Eric
Eric

Reputation: 4061

Get Current MapView Region after Update

How do I get the current mapView span after the user has moved or updated the map?

What do I put in this delegate method:

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

}

How do I get the current mapView.region.span after the map has been updated? I need to pass that to another method and have it redraw the whole map with certain things (not mapAnnotations) on the map.

This:

    -(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
    {
         [customMethod updateWith:mapView.region.span];
    }

doesn't work.

Upvotes: 0

Views: 1716

Answers (1)

Apurv
Apurv

Reputation: 17186

Span changes only when you change your zoom level. If you are not pinching the map (zoom gesture), and only panning (moving the map),your center will get changed not the span.

So you should pass complete region to custom method.

-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
    [customMethod updateWith:mapView.region];
}

Upvotes: 2

Related Questions