How can I only show map markers based on the user's current view?

I have between 10,000 and 50,000 map points that need to be shown within a city space.

Each of those markers has a lat and lon, but when loading them into google maps with blocks I can only really load all of them, this takes a while.

How can I store them and only show them based on the coordinates?

Google Maps itself has a “Search This Area” button to only load results.

I can create a button (thought I would rather it be automatic), so how can I load them (very quickly) based on that area?

Can I find the grid that maps is showing and the run through a stored list of points to filter out the ones that fit within that?

Thank you.

I’d recommend letting a backend handle this type of work. Xano, backendless, Firebase/firestore can all do this for you quite easily


I have thought about that, but as phones are powerful enough to do this kind of compute when the data is already on the device (especially if it’s in a local DB), I thought it might be a better idea to generate this locally and save myself cloud compute.

But thanks, I’ll look into it some more.

In that case, check out this solution and the supplement

[Solved] How do I find/add Map Markers Nearest to the User (Haversine formula)

Distance between two coordinates