folium
folium copied to clipboard
Feature request: dynamic style functions
If you have multiple features on a geojson file, it would be handy to keep the features as 'abstract' layers to select which style to be used. By 'abstract' here I mean that they're working on the same data.
An example could be to highlight a set of polygons reflecting feature A in abstract layer 1, while it would highlight feature B in abstract layer 2.
Right now I would have to add the same polygons (geojson) with different style functions to achieve this, essentially duplicating the data. The problem grows with more features I would want to illustrate..
Hi @Trollgeir, I think I understand what you mean. We currently don't have that exact functionality in folium.
We recently merged a change where you can use GeoJson
with a style_function
and still not embed the data in the html, if you pass a URL or a file path. Would that work for you? You can make multiple GeoJson
objects, each with their own style_function
, but not embed the data so they can use the same data source.
@Conengmo what merge is this? This could possibly contribute to another issue: https://github.com/python-visualization/folium/issues/975#issuecomment-476022831
That was #1058.
As I understood it #975 is more about general solutions to reduce the html size, not about optimizing a single class (like GeoJson
). Though of course ideas to improve are welcome whatever their scope. But if you want to talk about GeoJson
specifically let's open a new issue.