While trying to implement use ClusterManager, I noticed that the getMap().setOnCameraChangeListener(clusterManager) is deprecated. Looking at the android-maps-utils sample on Github, I noticed that getMap().setOnCameraIdleListener(mClusterManager);
When I try doing the same, I get an error because the default ClusterManager class doesn't implement GoogleMap.OnCameraIdleListener.
Yet, in my gradle file, I am using what seems to me, the latest maps-util libraries:
dependencies {
    compile 'com.google.maps.android:android-maps-utils:0.4.3'
}
How can I get access to the newest ClusterManager class?
Thanks
instead of:
mMap.setOnCameraChangeListener(mClusterManager);
do that:
final CameraPosition[] mPreviousCameraPosition = {null};
    googleMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() {
        @Override
        public void onCameraIdle() {
            CameraPosition position = googleMap.getCameraPosition();
            if(mPreviousCameraPosition[0] == null || mPreviousCameraPosition[0].zoom != position.zoom) {
                mPreviousCameraPosition[0] = googleMap.getCameraPosition();
                clusterManager.cluster();
            }
        }
    });
that will work...
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