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.
; // prompts browser to allow location access ;
degreeToCardinal
params:
degree
{Number} - degree to convertsecondaryInterCardinals
{Boolean} - whether to include secondary interCardinal directions (i.e. 'NNE', 'SSW')
; const windBearing = 342;const windDirection = ;console;
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