From d16b04a026261804e01de9133ea5c27c51e8b553 Mon Sep 17 00:00:00 2001
From: Qiusheng Wu <giswqs@gmail.com>
Date: Wed, 16 Oct 2024 15:05:18 -0400
Subject: [PATCH] Fix folium geojson style issue

---
 leafmap/foliumap.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/leafmap/foliumap.py b/leafmap/foliumap.py
index 25dc02bfa3..c1cfa5a82c 100644
--- a/leafmap/foliumap.py
+++ b/leafmap/foliumap.py
@@ -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:
@@ -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,
@@ -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":