pvllnspk
pvllnspk

Reputation: 5767

GoogleMap.OnCameraChangeListener onCameraChange works with delays

I need to listen CameraPosition changes to draw a custom compass. The problem that: GoogleMap.OnCameraChangeListener onCameraChange

Is there are any way to listen to CameraPosition bearing changes? (In ios f.e. it's possible to achieve using Key-Value Observing), reflection...? Thanks.

Upvotes: 1

Views: 2546

Answers (2)

pvllnspk
pvllnspk

Reputation: 5767

Put FrameLayout above map and catch touches:

@Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (mCatchTouchFrameLayoutListener != null)
            mCatchTouchFrameLayoutListener.onTouch(ev);
        return false;
    }

Upvotes: 2

Verma
Verma

Reputation: 8439

To move the camera instantly with the given CameraUpdate, you can call GoogleMap.moveCamera(CameraUpdate).

You can make the user experience more pleasing, especially for short moves, by animating the change. To do this instead of calling GoogleMap.moveCamera() call GoogleMap.animateCamera(). The map will move smoothly to the new attributes. The most detailed form of this method, GoogleMap.animateCamera(cameraUpdate, duration, callback), offers three arguments:

CameraUpdate: The CameraUpdate describing where to move the camera.

Callback: An object that implements GoogleMap.CancellableCallback. This generalized interface for handling tasks defines two methods onCancel() and onFinished(). For animation, the methods are called in the following circumstances: onFinish() Invoked if the animation goes to completion without interruption. onCancel() Invoked if the animation is interrupted by calling stopAnimation() or starting a new camera movement. Alternatively, this can also occur if you call GoogleMap.stopAnimation().

Duration: Desired duration of the animation, in milliseconds, as an int.

Upvotes: 0

Related Questions