Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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);
like image 981
Edward Collins Avatar asked May 01 '15 08:05

Edward Collins


People also ask

How do I use marker clustering on the map?

When you click on a cluster marker, the map will zoom in and the number on the cluster marker will decrease. You will start seeing individual markers on the map. If you keep zooming in, the cluster will disappear and all the markers will be displayed on the map. Check out this map example with marker clustering enabled.

What happens when you zoom in and out of a cluster?

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.

Can You cluster markers on Google Maps in flutter?

If you’re using Google Maps to display markers on your Flutter app, I’m sure that you will eventually need to cluster those markers. You don’t want users to zoom out and see hundreds of markers spamming the map right? Well, as I’m sure you know by now, that feature isn’t supported yet by the official Google Maps package.

How do I change the color of the cluster marker?

The color used for the cluster marker is the same as the category marker color. If you are using image markers, the color is either automatically generated from the image marker or can be manually set in the marker editor.


1 Answers

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

Hope this helps

like image 173
k3v1n4ud3 Avatar answered Sep 21 '22 15:09

k3v1n4ud3