Encodes and decodes Google's polyline format It's a forked version of google-polyline module with minor performance improvements and reversed order of coordinates: longitude, latitude (think x, y or easting, northing), which corresponds to position definition in GeoJSON spec.
Install via npm
$ npm install --save google-polyline
var polyline = require( 'google-polyline' )
polyline.encode([
[ -120.2, 38.5 ],
[ -120.95, 40.7 ],
[ -126.453, 43.252 ]
])
> '_p~iF~ps|U_ulLnnqC_mqNvxq`@'
polyline.decode( '_p~iF~ps|U_ulLnnqC_mqNvxq`@' )
> [
[ -120.2, 38.5 ],
[ -120.95, 40.7 ],
[ -126.453, 43.252 ]
]
returns string representing encoded polyline
points
is an array of points, each point is a 2 element array [longitude, latitude]
returns array of point representing decoded polyline