Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MarkerCluster not working properly in Streamlit 1.34 onwards #222

Open
benjamin-awd opened this issue Sep 28, 2024 · 5 comments
Open

MarkerCluster not working properly in Streamlit 1.34 onwards #222

benjamin-awd opened this issue Sep 28, 2024 · 5 comments

Comments

@benjamin-awd
Copy link

It seems that Streamlit version 1.34 introduced some kind of regression for Folium -- specifically it disables the Spiderfy functionality in MarkerCluster (and I think any related interactivity)

Expected
(on click)
image

Current
folium_regression

To reproduce

pip install streamlit==1.34
import streamlit as st

st.set_page_config(
    page_title="streamlit-folium documentation",
    page_icon=":world_map:️",
    layout="wide",
)

left, right = st.columns(2)

with left:
    with st.echo():
        import folium
        import streamlit as st

        from streamlit_folium import st_folium
        from folium.plugins import MarkerCluster

        # center on Liberty Bell, add marker
        m = folium.Map(location=[39.949610, -75.150282], zoom_start=16)
        
        marker_cluster = MarkerCluster().add_to(m)
        folium.Marker(
            [39.949610, -75.150282], popup="Liberty Bell", tooltip="Liberty Bell"
        ).add_to(marker_cluster)
        folium.Marker(
            [39.949610, -75.150282], popup="Liberty Bell", tooltip="Liberty Bell"
        ).add_to(marker_cluster)
        folium.Marker(
            [39.949610, -75.150282], popup="Liberty Bell", tooltip="Liberty Bell"
        ).add_to(marker_cluster)

        # call to render Folium map in Streamlit
        st_data = st_folium(m, width=725)

with right:
    st_data
@benjamin-awd benjamin-awd changed the title MarkerCluster not working in Streamlit 1.34 onwards MarkerCluster not working properly in Streamlit 1.34 onwards Sep 28, 2024
@benjamin-awd benjamin-awd reopened this Sep 29, 2024
@benjamin-awd
Copy link
Author

Spent a bit of time figuring out the bad commit upstream with git bisect, and it seems to be this one: streamlit/streamlit@ea17620

It seems to be a fairly innocuous change, but somehow breaks the spiderfy functionality.

@blackary
Copy link
Collaborator

Spent a bit of time figuring out the bad commit upstream with git bisect, and it seems to be this one: streamlit/streamlit@ea17620

It seems to be a fairly innocuous change, but somehow breaks the spiderfy functionality.

Wow, thanks for doing that digging! I'll reach out to the streamlit team and see if they have any insights.

@benjamin-awd
Copy link
Author

benjamin-awd commented Sep 30, 2024

thanks @blackary @randyzwitch!

I ended up creating a .tar.gz of 1.38 without that particular commit, and it seems to be working well for my app: https://hdb-kaki.streamlit.app/Town_Analysis

To reproduce, you can try running the script above with Streamlit 1.38 (the spiderfy functionality should be missing). Then drop that specific commit from the Streamlit commit history, recompile using make package, and add the tar.gz file to your dependencies and re-run.

Otherwise if it's useful, I created a demo branch with the original bug: https://github.com/benjamin-awd/hdb-kaki/tree/folium-regression-demo

Btw, had no issues running on Safari even without that commit

@kmcgrady
Copy link
Contributor

Hey @randyzwitch @benjamin-awd ! Thanks for letting us know. I'm having trouble figuring out what is going on from Streamlit's side that could be causing the issue. We did notice that v0.20.0 works but v0.20.1 does not work. Looking at the Network logs I see the Marker Cluster is inserted after the map information (that all being said, I see scripts duplicated multiple times). This leads me to think this might be tied to this change surrounding the dynamic load of the JS instances.

image

@randyzwitch
Copy link
Owner

Interesting that this might both be a streamlit and a streamlit-folium issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants