【问题标题】:Determine proper zoom level on GMSMapView to fit all the locations needed?在 GMSMapView 上确定适当的缩放级别以适合所有需要的位置?
【发布时间】:2021-09-30 20:42:12
【问题描述】:

在我的 iOS 应用中,我使用的是 GoogleMaps 和地图 API,但我不是很熟悉。

我知道,使用 iOS 原生 MKMapView,您可以设置可见的地图矩形,以适应适当缩放级别所需的所有点,如下所述:Zooming MKMapView to fit annotation pins?

但我不确定如何为 GMSMapView 做这样的事情。有人知道怎么做吗?

非常感谢任何形式的帮助!

【问题讨论】:

    标签: ios swift google-maps gmsmapview


    【解决方案1】:

    在地图上设置标记后添加:

      var bounds = GMSCoordinateBounds()
            for coordinate in testCoordinates
            {
                bounds = bounds.includingCoordinate(coordinate)
            }
            let update = GMSCameraUpdate.fit(bounds, withPadding: 50)
            mapView.animate(with: update)
    

    【讨论】:

    • 就像一个魅力。谢谢。
    猜你喜欢
    • 2023-04-05
    • 2016-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-05
    • 2016-11-04
    • 1970-01-01
    • 2014-07-02
    相关资源
    最近更新 更多