GitHub
# x-geolocation ![GitHub Actions Status](https://github.com/1000ch/x-geolocation/workflows/test/badge.svg)
Declarative Geolocation API as Web Components.
## Demo
Latitude:
Longitude:
## Install
Using [npm](https://www.npmjs.org/package/x-geolocation):
```sh
$ npm install x-geolocation
```
## Usage
Import `XGeolocation` and register it.
```html
```
Put `` tag.
```html
```
### Monitoring position change
To monitor position changing, execute `monitorPosition()` function.
```js
document.querySelector('x-geolocation').monitorPosition();
```
Or set `monitor` attribute.
```html
```
### Handle position changes
Handle `positionchange` event using `addEventListener()`.
```js
document.querySelector('x-geolocation').addEventListener('positionchange', e => {
console.log('latitude:', e.detail.latitude);
console.log('longitude:', e.detail.longitude)
});
```
## License
[MIT](https://1000ch.mit-license.org) © [Shogo Sensui](https://github.com/1000ch)