ios - GMSCameraPosition 不准确

标签 ios swift swift3 maps gmsmapview

我使用 GMS 通过以下代码在我的 iOS 应用程序中显示 map 位置。相机的位置不是以标记位置为中心,而是稍微偏北(约 5 英里)。如何将相机位置居中以标记为中心?

 let marker = GMSMarker()
 marker.position = CLLocationCoordinate2D(latitude: latitude!, longitude:longitude!)

 let camera = GMSCameraPosition.camera(withTarget: marker.position, zoom: 10.0)
 let mapView = GMSMapView.map(withFrame: view.bounds, camera: camera)

 marker.map = mapView

 cell.mapView.addSubview(mapView)

The initial view of the map 以上是 map 的初始位置。 location of the marker 标记位于初始 View 的南边。

最佳答案

withFrame: view.bounds 中的 View 不是正确的 mapView。将其更改为 mapView 解决了问题。

关于ios - GMSCameraPosition 不准确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44689573/

相关文章:

ios - UIScrollView 第一次创建在错误的位置

iphone - UILocalNotification 每分钟重复一次

如果用户在页面加载完成之前点击单元格,带有 Firebase 的 iOS Swift 应用程序会崩溃并显示 'Index out of range'

swift 。确保在子类方法的末尾调用父类(super class)方法

ios - 无法使类型为 X 且标识符为 Y 的 View 出列(NSInternalInconsistencyException)

ios - 名称中的 React native 图像变量不起作用

ios - 动画应用程序的按钮

ios - swift 3 中的自定义复选框

swift - 为什么找不到 iCloud 帐户/CKContainer

swift3 - iOS 11 现在可以录屏了吗?