2.0.2 • Published 7 years ago
code42day-google-polyline v2.0.2
google-polyline
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
Usage
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 ]
]
API
polyline.encode(points)
returns string representing encoded polyline
points
is an array of points, each point is a 2 element array longitude, latitude
polyline.decode(string, factor)
returns array of point representing decoded polyline