react-geolocation-element
v0.1.2
Published
A lightweight React wrapper for the `<geolocation>` element
Readme
react-geolocation-element
A lightweight React wrapper for the <geolocation> element
Installation
npm i react-geolocation-elementUsage
import GeoLocation from 'react-geolocation-element';
<GeoLocation
autolocate
accuracymode="precise"
watch
onLocation={(
position: GeolocationPosition | null,
err?: GeolocationPositionError | null
) => {
if (position) {
console.log(position);
} else if (err) {
console.error(err);
}
}}
>
<button
type="button"
onClick={() => navigator.geolocation.getCurrentPosition(console.log)}
>
Use my location
</button>
</GeoLocation>;Link
Contributing
Please see CONTRIBUTING.md for contribution guidelines.
License
MIT
