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

修正は、次のようなことを行うことです。

- (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 に答える