Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix folium geojson style issue #922

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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