This package has been deprecated

Author message:

WARNING: This package has been renamed. Install @pirxpilot/google-polyline instead; see https://github.com/pirxpilot/google-polyline

code42day-google-polyline

2.0.2 • Public • Published

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

  • 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

  • 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.)

Package Sidebar

Install

npm i code42day-google-polyline

Weekly Downloads

2

Version

2.0.2

License

MIT

Last publish

Collaborators

  • deprecated.packages