- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 210
 
Description
I'm building a map in Streamlit where certain interactions trigger dynamic updates without needing to rerender the entire map. I've been able to implement this using folium.FeatureGroup, but there's an issue with the colormap. I want the colormap to update dynamically alongside the map when values change due to user interaction.
Here’s a simplified version of my code:
m = folium.Map(location=center_start, zoom_start=zoom_start)
folium.TileLayer("CartoDB positron", name="Light Map", control=True).add_to(m)
colormap = branca.colormap.LinearColormap(
    vmin=data[column].min(),
    vmax=data[column].max(),
    colors=colors,
    caption=caption
)
# colormap.add_to(m)
feature_group_to_add = folium.FeatureGroup(name="Cities")
feature_group_to_add.add_child(colormap)When I use colormap.add_to(m), it works perfectly, but the issue arises when the colormap changes. It forces the entire map to be rerendered, which I want to avoid. I would prefer to update the map dynamically without triggering a full reload.
However, when I try adding colormap to feature_group_to_add with feature_group_to_add.add_child(colormap), it doesn't seem to work. Have I missed something? Any help would be greatly appreciated. Thanks in advance!