geoposition-to-object
Turn an HTML5 Geoposition object into a regular object that can be serialized with JSON.stringify
Pairs well with geolocation-stream.
See also geoposition-to-geojson, a very similar module that coerces geoposition objects into a Mapbox and/or OpenStreetMap-ready format.
Why
When using the geolocation feature in browsers, the object you'll get back cannot be stringified:
navigatorgeolocation // {}
This package exports a function that accepts a Geoposition and returns a plain javascript Object with all the same deep properties.
Installation
npm install geoposition-to-object --save
Usage
var objectify = navigatorgeolocation // {// timestamp: '2016-07-20T21:50:03.183Z',// coords: {// accuracy: 26,// altitude: null,// altitudeAccuracy: null,// heading: null,// latitude: 38.792024999999995,// longitude: -104.8483681,// speed: null// }// }
Tests
npm installnpm test
Dependencies
None
Dev Dependencies
- tap-spec: Formatted TAP output like Mocha's spec reporter
- tape: tap-producing test harness for node and browsers
License
MIT
Generated by package-json-to-readme