I have used cluster concept in my application, i can successfully get the cluster but the problem is not getting updated when the array of markers getting refreshed, right now based on the miles i am refreshing my map
Check it out my below code :
if (map != null) {
map.moveCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(Double.parseDouble(list.get(0).getLatitude()),
Double.parseDouble(list.get(0).getLangtitude())),
map.getCameraPosition().zoom));
mClusterManager = new ClusterManager<MyItem>(getActivity(), map);
map.setOnCameraChangeListener(mClusterManager);
map.setOnMarkerClickListener(mClusterManager);
}
mClusterManager.clearItems();
for (int i = 0; i < list.size(); i++) {
String title = list.get(i).getName() + "~" + list.get(i).getCity()
+ "~" + list.get(i).getSector();
MyItem offsetItem = new MyItem(Double.parseDouble(list.get(i)
.getLatitude()), Double.parseDouble(list.get(i)
.getLangtitude()), title, list.get(i).getSector(),
String.valueOf(i));
mClusterManager.addItem(offsetItem);
}
mClusterManager.cluster();
Instead of updating markers are added for each refreshment, mClusterManager.clearItems(); its not working, dont know what mistake i have done, please figure out
Thanks in Advance
If you want to clear all markers, use clearItems().
If you want to remove individual marker,obtain its reference ans use remove() method.
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