Socket
Socket
Sign inDemoInstall

leaflet-polylinedecorator

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-polylinedecorator

A plug-in for the Leaflet map library to define patterns (like dashes, arrows, icons, etc.) on Polylines


Version published
Weekly downloads
12K
decreased by-8.63%
Maintainers
1
Weekly downloads
 
Created
Source

Leaflet PolylineDecorator

A Leaflet plug-in to define and draw patterns on existing Polylines or along coordinate paths.

Features

  • Dashed or dotted lines, arrow heads, markers following line
  • Works on Polygons too! (easy, as Polygon extends Polyline)
  • Multiple patterns can be applied to the same line
  • New behaviors can be obtained by defining new symbols

Usage

    var polyline = L.polyline([...]).addTo(map);
    var decorator = L.polylineDecorator(polyline, {
        patterns: [
            // define a pattern of 10px-wide dashes, repeated every 20px on the line 
            {offset: 0, repeat: '20px', symbol: new L.Symbol.Dash({pixelSize: 10})}
        ]
    }).addTo(map);

The polyline parameter can be a single array of L.LatLng or, with Leaflet's simplified syntax, an array of 2-cells arrays of coordinates. It is useful if you don't want to actually display a polyline, but just a pattern following coordinates, like a dotted line.

Screenshot

screenshot

Performance note

Please note that this library is in an early stage, and many operations could still be optimized. Moreover, as it requires a lot of (re-)computations, and each pattern symbol is an actual L.ILayer object, it can have an impact on the responsiveness of your map, especially if used on many objects. In cases where it's applicable (dash patterns), you should probably use instead the dashArray property of L.Path, as it's natively drawn by the browser.

TODO

  • Documentation
  • Optimize rendering and mem footprint
  • Other symbol types
  • Animations(?)

Keywords

FAQs

Package last updated on 06 Aug 2016

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