File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -237,6 +237,23 @@ colormap.add_to(m)
237237m
238238```
239239
240+ >
241+ > ** Caveat**
242+ >
243+ > When using ` style_function ` in a loop you may encounter Python's 'Late Binding Closure' gotcha!
244+ > See https://docs.python-guide.org/writing/gotchas/#late-binding-closures for more info.
245+ > There are a few ways around it from using a GeoPandas object instead,
246+ > to "hacking" your ` style_function ` to force early closure, like:
247+ > ``` python
248+ > for geom, my_style in zip (geoms, my_styles):
249+ > style = my_style
250+ > style_function = lambda x , style = style: style
251+ > folium.GeoJson(
252+ > data = geom,
253+ > style_function = style_function,
254+ > ).add_to(m)
255+ > ```
256+
240257# ## Highlight function
241258
242259The `GeoJson` class provides a `highlight_function` argument, which works similarly
You can’t perform that action at this time.
0 commit comments