Google 地图投掷事件

Google Maps fling event

有没有什么方法可以在 google 地图 (SupportMapFragment) 上禁用滑动手势?或者我至少需要一个事件来检测地图滚动何时结束并计算地图相机位置。

谢谢。

您可以设置一个OnCameraIdleListener。来自 the documentation:

onCameraIdle()

Called when camera movement has ended, there are no pending animations and the user has stopped interacting with the map

考虑到 OnCameraIdleListener 是取代已弃用的 OnCameraChangeListener (documentation) 的事件之一。

你可以这样获取新的相机位置:

@Override
public void onCameraIdle() {
    CameraPosition cameraPosition = mMap.getCameraPosition();
}

使用OnCameraMoveStartedListener可以知道用户是否发起了相机更新事件。如果更新已由用户启动,方法 onCameraMoveStarted(int reason) 提供等于 REASON_GESTURE 的原因。来自 the documentation

onCameraMoveStarted(int reason)

Called when the camera starts moving after it has been idle or when the reason for camera motion has changed.