Get location from the center of the Swift MapKit screen

I am new to Swift Programming and I am trying to create an application to get the coordinates of the center of the view using MapKit and Swift 2.

I can already get the current location, but I need, if I go to the map, a place set to a new point, which will be the center of the screen.

Can you help me please?

Hello,

+6
source share
1 answer

You can use the regionDidChangeAnimated delegate method and call mapView.centerCoordinate. It will look like this:

func mapView(mapView: MKMapView, regionDidChangeAnimated animated: Bool) { var center = mapView.centerCoordinate } 

Also, make sure your class extends MKMapViewDelegate and you call self.mapView.delegate = self in your viewDidLoad() function.

+8
source

All Articles