How can I create two listeners? One is used for the clustering and the other will load new cluster items to the map if no cluster items exists on the map.
//needed for clustering
map.setOnCameraChangeListener(mClusterManager);
// need for loading clusteritems
map.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition position) {
// ifMarkesNotInsideMapReload...
I think it's not possible but someone maybe solved this...
One idea is to set a starting position and poll for changes manually.. not cool :-)
I'm using googles cluster library: google cluster
I have looked into ClusterManager
implementation of AMUtils library and it looks like it calls onCameraChange
on your implementation of ClusterRenderer
if it also implements OnCameraChangeListener
. Simply make it implement that interface.
Relevant parts of the code:
@Override
public void onCameraChange(CameraPosition cameraPosition) {
if (mRenderer instanceof GoogleMap.OnCameraChangeListener) {
((GoogleMap.OnCameraChangeListener) mRenderer).onCameraChange(cameraPosition);
}
If you are using DefaultClusterRendeder
, create a class like:
public class MyClusterRenderer extends DefaultClusterRenderer implements OnCameraChangeListener {