GMSCameraPosition不准确

时间:2017-06-22 03:19:20

标签: ios swift swift3 maps gmsmapview

我正在使用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)

The initial view of the map 上面是地图的初始位置。 location of the marker 标记位于初始视图的南侧。

1 个答案:

答案 0 :(得分:-1)

withFrame: view.bounds中的观点不正确mapView。将其更改为mapView可解决问题。