我使用 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)
最佳答案
withFrame: view.bounds
中的 View 不是正确的 mapView
。将其更改为 mapView
解决了问题。
关于ios - GMSCameraPosition 不准确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44689573/