-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
bugAn issue describing unexpected or malicious behaviourAn issue describing unexpected or malicious behaviour
Description
Describe the bug
Both in a loop or using a GeoDataframe, only the last style is applied to all geometries.
We can see that in our docs:
To Reproduce
I also believe #1608 is related.
Expected behavior
We expect each geometry to have its own color defined by the style column.
Environment (please complete the following information):
- Browser: all tested
- Jupyter Notebook or html files? Both.
- Python version: 3.11
- folium version: 0.16.0
- branca version: 0.7.1
Additional context
In a loop one can "hack" this problem by assigning a unique value using exec (note recommended though).
import folium
m = folium.Map()
for k, glider in gdf.iterrows():
exec(f"style_function = lambda x: {glider['style']}") # hack it to make it work
# style_function = lambda x: glider['style'] # shows the bug
folium.GeoJson(
data=glider["geometry"],
style_function=style_function,
).add_to(m)
mPossible solutions
I'll investigate more and see if I can come up with something.
I did try with latest branca and folium and this is not solved yet.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugAn issue describing unexpected or malicious behaviourAn issue describing unexpected or malicious behaviour
