randyzwitch / streamlit-folium

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

Support for Folium Realtime plugin. #174

Closed Wosin closed 5 months ago

Wosin commented 6 months ago

Folium has recently merged changes that allow defining markers that are updated in real time using Javascript code.

Currently, it seems that streamlit-folium doesn't currently support that. I've tried very simple code:

import folium
from folium import JsCode
from streamlit_folium import st_folium

m = folium.Map(location=[40.73, -73.94], zoom_start=12)
rt = folium.plugins.Realtime(
    "https://raw.githubusercontent.com/python-visualization/folium-example-data/main/subway_stations.geojson",
    get_feature_id=JsCode("(f) => { return f.properties.objectid; }"),
    interval=10000,
)
rt.add_to(m)
st_data = st_folium(m)

But that just causes the map to be minimized (no matter what are actual dimensions defined):

image

Is there a known limitation that makes it impossible to use realtime plugin with streamlit-folium ??