Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

polyline-encoded

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polyline-encoded

Encoding and decoding of Google's polyline encoding format

  • 0.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.2K
increased by1.12%
Maintainers
1
Weekly downloads
 
Created
Source

Support encoded polylines in Leaflet


This Leaflet plugin extends the Leaflet API with functions to encode en decode Google maps polyline encoding. It is just a convenient way to use the algorithm from http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/ in Leaflet.

Provided methods

Utility methods
L.PolylineUtil.encode(latlngs)Encode an array of L.LatLng objects.
L.PolylineUtil.decode(encoded)Decode the string encoded to an array of L.LatLng objects.
Extensions for L.Polyline
L.Polyline.fromEncoded(encoded [, options])Construct a L.Polyline from a string, with optional options object.
L.Polyline.encodePath()Return an encoded string for the current Polyline.
Extensions for L.Polygon
L.Polygon.fromEncoded(encoded [, options])Construct a L.Polygon from a string, with optional options object.
L.Polygon.encodePath()Return an encoded string for the current Polygon.

Code examples

After loading leaflet.js, src/Polyline.encoded.js should be included.

Encoding

var latlngs = [
	new L.LatLng(38.5, -120.5),
	new L.LatLng(40.7, -120.95),
	new L.LatLng(43.252, -126.453)
];
var polyline = new L.Polyline(latlngs);

//prints "_p~iF~cn~U_ulLn{vA_mqNvxq`@" to the console
console.log(polyline.encodePath());

Decoding

var encoded = "_p~iF~cn~U_ulLn{vA_mqNvxq`@";
var polyline = L.Polyline.fromEncoded(encoded);

// prints an array of 3 LatLng objects.
console.log(polyline.getLatLngs());

Keywords

FAQs

Package last updated on 29 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc