2013-05-08 27 views
4

我一直在同一個應用程序的工作數月,這是一個新問題。我想知道Apple Map數據的服務器端是否有變化。這裏的問題:MKMapView setRegion to Small Area會導致失敗的衛星圖像加載

我的應用程序(有時)想要設置一個MKMapView區域到一個特定的位置可能的最充分放大的值。要做到這一點,我做這樣的事情:

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

無論在哪裏item's座標,我得到的網格「沒有衛星圖像」的背景。這似乎與可用的衛星圖像無關,因爲它在美國的許多地區表現一致。

我知道,setRegion:animated:可能會調整事實後的地區。我知道一個100萬平方米是一個不合理的小區域,試圖在相當大的地圖上顯示。所以,我已經試過

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

設置animated:YES似乎以防止這種情況發生,但我不希望動畫這些變化。

一些更多的意見:

  • 如果我縮小僅有1或2個像素,顯示的地圖圖像。
  • 試圖執行映射委託方法:– mapViewDidFailLoadingMap:withError:沒有幫助。它從未被稱爲。
  • 這似乎是新的。我在應用程序商店中的應用程序的工作版本現在顯示類似的問題。
  • 我最近在其他流行的應用程序中看到過這種情況。

對此解決方案有任何想法,或確認它是系統性問題?

+0

這似乎確實與iOS 6.1相關。 (至少在模擬器中。) – DeepFriedTwinkie 2013-05-08 22:06:34

回答

1

我結束了子類MKMapView和覆蓋setRegion:。我創建了一個示例應用程序在Github上,如果有人有興趣在行動中發現的問題,或者我的解決方案:

https://github.com/DeepFriedTwinkie/iOS6MapZoomIssue

setRegion:方法是這樣的:

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

它不起作用,仍然在mapView上沒有找到圖像。 – 2016-08-24 07:59:55

1
//fix for ios6 
if (region.span.latitudeDelta < .0005f) 
    region.span.latitudeDelta = .0005f; 
if (!region.span.longitudeDelta < .0005f) 
    region.span.longitudeDelta = .0005f; 

確保您的區域經緯度不是太低,它會清除。

+0

謝謝。這並不適合我。即使在有效的縮放級別(如19)緯度經度和經度緯度都小於.0005。 – DeepFriedTwinkie 2013-07-19 23:57:20