More

Is there a way to change leaflet-gpx style?

Is there a way to change leaflet-gpx style?


I'm using the leaflet-gpx plugin to draw various .gpx files on my map. How can I change the color/style of it?

gpxvar[{{loop.index0}}] = new L.GPX("{{url_for('static', filename="gpx/" + r )}}", { async: true, marker_options: { startIconUrl: "{{url_for('static', filename="img/pin-icon-start.png">

ok it seems like as L.GPX extends L.featureGroup and that the latter has a setStyle method, one should just have to pass it while creating it. looking at the code it defaults to blue usingpolyline_options

so my code added it and I got different colors now :

var colors = ['red', 'purple']; gpxvar[{{loop.index0}}] = new L.GPX("{{url_for('static', filename="gpx/" + r )}}", { async: true, marker_options: { startIconUrl: "{{url_for('static', filename="img/pin-icon-start.png">ShareImprove this answeranswered Dec 11 '15 at 13:41euri10euri101414 bronze badges