Skip to content

Commit 688dcc1

Browse files
GeoJson: documentation for popup_keep_highlighted argument (#1854)
* added section to geojson.md * Update geojson.md --------- Co-authored-by: Frank <[email protected]>
1 parent 0d60932 commit 688dcc1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/user_guide/geojson/geojson.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,3 +257,29 @@ folium.GeoJson(
257257
258258
m
259259
```
260+
261+
#### Keep highlighted while popup is open
262+
263+
The `GeoJson` class provides a `popup_keep_highlighted` boolean argument.
264+
Whenever a GeoJson layer is associated with a popup and a highlight function
265+
is defined, this argument allows you to decide if the highlighting should remain
266+
active while the popup is open.
267+
268+
```{code-cell} ipython3
269+
m = folium.Map([43, -100], zoom_start=4)
270+
271+
popup = folium.GeoJsonPopup(fields=["name"])
272+
273+
folium.GeoJson(
274+
geo_json_data,
275+
highlight_function=lambda feature: {
276+
"fillColor": (
277+
"green" if "e" in feature["properties"]["name"].lower() else "#ffff00"
278+
),
279+
},
280+
popup=popup,
281+
popup_keep_highlighted=True,
282+
).add_to(m)
283+
284+
m
285+
```

0 commit comments

Comments
 (0)