Skip to content

Commit

Permalink
docs: add GeoJson highlight_function arg (#1799)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conengmo authored Sep 6, 2023
1 parent 765f1f1 commit fd0267d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/user_guide/geojson/geojson.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,24 @@ colormap.add_to(m)
m
```

### Highlight function

The `GeoJson` class provides a `highlight_function` argument, which works similarly
to `style_function`, but applies on mouse events. In the following example
the fill color will change when you hover your mouse over a feature.

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

0 comments on commit fd0267d

Please sign in to comment.