I am trying to use two ClusterManager for Google Map , But I am able to add only one clustermanager and it's item click event,
googleMap.setOnMarkerClickListener(mClusterManager);
and
mClusterManager.setOnClusterItemClickListener(new OnClusterItemClickListener<Person>() {
@Override
public boolean onClusterItemClick(Person item) {
Log.v("Cluster Click", "Item Click:"+item.getName());
return true;
}
});
How can I add one more clustermanager to googlemap?
Thanks in advance.
Answers. you can add 200 markers at a time but if you are using google service it will not response more than 10 or 20 at a time and if you have array of collection Lattitude and longitude just try to modify above code.
you can use MarkerManager like this:
MarkerManager markerManager = new MarkerManager(mMap);
mClusterManager1 = new ClusterManager<>(getContext(), mMap,markerManager);
mClusterManager2 = new ClusterManager<>(getContext(), mMap,markerManager);
mMap.setOnMarkerClickListener(markerManager);
mMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
mClusterManager1.onCameraChange(cameraPosition);
mClusterManager2.onCameraChange(cameraPosition);
}
});
mClusterManager1.setRenderer(myClusterRenderer1 = new MyClusterRenderer(getContext(), mMap, mClusterManager1));
mClusterManager2.setRenderer(myClusterRenderer2 = new MyClusterRenderer(getContext(), mMap, mClusterManager2));
yes, delegate the click listener through to both cluster managers.
map.setOnClickListener(new GoogleMap.OnMarkerClickListener() {
boolean onMarkerClick(Marker m) {
clusterManager1.onMarkerClick(m)
clusterManager2.onMarkerClick(m)
}
});
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