Git Product home page Git Product logo

leaflet.polylinedecorator's Introduction

Leaflet PolylineDecorator

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

Compatibility with Leaflet versions

The development version of the plugin (on the master branch) is now targeted at the dev version of Leaflet (0.8), which includes some API breaking changes.

For a version of the plugin compatible with the latest stable Leaflet release, use the leaflet-0.7.2 branch.

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(?)

leaflet.polylinedecorator's People

Contributors

bbecquet avatar gpbl avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.