2.0.2 • Published 7 years ago

code42day-google-polyline v2.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

NPM version Build Status Dependency Status

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

polyline.decode(string, factor)

returns array of point representing decoded polyline

  • string is an encoded polyline representation
  • factor - optional (defaults to 10e5), factor by which coordinates are divided after decoding; use factor 10e6 when decoding polylines from OSM data (OSRM, mapzen etc.)
2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.0

7 years ago