Streamlit Folium Update -- more dynamic maps

Streamlit-folium 0.8.0 was just released, and it contains new functionality for dynamic maps.
ezgif-1-0189d7f263

If you’re only making static maps (not adding/removing/updating things within your app), then you may not make use of this. But, if you’re changing your map (e.g. changing the markers that are on the map, moving to a new location, etc.) via other streamlit widgets, you can now do that without re-drawing the map every time.

The new arguments to st_folium are zoom (takes an int), center (takes a pair of floats for lat/lng), and feature_group_to_add (which accepts any folium FeatureGroup). If these arguments are passed to st_folium, and you change them from within your streamlit app, the map will not be redrawn from scratch, but will be updated in-place.

You can try this out here: https://folium.streamlit.app/dynamic_map_vs_rerender

Hope you all enjoy this new functionality!

3 Likes

Thanks for the update! This will be very useful.