ClusterManager repaint markers of Google maps v2 utils

PaNaVTEC picture PaNaVTEC · Mar 9, 2014 · Viewed 16.1k times · Source

I'm making a server request and when I receive the response from server, I'm executing on UI Thread a ClusterManager.addItem() but this items are not painting in the map, only when I make a zoom update (+,-) newly added items starts appearing. I also tried to debug the renderer, but onBeforeClusterRendered / onBeforeClusterItemRendered are not getting called until I update the zoom in map.

Any ideas how to refresh map/clusterManager/markers?

MarkerManager markerManager = new MarkerManager(map);
clusterManager = new ClusterManager<TweetClusterItem>(getActivity(), map, markerManager);
clusterManager.setRenderer(new TweetClusterRenderer(getActivity(), map, clusterManager, defaultMarker));
clusterManager.setOnClusterClickListener(this);
clusterManager.setOnClusterInfoWindowClickListener(this);
clusterManager.setOnClusterItemClickListener(this);
clusterManager.setOnClusterItemInfoWindowClickListener(this);

UiSettings uiSettings = map.getUiSettings();
uiSettings.setZoomControlsEnabled(true);
uiSettings.setMyLocationButtonEnabled(false);

map.setOnCameraChangeListener(clusterManager);
map.setOnMarkerClickListener(clusterManager);
map.setOnInfoWindowClickListener(clusterManager);
map.setOnMapClickListener(this);

Answer

Oscar Kuok picture Oscar Kuok · Mar 14, 2014

mClusterManager.cluster();

force re-clustering items when you after added new item.