# geo-loc-utils

> js geolocation library - promise based method for retrieving navigator coords and other utils

Latest version **1.0.2** (published 2020-05-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install geo-loc-utils
pnpm add geo-loc-utils
yarn add geo-loc-utils
bun add geo-loc-utils
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-05-29 |
| First published | 2017-04-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 22 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Dean Verleger |
| Maintainers | deanbot |
| Keywords | geolocation, location, loc, geo, navigator, position, currentPosition, degree, cardinal, bearing |

## Links

- npm: https://www.npmjs.com/package/geo-loc-utils
- Repository: https://github.com/deanbot/geo-loc-utils
- Homepage: https://github.com/deanbot/geo-loc-utils#readme
- Issues: https://github.com/deanbot/geo-loc-utils/issues
- npm.io page: https://npm.io/package/geo-loc-utils

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-05-29
- 1.0.1 — 2020-05-28
- 1.0.0 — 2020-05-28
- 0.0.4 — 2020-05-28
- 0.0.3 — 2020-05-28
- 0.0.2 — 2017-04-06
- 0.0.1 — 2017-04-06

## README

# geo-loc-utils

A small collection of geolocation/direction utilities.

* getNavigatorCoords - get current position (a promise wrapper around [Geolocation.getCurrentPosition](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition))
* degreeToCardinal - convert degree to a cardinal direction

### Install

`npm install geo-loc-utils`

### getNavigatorCoords

params:
  * `options` {object} - Geolocaiton.getCurrentPosition supports [some options](https://developer.mozilla.org/en-US/docs/Web/API/PositionOptions).
  * `ignoreCache` {boolean} - Results are stored in memory by default and returned by subsequent calls. To get around this pass true as the second argument to ignore cache.

```js
import { getNavigatorCoords } from 'geo-loc-utils';

// prompts browser to allow location access
getNavigatorCoords()
  .then(position => console.log(position));
```

### degreeToCardinal

params:
 * `degree` {Number} - degree to convert
 * `secondaryInterCardinals` {Boolean} - whether to include secondary interCardinal directions (i.e. 'NNE', 'SSW')

```js
import { degreeToCardinal } from 'geo-loc-utils';

const windBearing = 342;
const windDirection = degreeToCardinal(windBearing);
console.log(windDirection);
```

# Development

- Notes:
  - Written in TypeScript
  - Compiled to UMD via WebPack
  - Compiled to ES6 via TSC
  - Typings generated by TSC
  - geolocation isn't supported when serving localhostf
- Setup: `pnpm install`
- Serve: `pnpm run start`

See [index.ejs](./index.ejs)

## Runtimes

Latest tested runtimes

- node: 10.16.3
- pnpm: 2.15.1

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