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.
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));
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
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.