Skip to content

lyvyu/Leaflet.MultiOptionsPolyline

 
 

Repository files navigation

Leaflet.MultiOptionsPolyline

A Leaflet-plugin to enable multiple styles for a polyline.

Here you can see a demo.

Usage

Have a look at the demo. Links to source code are included.

Example

L.multiOptionsPolyline(points, {
    multiOptions: {
        optionIdxFn: function (latLng) {
            var i,
                altThresholds = [800, 900, 1000, 1100, 1200, 1300, 1400, 1500];

            for (i = 0; i < altThresholds.length; ++i) {
                if (latLng.alt <= altThresholds[i]) {
                    return i;
                }
            }
            return altThresholds.length;
        },
        options: [
            {color: '#0000FF'}, {color: '#0040FF'}, {color: '#0080FF'},
            {color: '#00FFB0'}, {color: '#00E000'}, {color: '#80FF00'},
            {color: '#FFFF00'}, {color: '#FFC000'}, {color: '#FF0000'}
        ]
    },
    weight: 5,
    lineCap: 'butt',
    opacity: 0.75,
    smoothFactor: 1}).addTo(map);

Installation

Bower

$ bower install hgoebl/Leaflet.MultiOptionsPolyline --save

License

MIT-License (see LICENSE file).

About

A Leaflet plugin for multi-colored polyline

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 71.3%
  • HTML 28.7%