I state I’m a beginner so please don’t miss any step!
I used that code to show and “jump” to the user location:
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views {
for(MKAnnotationView *annotationView in views) {
if(annotationView.annotation == mv.userLocation) {
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.002;
span.longitudeDelta=0.002;
CLLocationCoordinate2D location=mv.userLocation.coordinate;
region.span=span;
region.center=location;
[mv setRegion:region animated:TRUE];
[mv regionThatFits:region];
}
}
But I’d like to request it just when I press a button.. How can I do it? (Remember: I’m a beginner!). Thanks in advance!
All you need to do is not call your setRegion above, but just call it when you press the button. Alternatively you can turn updating your map on and off with [locationManager startUpdatingLocation][locationManager stopUpdatingLocation], but leaving this on burns up battery, so be judicious.