【问题标题】:How to get marker data of current camera position in Google Maps iOS SDK?如何在 Google Maps iOS SDK 中获取当前相机位置的标记数据?
【发布时间】:2019-05-15 21:59:20
【问题描述】:

我正在构建一个 tableview/scrollview 到包含 GMSMapView.map 的窗口的下部,它旨在显示当前相机位置的标记数据。

GMSMapView.map 已经设置了标记。

我错过了获取当前相机位置的标记数据的方法,通过谷歌的文档进行了检查,但在那里找不到,非常感谢任何帮助。

【问题讨论】:

    标签: ios swift google-maps google-maps-markers gmsmapview


    【解决方案1】:

    一些挖掘,这里是简化的答案,使用 SDK 的 mapView didChange 位置函数,单个已经定义的标记和打印确认:

    func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
    let camView = mapView.projection.visibleRegion()
    let cameraBox = GMSCoordinateBounds(region: camView)
    if cameraBox.contains(marker.position) {
        print("YES")
    }
    else {print("NO")
    }
    

    【讨论】:

      猜你喜欢
      • 2014-01-24
      • 2013-06-08
      • 2016-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多