Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change style dynamically #24

Open
barryrowlingson opened this issue Sep 29, 2017 · 1 comment
Open

Change style dynamically #24

barryrowlingson opened this issue Sep 29, 2017 · 1 comment

Comments

@barryrowlingson
Copy link

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...

@timwis
Copy link
Owner

timwis commented Oct 11, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants