0

我在使用 IOS6 的 MapView 上的最大缩放级别遇到问题。用户可以放大太多并且图块是空白的。

一个快速的解决方法是这样做:

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

并自动再次缩小,但有时它仍然放大得太远并且不会再次缩小。

我想我需要获得我所在的当前区域的最大缩放级别,但似乎没有一种简单的方法可以做到这一点。你们是如何解决这个问题的?

4

2 回答 2

0

我确实遇到了和你一样的问题,是iOS6.0的bug,这很难。你的程序在iOS 5.0中应该不会出现磁贴空白的问题,希望苹果能解决。gitHub 中的 MKMapView+ZoomLevel 是设置 mapView 缩放级别的好工具,但也会遇到一些瓷砖空白问题。但是,这可能对您有帮助: https ://github.com/DeepFriedTwinkie/iOS6MapZoomIssue

于 2013-09-12T14:02:03.903 回答
0

一个解决办法是做这样的事情:

- (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];
}

也许它并不完美,但它足以满足我的需要。

于 2013-07-29T09:22:06.367 回答