I am using MKMapView on a project and would like to center the map on a coordinate and zoom in. Just like Google maps has:
GMSCameraPosition.camera(withLatitude:
This works in swift 5, ios 13 and is easy to understand:
Just add the following method to your class:
func zoomAndCenter(on centerCoordinate: CLLocationCoordinate2D, zoom: Double) {
var span: MKCoordinateSpan = mapView.region.span
span.latitudeDelta *= zoom
span.longitudeDelta *= zoom
let region: MKCoordinateRegion = MKCoordinateRegion(center: centerCoordinate, span: span)
mapView.setRegion(region, animated: true)
}