【问题标题】:Kotlin : On camera move endKotlin:在相机移动结束时
【发布时间】:2019-01-22 11:32:23
【问题描述】:

我想知道如何检测相机何时完成移动,或者在相机移动后检测用户何时将手指从屏幕上移开。

现在我有这个小听众:

 mMap.setOnCameraMoveListener {
   val coords = mMap.cameraPosition.target
   getData(coords)   
}

但每次相机移动时都会触发(基本上,这是它的正常行为)。

但我正在使用 getData(coords) 进行 api 调用,因此每次相机移动时都会触发 api(因此它会在几秒钟内进行大量调用)...

【问题讨论】:

标签: android google-maps events kotlin


【解决方案1】:

使用onCameraIdle()GoogleMap.OnCameraIdleListener 代替OnCameraMoveListener

mMap.setOnCameraIdleListener {
   val coords = mMap.cameraPosition.target
   getData(coords)   
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-26
    • 2017-03-28
    • 1970-01-01
    相关资源
    最近更新 更多