What's the best way to seamlessly update a map?

I have an app I just deployed to Streamlit cloud. I don’t think it’s quite ready because it has a very annoying problem which I’m hoping I could get some help with. The map does not update correctly.

I would like it to do is load the data for the visible section as I pan and zoom in/out. What I end up however is this abrupt change.


I’ve combed through the documentation for Streamlit and PyDeck and with no luck. And I’ve even thrown an LLM at it no results.

Anyway, if someone is up for taking a shot at it, I’d be quite grateful. Here’s the repo – GitHub - hrokr/Quakes

Thanks

That appears to be because you’re wrapping around to a new “copy” of the earth, and so it’s shifting over the dots to be on the new copy. This is a pretty silly fix, but seems to work:

        quakes = pd.read_parquet(
            recent_file_url,
            engine="pyarrow",
            columns=[
                "datetime",
                "longitude",
                "latitude",
                "place",
                "mag",
                "depth",
                "tsunami_warning",
            ],
        )

        # Duplicate the data + and - 360 degrees longitude
        quakes_plus = quakes.copy()
        quakes_plus["longitude"] = quakes_plus["longitude"] + 360
        quakes = pd.concat([quakes, quakes_plus])

        quakes_minus = quakes.copy()
        quakes_minus["longitude"] = quakes_minus["longitude"] - 360
        quakes = pd.concat([quakes, quakes_minus])

By the way, if you want to dynamically update the map based on where the user has scrolled and zoomed, you might want to check out Streamlit-Folium https://folium.streamlit.app/, which returns the coordinates of the current boundaries of the map as you move around.

That kind of worked. It did cause the dots to display as desired however it also messed up the analytics in the process and it didn’t work for geojson gridlines.

However, it was exactly what I needed to get over the hump so thank you so very much.

1 Like

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