Skip to content

Commit

Permalink
Fix folium geojson style issue (#922)
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs authored Oct 16, 2024
1 parent 062984f commit cfce631
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions leafmap/foliumap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ def add_geojson(
kwargs["style_function"] = kwargs.pop("style_callback")

style_dict = {}
if "style_function" not in kwargs:
if "style_function" not in kwargs and ("style" not in gdf.columns):
if "style" in kwargs:
style_dict = kwargs["style"]
if isinstance(kwargs["style"], dict) and len(kwargs["style"]) > 0:
Expand Down Expand Up @@ -1476,7 +1476,7 @@ def random_color(feature):
if "weight" not in style_dict:
style_dict["weight"] = 2

if "highlight_function" not in kwargs:
if "highlight_function" not in kwargs and ("style" not in gdf.columns):
kwargs["highlight_function"] = lambda feat: {
"weight": style_dict["weight"] + 2,
"fillOpacity": 0,
Expand All @@ -1490,6 +1490,8 @@ def random_color(feature):
kwargs.pop("fields")
else:
props = list(data["features"][0]["properties"].keys())
if "style" in gdf.columns:
props.remove("style")
if info_mode == "on_hover":
tooltip = folium.GeoJsonTooltip(fields=props)
elif info_mode == "on_click":
Expand Down

0 comments on commit cfce631

Please sign in to comment.