-
https://github.com/mapbox/pbf
- A low-level, lightweight protocol buffers implementation in JavaScript.
-
https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/getCurrentPosition
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};
function success(pos) {
var crd = pos.coords;
console.log('Your current position is:');
console.log(`Latitude : ${crd.latitude}`);
console.log(`Longitude: ${crd.longitude}`);
console.log(`More or less ${crd.accuracy} meters.`);
}
function error(err) {
console.warn(`ERROR(${err.code}): ${err.message}`);
}
navigator.geolocation.getCurrentPosition(success, error, options);
- https://github.com/mapbox/cheap-ruler
- Distance calculation.
var x = cheapRuler(lat1, 'kilometers');
x.distance([lat1, long1], [lat2, long2]);
OpenLocationCode.encode(lat, long)
OpenLocationCode.decode(lat, long)
var data = {values: [true, false, true, true, false]};
var x = new pbf();
x.writePackedBoolean(1, data.values);
var xbuff = x.finish();
function readData(tag, data, pbf) {
if (tag === 1) data.values= pbf.readPackedBoolean();
}
var xdata = new pbf(xbuff).readFields(readData, {});
console.log(xdata);