0
votes

I'm having trouble with the maximum zoom level on the MapView using IOS6. The user can zoom in too much and the tiles are blank.

A quick fix was to do this:

- (void)mapView:(MKMapView *)theMapView regionDidChangeAnimated:(BOOL)animated {
    if([theMapView zoomLevel] > 18) {
        [theMapView setCenterCoordinate:[theMapView centerCoordinate] zoomLevel:18 animated:TRUE];
    }
}

and zoom out again automatically, but sometimes it still zooms too far in and does not zoom out again.

I think I need to get the maximum zoom level of the current region that i'm in but there doesn't seem to be a easy way of doing that. How did you guys get past this issue?

2

2 Answers

0
votes

A fix would be to do something like this:

- (void)setRegionWithMaximumZoomLevel:(MKCoordinateRegion)region animated:(BOOL)animated
{
    if ([self zoomLevelForRegion:region] > 17)
    {
        [self setCenterCoordinate:region.center zoomLevel:17 animated:TRUE];
    }else
    {
        [self setRegion:region animated:animated];
    }
}

- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate
                  zoomLevel:(NSUInteger)zoomLevel
                   animated:(BOOL)animated
{
    // clamp large numbers to 28
    zoomLevel = MIN(zoomLevel, 17);

    // use the zoom level to compute the region
    MKCoordinateSpan span = [self coordinateSpanWithMapView:self centerCoordinate:centerCoordinate andZoomLevel:zoomLevel];
    MKCoordinateRegion region = MKCoordinateRegionMake(centerCoordinate, span);

    // set the region like normal
    [self setRegion:region animated:animated];
}

Maybe it's not perfect but it's good enough for what I needed.

0
votes

I did run in to the same problem as you, it's iOS6.0's bug, this is tough. Your program should not have the problem of tile blank in iOS 5.0, hope apple can fix it. The MKMapView+ZoomLevel in gitHub is a good tools in set mapView's zoom level, but you will also run in to some trouble for tiles blank problem. but, may be this can help you: https://github.com/DeepFriedTwinkie/iOS6MapZoomIssue