Skip to content

Commit fd0267d

Browse files
authored
docs: add GeoJson highlight_function arg (#1799)
1 parent 765f1f1 commit fd0267d

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

docs/user_guide/geojson/geojson.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,24 @@ colormap.add_to(m)
236236
237237
m
238238
```
239+
240+
### Highlight function
241+
242+
The `GeoJson` class provides a `highlight_function` argument, which works similarly
243+
to `style_function`, but applies on mouse events. In the following example
244+
the fill color will change when you hover your mouse over a feature.
245+
246+
```{code-cell} ipython3
247+
m = folium.Map([43, -100], zoom_start=4)
248+
249+
folium.GeoJson(
250+
geo_json_data,
251+
highlight_function=lambda feature: {
252+
"fillColor": (
253+
"green" if "e" in feature["properties"]["name"].lower() else "#ffff00"
254+
),
255+
},
256+
).add_to(m)
257+
258+
m
259+
```

0 commit comments

Comments
 (0)