If you want to start by displaying one region and then zoom in, you will have to issue two or more calls to setRegion , because setRegion alone does not allow you to control the starting area or speed of the animation.
In viewDidLoad set the span start area to see all of the UK (try delta 10.0 instead of 0.15 ). You can also set animated to NO for the start area.
Then, until the end of viewDidLoad schedule the scale to complete in a few seconds:
- (void)viewDidLoad { ... [self performSelector:@selector(zoomInToMyLocation) withObject:nil afterDelay:5];
The zoomInToMyLocation method may look like this:
-(void)zoomInToMyLocation { MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; region.center.latitude = 51.502729 ; region.center.longitude = -0.071948; region.span.longitudeDelta = 0.15f; region.span.latitudeDelta = 0.15f; [mapView setRegion:region animated:YES]; }
One thing you might have to take care of when using performSelector is to cancel the waiting call if the view is closed or released before the call starts. For example, if the user closes the view two seconds after loading it. After three seconds, the planned method can still be called, but it will work since it has not disappeared. To avoid this, cancel the pending actions in viewWillDisappear: or, when necessary:
[NSObject cancelPreviousPerformRequestsWithTarget:self]
source share