Search code examples
iosmkmapview

determine if MKMapView was dragged/moved


Is there a way to determine if a MKMapView was dragged around?

I want to get the center location every time a user drags the map using CLLocationCoordinate2D centre = [locationMap centerCoordinate]; but I'd need a delegate method or something that fires as soon as the user navigates around with the map.


Solution

  • Look at the MKMapViewDelegate reference.

    Specifically, these methods may be useful:

    - (void)mapView:(MKMapView *)mapView regionWillChangeAnimated:(BOOL)animated
    - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
    

    Make sure your map view's delegate property is set so those methods get called.