简体   繁体   English

Google Maps事件

[英]Google Maps fling event

Is there any way to disable fling gesture on google map (SupportMapFragment)? 有什么方法可以在Google地图(SupportMapFragment)上禁用甩动手势吗? Or I need at least an event to detect when map scrolling ends after fling and to compute map camera location. 或者,我至少需要一个事件来检测扫掠后何时结束地图滚动并计算地图摄像机的位置。

Thanks. 谢谢。

You can set an OnCameraIdleListener . 您可以设置OnCameraIdleListener From the documentation : 文档中

onCameraIdle() onCameraIdle()

Called when camera movement has ended, there are no pending animations and the user has stopped interacting with the map 相机移动结束时调用,没有待处理的动画,并且用户已停止与地图互动

Thake into account that OnCameraIdleListener is one of the events that replace the deprecated OnCameraChangeListener ( documentation ). 考虑到OnCameraIdleListener是替换不推荐使用的OnCameraChangeListener文档 )的事件之一。

You can get the new camera position like this: 您可以像这样获得新的相机位置:

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

You can know whether the user initiated the camera update event if you use the OnCameraMoveStartedListener . 如果您使用OnCameraMoveStartedListener则可以知道用户是否发起了相机更新事件。 The method onCameraMoveStarted(int reason) provides a reason that equals REASON_GESTURE if the update has been initiated by the user. 如果用户已启动更新,则onCameraMoveStarted(int reason)提供的原因等于REASON_GESTURE From the documentation 文档中

onCameraMoveStarted(int reason) onCameraMoveStarted(int原因)

Called when the camera starts moving after it has been idle or when the reason for camera motion has changed. 闲置后摄像机开始移动或摄像机运动的原因已更改时调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM