I want to change the options assigned to a Leaflet polyline (and then render it) after building it:
// Add polyline
var polyline = L.polyline([], {weight:weight, opacity:1, color:'gray'}).addTo(map);
// Attempts to change color
polyline.options.color = 'blue' // doesn't render
polyline.options.color('blue') // throws error
polyline({color:'blue'}) // throws error
polyline._updateStyle(polyline) // throws error: not sure how exactly this works
polyline._updateStyle() // throws error
polyline({color:blue}) // throws error
Is this possible?
L.Polyline
is extended from L.Path
which has a setStyle
method:
polyline.setStyle({
color: 'black'
});
Example: http://plnkr.co/edit/kfLcoG?p=preview
Reference: http://leafletjs.com/reference.html#path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With