Hello,
I have the following code in place:
-(void)viewDidLoad
{
//Set Zoom level using Span
MKCoordinateSpan span;
span.latitudeDelta = 0.05;
span.longitudeDelta = 0.05;
region.span = span;
}
-(void)locationChange:(CLLocation *)newLocation: (CLLocation *)oldLocation
{
// This zooms in on the users current loation.
curlocation = newLocation.coordinate;
region.center = curlocation;
[_mapView setRegion:region animated:TRUE];
}
Initially the zoom level is set as per the code in ViewDidLoad. How do I store the zoom level id the user zooms in or out, as everytime a new location update is received the zoom level is reset.
Is there a way of detecting the user has zoomed in or out ?
UPDATE
I've add the regionDidChangeAnimated method as follows:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
NSLog(@"Region DID change. Center is now %f,%f, Deltas=%f,%f",
region.center.latitude, region.center.longitude,
region.span.latitudeDelta, region.span.longitudeDelta);
}
Output in the log looks like:
2010-11-01 15:17:29.317 Legginit[2948:307] Region DID change.
Center is now 54.181150,-8.483177, Deltas=0.050000,0.050000
2010-11-01 15:17:30.553 Legginit[2948:307] Region DID change.
Center is now 54.181150,-8.483177, Deltas=0.050000,0.050000
2010-11-01 15:17:31.063 Legginit[2948:307] Region DID change.
Center is now 54.181150,-8.483177, Deltas=0.050000,0.050000
2010-11-01 15:17:31.653 Legginit[2948:307] Region DID change.
Center is now 54.181150,-8.483177, Deltas=0.050000,0.050000
2010-11-01 15:17:32.582 Legginit[2948:307] Region DID change.
Center is now 54.181150,-8.483177, Deltas=0.050000,0.050000
2010-11-01 15:17:33.608 Legginit[2948:307] Region DID change.
Center is now 54.181150,-8.483177, Deltas=0.050000,0.050000
As I zoom in on the phone I was expecting the Delta Values to change but they remain at 0.05. Am I misunderstanding how this works. I thought I could capture the Delta values and store them so I could reset the zoom level if the user exits and re-enters the map.
Regards, Stephen