From 4ea09cdfdb97aae29cf1034a311a2d6a5a182f51 Mon Sep 17 00:00:00 2001 From: Qiusheng Wu Date: Thu, 17 Oct 2024 14:52:46 -0500 Subject: [PATCH] Fix ipyleaflet style str issue (#925) --- leafmap/leafmap.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/leafmap/leafmap.py b/leafmap/leafmap.py index 0369403204..bfca622725 100644 --- a/leafmap/leafmap.py +++ b/leafmap/leafmap.py @@ -2655,6 +2655,18 @@ def add_geojson( gdf = gdf.to_crs("EPSG:4326") data = gdf.__geo_interface__ + try: + first_feature = data["features"][0] + if isinstance(first_feature["properties"].get("style"), str): + # Loop through the features and update the style + for feature in data["features"]: + fstyle = feature["properties"].get("style") + if isinstance(fstyle, str): + feature["properties"]["style"] = json.loads(fstyle) + except Exception as e: + print(e) + pass + geom_type = gdf.geom_type[0] if style is None and (style_callback is None):