geo-loc-utils
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

geo-loc-utils

A small collection of geolocation/direction utilities.

  • getNavigatorCoords - get current position (a promise wrapper around Geolocation.getCurrentPosition)
  • degreeToCardinal - convert degree to a cardinal direction

Install

npm install geo-loc-utils

getNavigatorCoords

params:

  • options {object} - Geolocaiton.getCurrentPosition supports some options.
  • 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.
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')
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

Runtimes

Latest tested runtimes

  • node: 10.16.3
  • pnpm: 2.15.1

Package Sidebar

Install

npm i geo-loc-utils

Weekly Downloads

11

Version

1.0.2

License

ISC

Unpacked Size

22.5 kB

Total Files

17

Last publish

Collaborators

  • deanbot