Turn an HTML5 Geoposition object into a regular object that can be serialized with JSON.stringify
npm install geoposition-to-objectTurn 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.
When using the geolocation feature in browsers, the object you'll get back
cannot be stringified:
``js
navigator.geolocation.getCurrentPosition(function(position) {
console.log(JSON.stringify(position))
})
// {}
`
This package exports a function that accepts a Geoposition and returns a
plain javascript Object with all the same deep properties.
`sh`
npm install geoposition-to-object --save
`js
var objectify = require('geoposition-to-object')
navigator.geolocation.getCurrentPosition(function(position) {
console.log(objectify(position))
})
// {
// timestamp: '2016-07-20T21:50:03.183Z',
// coords: {
// accuracy: 26,
// altitude: null,
// altitudeAccuracy: null,
// heading: null,
// latitude: 38.792024999999995,
// longitude: -104.8483681,
// speed: null
// }
// }
`
`sh``
npm install
npm test
None
- tap-spec: Formatted TAP output like Mocha's spec reporter
- tape: tap-producing test harness for node and browsers
MIT
_Generated by package-json-to-readme_