Skip to content

Commit

Permalink
GeoJson: documentation for popup_keep_highlighted argument (#1854)
Browse files Browse the repository at this point in the history
* added section to geojson.md

* Update geojson.md

---------

Co-authored-by: Frank <33519926+Conengmo@users.noreply.github.com>
  • Loading branch information
GiuseppeGalilei and Conengmo authored Jan 2, 2024
1 parent 0d60932 commit 688dcc1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/user_guide/geojson/geojson.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,29 @@ folium.GeoJson(
m
```

#### Keep highlighted while popup is open

The `GeoJson` class provides a `popup_keep_highlighted` boolean argument.
Whenever a GeoJson layer is associated with a popup and a highlight function
is defined, this argument allows you to decide if the highlighting should remain
active while the popup is open.

```{code-cell} ipython3
m = folium.Map([43, -100], zoom_start=4)
popup = folium.GeoJsonPopup(fields=["name"])
folium.GeoJson(
geo_json_data,
highlight_function=lambda feature: {
"fillColor": (
"green" if "e" in feature["properties"]["name"].lower() else "#ffff00"
),
},
popup=popup,
popup_keep_highlighted=True,
).add_to(m)
m
```

0 comments on commit 688dcc1

Please sign in to comment.