Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Android Clustering OnCameraChangeListener() deprecated

Using the tutorial here, I successfully implemented clustering in my Android app. Since OnCameraChangeListener() is now deprecated in com.google.android.gms:play-services:9.4.0 is there a new way to implement the part below?

private ClusterManager<MyItem> mClusterManager;
googleMap.setOnCameraChangeListener(mClusterManager);

EDIT:

I tried directly replacing setOnCameraChangeListener by setOnCameraMoveListener like

googleMap.setOnCameraMoveListener(mClusterManager);

This does not work since setOnCameraMoveListener() is expecting an object of class OnCameraMoveListener. Casting mClusterManager does not work either.

googleMap.setOnCameraMoveListener((GoogleMap.OnCameraMoveListener) mClusterManager);
like image 229
Rio Marie A. Callos Avatar asked Aug 23 '16 07:08

Rio Marie A. Callos


Video Answer


1 Answers

You need to use

gooleMap.setOnCameraIdleListener(mClusterManager);

instead of

googleMap.setOnCameraMoveListener(mClusterManager);

You can to search for the source code of ClusterManager and you will see that ClusterManager implements the new OnCameraIdleListener.

Also you need to update to new android-maps-utils:0.4.4

(compile 'com.google.maps.android:android-maps-utils:0.4.4')

Good luck and vote up... ;-)

like image 137
Max Waitzman Avatar answered Sep 18 '22 01:09

Max Waitzman