leaflet-choropleth icon indicating copy to clipboard operation
leaflet-choropleth copied to clipboard

Change style dynamically

Open barryrowlingson opened this issue 8 years ago • 1 comments

Feature request: is it possible to change the style after creating a layer? I'd like to show a map and then have a drop down of feature names, and then update the layer to colour by that feature, possibly with a different colour scale.

At present I don't think it can be easily done because the colour mapping info is stored in opts which has the scope of the L.choropleth constructor - changing mylayer.options and forcing a style update with mylayer.setStyle(mylayer.options.style) doesn't work. I can't actually see how a style function can get anything from the layer options, but my JS skills are poor, especially understanding scope in JS...

barryrowlingson avatar Sep 29 '17 16:09 barryrowlingson

Hi Barry, that's an interesting question. I'm not entirely sure. The Choropleth method just extends the GeoJSON method, so I think if you do some googling on how you would change a GeoJSON layer dynamically, you could apply that approach to this module as well.

timwis avatar Oct 11 '17 09:10 timwis