open-location-code
Advanced tools
Comparing version
{ | ||
"name": "open-location-code", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Open Location Codes are a way of encoding location into a form that is easier to use than latitude and longitude. Source for a website to demonstrate Open Location Codes. (https://github.com/google/open-location-code)", | ||
@@ -5,0 +5,0 @@ "main": "openlocationcode.js", |
@@ -78,3 +78,29 @@ Open Location Code | ||
------------ | ||
var OpenLocationCode = require('open-location-code').OpenLocationCode; | ||
var openLocationCode = new OpenLocationCode(); | ||
// Encode a location, default accuracy: | ||
var code = openLocationCode.encode(47.365590, 8.524997); | ||
console.log(code); | ||
// Encode a location using one stage of additional refinement: | ||
code = openLocationCode.encode(47.365590, 8.524997, 11); | ||
console.log(code); | ||
//Decode a full code: | ||
var coord = openLocationCode.decode(code); | ||
var msg = 'Center is ' + coord.latitudeCenter + ',' + coord.longitudeCenter; | ||
console.log(msg); | ||
// Attempt to trim the first characters from a code: | ||
var shortCode = openLocationCode.shorten('8FVC9G8F+6X', 47.5, 8.5); | ||
console.log(shortCode); | ||
// Recover the full code from a short code: | ||
var nearestCode = openLocationCode.recoverNearest('9G8F+6X', 47.4, 8.6); | ||
console.log(nearestCode); | ||
nearestCode = openLocationCode.recoverNearest('8F+6X', 47.4, 8.6); | ||
console.log(nearestCode); | ||
The subdirectories contain sample implementations and tests for different | ||
@@ -81,0 +107,0 @@ languages. Each implementation provides the following functions: |
49059
2%118
28.26%