From 98362ca2e6a921e542b0c86374505182ff450d75 Mon Sep 17 00:00:00 2001 From: Zachary Blackwood Date: Thu, 17 Mar 2022 15:54:15 -0400 Subject: [PATCH] Get map zoom (#39) * Get map zoom * Bump version --- setup.py | 2 +- streamlit_folium/frontend/src/index.tsx | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 6640792..7fb8e46 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setuptools.setup( name="streamlit_folium", - version="0.6.2", + version="0.6.3", author="Randy Zwitch", author_email="randy@streamlit.io", description="Render Folium objects in Streamlit", diff --git a/streamlit_folium/frontend/src/index.tsx b/streamlit_folium/frontend/src/index.tsx index 39f5a21..3639934 100644 --- a/streamlit_folium/frontend/src/index.tsx +++ b/streamlit_folium/frontend/src/index.tsx @@ -10,6 +10,7 @@ type GlobalData = { last_active_drawing: any, all_drawings: any, bounds: any; + zoom: any; }; declare var __GLOBAL_DATA__: GlobalData; @@ -40,12 +41,14 @@ function onRender(event: Event): void { const global_data = __GLOBAL_DATA__; let map = global_data.map; let bounds = map.getBounds(); + let zoom = map.getZoom(); Streamlit.setComponentValue({ last_clicked: global_data.lat_lng_clicked, last_object_clicked: global_data.last_object_clicked, all_drawings: global_data.all_drawings, last_active_drawing: global_data.last_active_drawing, bounds: bounds, + zoom: zoom, }) } @@ -105,6 +108,7 @@ function onRender(event: Event): void { last_object_clicked: null, all_drawings: null, last_active_drawing: null, + zoom: null, };`; let replaced = fig + set_global_data; render_script.innerHTML = replaced;