3

I am using GMS to show map locations in my iOS app using the following code. The position of the camera is not centered at marker position but it is slightly north(around 5 miles) of it. How can I center camera position to center on marker?

 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 Above is the initial location of the map. location of the marker The marker is south of the initial view.

2ank3th
  • 2,948
  • 2
  • 21
  • 35

1 Answers1

-1

The view in withFrame: view.bounds is not the correct mapView. Changing that to mapView fixed the problem.

Lal Krishna
  • 15,485
  • 6
  • 64
  • 84
2ank3th
  • 2,948
  • 2
  • 21
  • 35