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);
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.
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.
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.
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.
After adding all the markers, if you call clusterManager.cluster()
it will draw what's been previsouly added.
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With