Reputation: 1205
Simple question:
Is it possible to do a max zoom-level? e.g.
region.span.latitudeDelta = 0.02;
region.span.longitudeDelta = 0.02;
I don't want to do it static. Think about the max possible zoom-level.
Where should I define it?
Upvotes: 0
Views: 107
Reputation: 5499
Yes, it is, just implement the delegate method mapView:regionDidChangeAnimated:
, I did it like this:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
if (mapView.region.span.longitudeDelta < YOUR_VALUE) {
MKCoordinateRegion initialRegion;
initialRegion.center = mapView.region.center;
initialRegion.span.latitudeDelta = YOUR_VALUE;
initialRegion.span.longitudeDelta = YOUR_VALUE;
MKCoordinateRegion adjustedRegion = [mapView regionThatFits:initialRegion];
[mapView setRegion:adjustedRegion animated:animated];
[mapView regionThatFits:adjustedRegion];
}
}
Upvotes: 1