Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server side clustering?

I've desperately searched for the right solution that could handle up to 50 000 markers ( and why not even more if server can handle it ) while being easy on my server and I've been doing this for days.


Concept is something like this:

enter image description here


  • What would be the best solution / language for clustering server side? Im not looking for a huge working code but I need to be pushed to right direction.
  • How to "cache" or "mark" already loaded clusters / markers so that you wouldn't reload markers / clusters that has already been loaded when map is beeing zoomed in/out or panned?

Theory:

Right way to go seems similar to this:

  • If map is zoomed out and there are a lot of markers, handle clustering in server
  • If map is zoomed in to a point that all markers don't fit to viewport anymore, cluster only markers that are in viewport - also server
  • If zoom gets so big that number of markers in viewport gets small (< 500 for example), cluster in browser via JS

Data I could use in server side and which I could also send to browser via JSON:

  • Map bounds sent via ajax to server when request is made
  • Total count of markers from database query
  • Coordinates of markers from database query
  • Probably something else important / useful that Im currently not realizing
like image 852
Solo Avatar asked Jan 02 '16 09:01

Solo


1 Answers

I'm working with google maps applications with 50,000 100,000 polygon It has proved very useful the possibility of organizing the polygons into a series of regions, (sheets logic, areas or similar). Using an array of regions already displayed that is sent to the server via ajax along with the coordinates you bound allowed me to select only regions not yet displayed and thus reduce both the bandwidth allocation is the time for rendering polygons,

For the rest of the strategy is right. for a more thorough evaluation should get in-depth technical little practicable in a social as SO.

For the server side language they are all okay, I personally right now I'm using PHP and framework Yii2 with PDO driver for MySQL. The important thing is to use an environment makes it very easy and efficient access to the database.

Under these conditions, the use of a good organization of the cluster and the display of polygons to regions when the zoom level allows it makes applications google maps very performing

Please take note that the appearance of markers is faster than that of the polygons as it is less the number of coordinates involved and theirs graphic characteristics .

For a general question like your is difficult find a good answer online. For the regions depends of the dimension of the area you manage and the average density of the markers. For area not near the pole you can use a fraction of the coord.. or if your geo point have some attribute related to area you can use them. You can find formulas online for link the zoom with an approximate dimension of the area. Depend also how the collection of markers is done. In my case during the collection i eval some attribute for this needs.

For the check is a markers or a group of a markers are already in maps i use simply vector and use this (via ajax) for dinamic exchange with the server. Firts time the vector is empty and progressively the vectore contain element for "know" what are already displayed.

like image 154
ScaisEdge Avatar answered Sep 19 '22 16:09

ScaisEdge