我正在使用GMS使用以下代码在我的iOS应用中显示地图位置。摄像机的位置不是以标记位置为中心,而是略微向北(大约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)
答案 0 :(得分:-1)
withFrame: view.bounds
中的观点不正确mapView
。将其更改为mapView
可解决问题。