I use the following code to display a map center on the user’s location:
...
// start off by default current position
AppManager *appManager = [AppManager sharedManager];
MKCoordinateRegion newRegion;
newRegion.center.latitude = [appManager.currentlatitude floatValue];
newRegion.center.longitude = [appManager.currentlongitude floatValue];
newRegion.span.latitudeDelta = 0.06;
newRegion.span.longitudeDelta = 0.06;
[self.mapView setRegion:newRegion animated:YES];
[self.view insertSubview:mapView atIndex:0];
...
The thing is, I do not manage to decrease the zoom level enough when playing with “newRegion.span.latitudeDelta” and “newRegion.span.longitudeDelta” values. The zoom only show a zone of something like 30 kms wide when I’d like to have several hundreds.
For what I saw, a value of 0.06 for longitudeDelta should show 180 degre (half of the earth) (for a latitude 0), then for a latitude of 43, I think I should see more than 30 km.
Any idea ?
The
latitudeDeltaandlongitudeDeltaare in degrees so a value of 0.06 is a relatively small distance in km. To show “half of the Earth”, you’d have to set thelongitudeDeltato 180.0.If you know the distance (eg. in km) you want to show, it will be easier to use the
MKCoordinateRegionMakeWithDistancefunction instead of trying to do the conversion yourself:The last two parameters are
latitudinalMetersandlongitudinalMetersso the above example sets the span to 200 km x 200 km.Remember the map view will then adjust the region as needed based on the map view’s proportions and displayable zoom level.