From c940401a72ff8b0f51ac8e7349dbdbe7a8ebaa4d Mon Sep 17 00:00:00 2001 From: Zachary Blackwood Date: Thu, 16 Nov 2023 16:15:49 -0800 Subject: [PATCH] Support grouped layer control --- examples/pages/grouped_layer_control.py | 34 +++++++++++++++++++++ setup.py | 2 +- streamlit_folium/frontend/public/index.html | 5 +++ tests/test_frontend.py | 10 ++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 examples/pages/grouped_layer_control.py diff --git a/examples/pages/grouped_layer_control.py b/examples/pages/grouped_layer_control.py new file mode 100644 index 0000000..f8b6298 --- /dev/null +++ b/examples/pages/grouped_layer_control.py @@ -0,0 +1,34 @@ +import folium +import streamlit as st +from folium.plugins import GroupedLayerControl + +from streamlit_folium import st_folium + +st.set_page_config( + page_title="streamlit-folium documentation: Grouped Layer Control", + page_icon=":pencil:", + layout="wide", +) + +st.title("streamlit-folium: Grouped Layer Control") + +m = folium.Map([40.0, 70.0], zoom_start=6) + +fg1 = folium.FeatureGroup(name="g1") +fg2 = folium.FeatureGroup(name="g2") +fg3 = folium.FeatureGroup(name="g3") +folium.Marker([40, 74]).add_to(fg1) +folium.Marker([38, 72]).add_to(fg2) +folium.Marker([40, 72]).add_to(fg3) +m.add_child(fg1) +m.add_child(fg2) +m.add_child(fg3) + +folium.LayerControl(collapsed=False).add_to(m) + +GroupedLayerControl( + groups={"groups1": [fg1, fg2]}, + collapsed=False, +).add_to(m) + +st_folium(m) diff --git a/setup.py b/setup.py index 3e90f2b..1050cf7 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setuptools.setup( name="streamlit_folium", - version="0.15.1", + version="0.16.0", author="Randy Zwitch", author_email="rzwitch@gmail.com", description="Render Folium objects in Streamlit", diff --git a/streamlit_folium/frontend/public/index.html b/streamlit_folium/frontend/public/index.html index 0965439..c5eb42a 100644 --- a/streamlit_folium/frontend/public/index.html +++ b/streamlit_folium/frontend/public/index.html @@ -50,6 +50,7 @@ + +