GoogleMap.OnCameraChangeListener onCameraChange 处理延迟
GoogleMap.OnCameraChangeListener onCameraChange works with delays
我需要监听 CameraPosition 变化来绘制自定义罗盘。问题在于:GoogleMap.OnCameraChangeListener onCameraChange
- 此听众可能不会收到中间摄像机位置的通知。
- 它随机延迟触发(不明白为什么)
有什么方法可以监听CameraPosition方位变化吗? (在 ios f.e 中,可以使用 Key-Value Observing 来实现),反射...?
谢谢
要使用给定的 CameraUpdate 立即移动相机,您可以调用 GoogleMap.moveCamera(CameraUpdate)
。
您可以通过动画更改来使用户体验更加愉悦,尤其是对于短距离移动。要执行此操作而不是调用 GoogleMap.moveCamera()
,请调用 GoogleMap.animateCamera()
。地图将顺利移动到新属性。此方法的最详细形式 GoogleMap.animateCamera(cameraUpdate, duration, callback)
提供三个参数:
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
.
将 FrameLayout 放在地图上方并捕捉触摸点:
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (mCatchTouchFrameLayoutListener != null)
mCatchTouchFrameLayoutListener.onTouch(ev);
return false;
}
我需要监听 CameraPosition 变化来绘制自定义罗盘。问题在于:GoogleMap.OnCameraChangeListener onCameraChange
- 此听众可能不会收到中间摄像机位置的通知。
- 它随机延迟触发(不明白为什么)
有什么方法可以监听CameraPosition方位变化吗? (在 ios f.e 中,可以使用 Key-Value Observing 来实现),反射...? 谢谢
要使用给定的 CameraUpdate 立即移动相机,您可以调用 GoogleMap.moveCamera(CameraUpdate)
。
您可以通过动画更改来使用户体验更加愉悦,尤其是对于短距离移动。要执行此操作而不是调用 GoogleMap.moveCamera()
,请调用 GoogleMap.animateCamera()
。地图将顺利移动到新属性。此方法的最详细形式 GoogleMap.animateCamera(cameraUpdate, duration, callback)
提供三个参数:
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()
andonFinished()
. 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
.
将 FrameLayout 放在地图上方并捕捉触摸点:
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (mCatchTouchFrameLayoutListener != null)
mCatchTouchFrameLayoutListener.onTouch(ev);
return false;
}