Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server side clusters of coordinates based on zoom level

Thanks to this answer I managed to come up with a temporary solution to my problem.

However, with a list of 6000 points that grows everyday it's becoming slower and slower.

I can't use a third party service* therefore I need to come up with my own solution.

Here are my requirements:

  1. Clustering of the coordinates need to work with any zoom level of the map.

  2. All clusters need to be cached

  3. Ideally there won't be a need to cluster (calculate distances) on all points if a new point is added.

So far I have implemented quadtree that returns the four boundaries of my map and returns whatever coordinates are within the viewable section of the map.

What I need and I know this isn't easy is to have clusters of the points returned from the DB (postgres).

like image 667
Eeyore Avatar asked Dec 04 '25 17:12

Eeyore


1 Answers

I am currently doing dynamic server-side clustering of about 2,000 markers, but it runs pretty quick up to 20,000. You can see discussion of my algorithm here:

Map Clustering Algorithm

Whenever the user moves the map I send a request with the zoom level and the boundaries of the view to the server, which clusters the viewable markers and sends it back to the client.

I don't cache the clusters because the markers can be dynamically filtered and searched - but if they were pre-clustered it would be super fast!

like image 116
Chris B Avatar answered Dec 07 '25 07:12

Chris B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!