randyzwitch / streamlit-folium

Streamlit Component for rendering Folium maps
https://folium.streamlit.app/
MIT License
468 stars 176 forks source link

GroupedLayerControl breaks st_folium #150

Closed fcusimano closed 10 months ago

fcusimano commented 10 months ago

When using folium.plugins.GroupedLayerControl, my map looks like this: image

When I use folium.LayerControl, it looks like this: image

Code example:

m = folium.Map(
    location=[city.dissolve().centroid.y, city.dissolve().centroid.x],
    tiles="cartodbpositron",
    zoom_start=11,
)

folium.GeoJson(
    city,
    style_function=lambda x: {"color": "black", "fill": None, "weight": 0.5},
    control=False,
).add_to(m)

transit_layer = folium.GeoJson(
      geo_data_dict["transit"].data_per_point,
      style_function=lambda x: {"color": "red"},
      control=True,
      name="transit",
      show=False,
  ).add_to(m)

GroupedLayerControl({"Per point": [transit_layer]}).add_to(m)
# folium.LayerControl(collapsed=False).add_to(m)

st_folium(
        m,
        use_container_width=True,
    )

A similar issue has been mentioned in https://github.com/randyzwitch/streamlit-folium/issues/139 but the discussion focused more on SideBySideLayers

BastienGauthier commented 10 months ago

For information, I used to have this error when I used a marker with the same name multiple times, working with folium_static but not st_folium.