marceloquinta
marceloquinta

Reputation: 703

How to listen to Android GoogleMap pan and zoom

I am using Android GoogleMap class (Google Play Services 8.1.0) and want to track map position change, that can be made by pan or zoom inside screen.

With the event, I need to update the places, according to map center.

In the previous APIs it was possible, but now I didnt find a way to do it.

Upvotes: 1

Views: 1417

Answers (2)

philtz
philtz

Reputation: 226

Use one of the methods that listens to the camera move (e.g. setOnCameraMoveStartedListener, setOnCameraMoveCancelledListener etc) and check the reason:

googleMap.setOnCameraMoveStartedListener(new GoogleMap.OnCameraMoveStartedListener() {
        @Override
        public void onCameraMoveStarted(int reason) {
            if (reason == GoogleMap.OnCameraMoveStartedListener.REASON_GESTURE) {
                //map is touched..do something
            }
        }
    });

Upvotes: 5

Stimsoni
Stimsoni

Reputation: 3156

Take a look a setOnCameraChangeListener

setOnCameraChangeListener

Upvotes: 1

Related Questions