MKMapView setRegion到小区域会导致卫星图像加载失败 [英] MKMapView setRegion to Small Area causes Failed Satellite Image Loading

查看:114
本文介绍了MKMapView setRegion到小区域会导致卫星图像加载失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在同一个应用程序上工作了好几个月,这是一个新问题。我想知道Apple Map数据的服务器端是否有变化。这是问题所在:

I have been working on the same app for a number of months, and this is a new problem. I am wondering if there has been a change in the server side of the Apple Map data. Here's the issue:

我的应用程序(有时)想要将MKMapView区域设置为特定位置周围可能达到的最大放大值。为此,我做了类似的事情:

My app (at times) wants to set an MKMapView region to the most fully zoomed in value possible around a particular location. To do this, I do something like:

self.map.mapType = MKMapTypeHybrid;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake(item.lat, item.lng), 1.0, 1.0);
[self.map setRegion:region animated:NO];

无论项目的坐标在哪里,我都是获得网格化的无卫星图像背景。这似乎与可用的卫星图像无关,因为它在美国的许多地区表现一致。

Regardless of where item's coordinate is, I get the gridded "no satellite images" background. This does not seem to be related to available satellite imagery, as it behaves consistently across many areas of the US.

我知道 setRegion:动画:可以在事后调整区域。而且我知道1平方米是一个不合理的小区域,试图在一张相当大的地图上展示。所以,我试过了

I am aware that setRegion:animated: may adjust the region after the fact. And I am aware the a 1m square is an unreasonably small area to attempt to show on a fairly large map. So, I've tried

[self.map setRegion:[self.map regionsThatFits:region] animated:NO];

设置动画:是似乎确实阻止了发生这种情况,但我不想对这些变化进行动画处理。

Setting animated:YES does seem to prevent this from occurring, but I do not want to animate these changes.

还有一些观察结果:


  • 如果我只缩小1或2像素,则会出现地图图像。

  • 尝试实现地图委托方法: - mapViewDidFailLoadingMap:withError :没有帮助。它从未被称为。

  • 这似乎是新的。我在应用程序商店中使用该应用程序的工作版本现在表现出类似的问题。

  • 我最近在其他热门应用程序中看到过这种情况。

  • If I zoom out just 1 or 2 pixels, the map imagery appears.
  • Attempting to implement the map delegate method: – mapViewDidFailLoadingMap:withError: does not help. It never is called.
  • This seems to be new. The working version I have of the app in the app store, now exhibits similar issues.
  • I have seen this happen in other popular apps recently.

对此解决方案的任何想法,或确认这是系统性问题?

Any thoughts on a solution to this, or confirmation that it is a systemic problem?

推荐答案

我最终继承了 MKMapView 并覆盖 setRegion:。我已经在Github中创建了一个示例应用程序,如果有人有兴趣看到该问题或我的解决方案:

I ended up subclassing MKMapView and overriding setRegion:. I've created a sample app in Github if anyone is interested in seeing the issue in action, or my solution:

https://github.com/DeepFriedTwinkie/iOS6MapZoomIssue

我的 setRegion: 方法看起来像这个:

My setRegion: method looks like this:

- (void) setRegion:(MKCoordinateRegion)region animated:(BOOL)animated {
    @try {
        // Get the zoom level for the proposed region
        double zoomLevel = [self getFineZoomLevelForRegion:region];

        // Check to see if any corrections are needed:
        //     - Zoom level is too big (a very small region)
        //     - We are looking at satellite imagery (Where the issue occurs)
        //     - We have turned on the zoom level protection

        if (zoomLevel >= (MAX_GOOGLE_LEVELS-1) && self.mapType != MKMapTypeStandard && self.protectZoomLevel) {
            NSLog(@"setRegion: Entered Protected Zoom Level");

            // Force the zoom level to be 19 (20 causes the issue)
            MKCoordinateRegion protectedRegion = [self coordinateRegionForZoomLevel:MAX_GOOGLE_LEVELS-1.0 atCoordinate:region.center];
            [super setRegion:protectedRegion animated:animated];
        } else {
            [super setRegion:region animated:animated];
        }
    }
    @catch (NSException *exception) {
        [self setCenterCoordinate:region.center];
    }
}

这篇关于MKMapView setRegion到小区域会导致卫星图像加载失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆