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: -33.8683,
longitude: 151.2086,
zoom: 6)
Is there any Mapkit method for this?
Code based on : http://troybrant.net/blog/2010/01/set-the-zoom-level-of-an-mkmapview/
Apinho answer in Swift 4.x
Swift 3.0
In the MapKit Function
didUpdateLocations
:Note: If you do not want to keep setting the center every time there is a location update, then do the following:
You'd create a MKCoordinateRegion object and set that as the region on your MKMapView object.
Here is a method I use to center your map on a pre-defined
CLLocation
usingMKCoordinateRegion
.Put the below code in your
CustomMapView
subclass ofMKMapView
Call is frominit