Search code examples
androidgoogle-mapsmarkerclustererandroid-maps-utils

Adding new markers on map using cluster manager doesn't reflect the changes until I zoom in and zoom out the map


When I add new markers on the map programmatically using cluster manager it doesn't reflect the changes until I update the zoom in and zoom out.

I have seen lots of questions on stack overflow but that doesn't work for me,

So please tell me how to update the map without clearing the map.

Code:

 for (int i = 0; i < name.length; i++)
 { 
   Person_marker person_marker = new Person_marker(createRandLocation(latLng),
   name[i], getAddress(latLng), typedArray.getResourceId(i, -1), time[i], acuracy[i]);
   person_markerList.add(person_marker);
 } 
clusterManager.clearItems(); clusterManager.addItems(person_markerList);

Solution

  • After adding all the markers, if you call clusterManager.cluster() it will draw what's been previsouly added.

    Hope this helps