Plotly Mapbox not updating on selectbox change

When the user changes the selectbox option, the scatter mapbox dots do not update properly. They are there but invisible (you can mouse over and see the hover_data). If the user clicks full screen the map seems to refresh and the dots display properly.

selected_project = st.selectbox(label="**Select a Project:**", options=distinct_equipment_df['PROJECT'].unique())
project_lat_longs = distinct_equipment_df[distinct_equipment_df['PROJECT'] == selected_project]    
    
# Plot map for a selected project
px.set_mapbox_access_token(open(".mapbox_token").read())
fig = px.scatter_mapbox(project_lat_longs, lat="LATITUDE", lon="LONGITUDE", 
                    color="EQUIPMENT_TYPE", hover_name='LOCATION_ID',
                    hover_data =['STATUS', 'LATITUDE', 'LONGITUDE'],
                    color_discrete_sequence=px.colors.qualitative.G10, size_max=20, zoom=6,
                    height=400)
fig.update_layout(
        margin=dict(l=0, r=0, t=0, b=0))
    
st.plotly_chart(fig, use_container_width=True)
2 Likes

This does indeed seem to be a bug – probably another instance of this issue that was recently reported plotly_chart using cached data on axis · Issue #5902 · streamlit/streamlit · GitHub

Feel free to upvote that issue, and add your example if you’d like, but hopefully we’ll have a fix for this soon.

2 Likes

I found the same limitations, had to switch to pydeck and keplergl

I’m currently using the st.map function, which is a wrapper around st.pydeck_chart, but am running into the same issue as spencerv. Maybe it’s an issue with the streamlit refresh function for maps? Putting the map in fullscreen refreshes it as spencerv mentions, but it is a somewhat inelegant fix.

Can you try upgrading to the latest version of streamlit and see if that fixes the issue?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.