I have an issue. My current location is displayed and centered in a map view however the map region doesn't get zoomed in to. I tried taking Rob's advice by taking span and region out of the didUpdateToLocation method but I must not have implemented it right. I don't think it's recognizing my call to setRegion in viewDidLoad and my buttons aren't being recognized. Please check my code below and point out the mistake(s). My goal is to be able to zoom in and out of my location using the IBAction buttons.
.h
- (IBAction)zoomIn:(id)sender;
- (IBAction)zoomOut:(id)sender;
.m in viewDidLoad
double miles = 0.5;
MKCoordinateSpan span;
span.latitudeDelta = miles/69.0;
span.longitudeDelta = miles/69.0;
MKCoordinateRegion region;
region.span = span;
[self.mapView setRegion:region animated:YES];
[self.mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
_mapView.mapType = MKMapTypeSatellite;
.m in my didUpdateToLocation method.
[self.mapView setCenterCoordinate:newLocation.coordinate animated:YES];
.Zoom In:
- (IBAction)zoomIn:(id)sender
{
MKCoordinateSpan span;
span.latitudeDelta = _mapView.region.span.latitudeDelta * 2;
span.longitudeDelta = _mapView.region.span.latitudeDelta * 2;
MKCoordinateRegion region;
region.span = span;
region.center = _mapView.region.center;
[self.mapView setRegion:region animated:YES];
}
.Zoom Out :
- (IBAction)zoomOut:(id)sender
{
MKCoordinateSpan span;
span.latitudeDelta = _mapView.region.span.latitudeDelta / 2;
span.longitudeDelta = _mapView.region.span.latitudeDelta / 2;
MKCoordinateRegion region;
region.span = span;
region.center = _mapView.region.center;
[self.mapView setRegion:region animated:YES];
}