S
S
survivalsuit2020-11-10 10:51:20
JavaScript
survivalsuit, 2020-11-10 10:51:20

How to make a polyline painted in different colors?

How to make a polyline painted in different colors? The bottom line is that you need to paint a certain percentage of the polyline with a different color, roughly speaking, there will be a load indicator, it must be displayed somehow.
Any ideas?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2020-11-10
@freeExec

Specify a different color when creating a line

var polyline = L.polyline(latlngs, {color: 'red'}).addTo(map);

Or if it's a gejson
L.geoJSON(states, {
    style: function(feature) {
        switch (feature.properties.party) {
            case 'Republican': return {color: "#ff0000"};
            case 'Democrat':   return {color: "#0000ff"};
        }
    }
}).addTo(map);

S
survivalsuit, 2020-11-10
@survivalsuit

Well, you can change the color, I understand that, but for example, I would like to know if there is a method that allows you to paint a polyline, for example, 70 percent of the length in orange and the rest in black ....
I found such an extension https://github.com/hgoebl /Leaflet.MultiOptionsPolyline
but it somehow builds on other data...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question