Best approach to mapping with dynamic updates

Hey there,

I’ve been thrown into a data science project (yes, Covid-19) and have been experimenting heavily with streamlit, which is awesome. There may be one key concept I’m missing, however.

There’s one use case I’ve haven’t quite been able to master, which is producing rich and performant maps where the user can change what is being displayed on the maps, without the plot resetting itself when they change an option using provided controls. By this I mean, the users selects the fields for the size/colour/hovertext of the marker, and the markers and their data update quickly. I can make nice plots in several packages, for instance Plotly, but the downside is every time the user makes a change, I call my “make_plot” function, the chart is redrawn and the zoom/positioning is reset.

st.map is too simple for my uses and PyDeck seems to have several bugs, e.g. hovertext not supported. Is there anything I’m missing - some way to interact with a plot without redrawing the whole thing from scratch? I can’t tell from the docs how this is accomplished with the built-in map, for instance. And custom javascript seems unimplemented/not the streamlit way.

Any tips appreciated.

When you use streamlit selectors, it will always re-render the viz as everything is run from top to bottom.

I think the way to go is to use streamlit inputs for the big picture stuff which doesn’t get changed often, and the rest of the interactive map changes to do in plotly directly.

That way the often used sliders or dropdowns won’t re-render the whole thing.

see these covid dashboard - they are using altair for viz and are coding some of the selection stuff into altair itself.

1 Like

Hi @khalido, I did try to do the same in altair, but the graph freezes in streamlit when I change the slider embedded into altair. Things are working fine in Jupyter.