# x-geolocation

> Declarative Geolocation API as Web Components.

Latest version **2.1.1** (published 2020-01-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install x-geolocation
pnpm add x-geolocation
yarn add x-geolocation
bun add x-geolocation
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2020-01-07 |
| First published | 2014-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | 1000ch |
| Maintainers | 1000ch |
| Keywords | webcomponents, geolocation |

## Links

- npm: https://www.npmjs.com/package/x-geolocation
- Repository: https://github.com/1000ch/x-geolocation
- Issues: https://github.com/1000ch/x-geolocation/issues
- npm.io page: https://npm.io/package/x-geolocation

## Recent versions

- 2.1.1 (latest) — 2020-01-07
- 2.1.0 — 2020-01-02
- 2.0.0 — 2019-08-18
- 1.0.0 — 2015-05-29
- 0.1.2 — 2014-09-19
- 0.1.1 — 2014-09-18
- 0.1.0 — 2014-09-18

## README

# `<x-geolocation>`

> Declarative Geolocation API as Web Components.

[![Build Status](https://travis-ci.org/1000ch/x-geolocation.svg?branch=master)](https://travis-ci.org/1000ch/x-geolocation)
[![NPM version](https://badge.fury.io/js/x-geolocation.svg)](http://badge.fury.io/js/x-geolocation)
[![devDependency Status](https://david-dm.org/1000ch/x-geolocation/dev-status.svg)](https://david-dm.org/1000ch/x-geolocation?type=dev)

## Install

Using [npm](https://www.npmjs.org/package/x-geolocation):

```sh
$ npm install x-geolocation
```

## Usage

Import `XGeolocation` and register it.

```html
<script type="module">
import XGeolocation from 'https://unpkg.com/x-geolocation';

customElements.define('x-geolocation', XGeolocation);
</script>
```

Put `<x-geolocation>` tag.

```html
<x-geolocation></x-geolocation>
```

### Monitoring position change

To monitor position changing, execute `monitorPosition()` function.

```js
document.querySelector('x-geolocation').monitorPosition();
```

Or set `monitor` attribute.

```html
<x-geolocation monitor></x-geolocation>
```

### 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)

---
_Source: https://npm.io/package/x-geolocation · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
