Skip to content Skip to sidebar Skip to footer

Can I Use 2 Cameraupdates With One Animatecamera?

I am trying to zoom on a map CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(mBounds, this.getResources().getDisplayMetrics().widthPixels, h

Solution 1:

If you call animateCamera multiple times, only the last one will finish its action.

The easy fix would be to use moveCamera instead of the first call to animateCamera, but that's not a nice solution from UX perspective.

The other way would be to do the math yourself and fill mBounds with the bounds you really want to show.

Solution 2:

The easiest way to do it is to use CancelableCallback. You should check the first action is complete and then call the second:

mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, size.x, height, 0), newCancelableCallback() {

                @OverridepublicvoidonFinish() {
                    CameraUpdate cu_scroll = CameraUpdateFactory.scrollBy(0, 500);
                    mMap.animateCamera(cu_scroll);
                }

                @OverridepublicvoidonCancel() {
                }
            });

Post a Comment for "Can I Use 2 Cameraupdates With One Animatecamera?"