Positioning camera that shows two places in GMSMapview iOS

In Swift

 let bounds = GMSCoordinateBounds(coordinate: sourcePosition, coordinate: endPosition)
 let camera: GMSCameraUpdate = GMSCameraUpdate.fit(bounds)
 //  let cameraWithPadding: GMSCameraUpdate = GMSCameraUpdate.fit(bounds, withPadding: 100.0) (will put inset the bounding box from the view's edge)

 self.mapView.animate(with: camera)

Add padding with bounds, it works for me, hope it helps you,

GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:start coordinate:end];

[self.viewMapView animateWithCameraUpdate:[GMSCameraUpdate fitBounds:bounds withPadding:100.0f]];

Tags:

Ios

Gmsmapview