Reputation: 2439
I am loading a mapview into a viewcontroller's view. When I load the mapview, it zooms directly to the location of the contact. I have button in the toolbar of my viewcontroller. When I click on this button the mapview should zoom from the already zoomed location to the current location of my iphone. This feature is similar to the one in iphone map app. How can I do this?
Upvotes: 0
Views: 172
Reputation: 12036
//did update user location
- (void)mapView:(MKMapView *)currentMapView didUpdateUserLocation:(MKUserLocation *)userLocation{
if(shouldChangeSpan) {
MKCoordinateSpan span;
span.latitudeDelta = 0.40;
span.longitudeDelta = 0.45;
MKCoordinateRegion region = MKCoordinateRegionMake(userLocation.coordinate, span);
[mapView setRegion:region animated:YES];
shouldChangeSpan = NO;
}
}
shouldChangeSpan in an bool declared in h. and set to no in view did load, and set to yes in your button action method.
Upvotes: 1