Albert221
Albert221

Reputation: 7082

How to cancel any movement of Google Map?

I have somewhere in my application called map.animateCamera(...).

I want to cancel ANY movement of the map. I am looking for something like map.cancelCameraMove() or something similar, but unfortunately, it does not exist.

Any help?

Upvotes: 3

Views: 1075

Answers (1)

Andrii Omelchenko
Andrii Omelchenko

Reputation: 13343

Seems map.stopAnimation() is what you need:

...
map.animateCamera(location, duration, null);
...

// when need to stop animation
map.stopAnimation();

Or you can use workaround: get current camera position via map.getCameraPosition() and move it instantaneous exactly to them with map.moveCamera(). Something like that:

...
map.animateCamera(location, duration, null);
...

// when need to stop animation
CameraPosition cameraPosition = map.getCameraPosition();
map.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

Upvotes: 2

Related Questions