Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practices when clustering large amount of markers in Google Maps Android V2

Tags:

I would like to show a large number of markers (50k+) on a Google Map. As it turns out, the Android Maps Util Library https://github.com/googlemaps/android-maps-utils seems to be the number one choice when clustering markers.

I was wondering if there exist any best practices in order to increase the performance of the map user experience while showing such a vast amount of markers.

Example

As an example, I used the Cluster Manager to add approx 20.000 Markers to the Cluster Manager, resulting in a not very smooth map interaction experience when zooming and panning the map.

What I used:

GridBasedAlgorithm<MyClusterItem> gridAlgorithm = new GridBasedAlgorithm<MyClusterItem>();      mClusterManager.setAlgorithm(new PreCachingAlgorithmDecorator<MyClusterItem>(gridAlgorithm)); 

My strategies:

1) Remove all markers from the cluster on a camera change event, then add only those within the view bounds. Works great on high zoom level, when the zoom level lowers, there are many markers to remove and to add, adding overhead to the whole clustering process

2) Adding all Markers in the first place.

  • 100 Markers => Works great
  • 1000 Markers => Works, but already showing slowness in the process of clustering when zoom out occurs
  • 10000 Markers => Already very slow behavior, taking a long time to re-cluster the markers and the zooming in-out is not smooth
  • 20000 Markers => Re clustering takes a very long time (> 20s), the map is not responsive
like image 416
Devdroid Avatar asked Jun 05 '14 10:06

Devdroid


People also ask

Which is the preferred method for handling large number of markers is to store the data in?

As it turns out, the Android Maps Util Library https://github.com/googlemaps/android-maps-utils seems to be the number one choice when clustering markers.

How many markers can Google Maps handle?

2048 characters in URL is just under 100 GeoCode values. So, again no more than 100 markers.

How do I use marker clusters in Google Maps?

To navigate, press the arrow keys. The number on a cluster indicates how many markers it contains. Notice that as you zoom into any of the cluster locations, the number on the cluster decreases, and you begin to see the individual markers on the map. Zooming out of the map consolidates the markers into clusters again.


1 Answers

How I did that in the past: You should listen map movement and draw only markers which should be visible at the moment. Also you should manage zoom level and aggregate few markers to single one if they are placed on the same screen place.

like image 185
Dmytro Batyuk Avatar answered Sep 21 '22 12:09

Dmytro Batyuk