node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

Leaflet.MultiOptionsPolyline

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 (= 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).