2013-12-13 127 views
5

在我的应用程序中,我显示使用MKMapView地图视图上的一些地方。它显示地图很好。但从昨天开始,它只显示网格,并没有显示地图,当我添加委托方法时,它会在mapviewdidfiailtoload有时。MKMap查看显示只有网格不显示地图视图

我使用下面的代码

// MapView的

myMapView=[[MKMapView alloc] initWithFrame:CGRectMake(0,gameNameLabel.frame.size.height, 320, 181)]; 
myMapView.mapType=MKMapTypeStandard; 
myMapView.delegate=self; 
LocationModel *loc=presentGame.location; 
NSArray *cordinates=[loc.geoCordinates componentsSeparatedByString:@","]; 

CLLocationCoordinate2D zoomLocation; 
zoomLocation.latitude = [[cordinates objectAtIndex:0] doubleValue]; 
zoomLocation.longitude= [[cordinates objectAtIndex:1] doubleValue]; 
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 0.5*METERS_PER_MILE, 0.5*METERS_PER_MILE); 
// 3 
MKCoordinateRegion adjustedRegion = [myMapView regionThatFits:viewRegion]; 
// 4 
[myMapView setRegion:adjustedRegion animated:YES];  [scroll addSubview:myMapView]; 
Place *pin = [[Place alloc] init]; 
pin.name = loc.gameLocation; 
pin.latitude = [[cordinates objectAtIndex:0] doubleValue]; 
pin.longitude = [[cordinates objectAtIndex:1] doubleValue]; 
PlaceMark* Place1 = [[PlaceMark alloc] initWithPlace:pin]; 
Place1.tagg=1; 
[myMapView addAnnotation:Place1]; 
//end of mapview 

- (MKAnnotationView *)的MapView:(*的MKMapView)mapView1 viewForAnnotation:(ID)注释{

static NSString *identifier = @"PlaceMark"; 
if ([annotation isKindOfClass:[PlaceMark class]]) { 

    MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [mapView1 dequeueReusableAnnotationViewWithIdentifier:identifier]; 
    annotationView.tag=[mapView1.annotations count]; 
    if (annotationView == nil) { 
     annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier]; 
    } else { 
     annotationView.annotation = annotation; 
    } 
    annotationView.enabled = YES; 
    annotationView.canShowCallout = YES; 
    return annotationView; 
} 

return nil; 

}

METERS_PER_MILE定义为1609.344 和ih ave在.h文件中设置委托。

所有的事情是工作正常,但现在只显示网格,它显示引脚atleaset

+0

你太接近地表了,在这样的分辨率下没有地球的图像=)至少这是我的情况的问题 – Ossir

+0

不,我不这样做,因为它显示地图一些时间。请建议一些东西 – user100

+1

检查你的网络连接 –

回答

0

iOS的模拟器自带的官方地图应用程序包括在内。打开它并验证它可以获取切片,这可能是一个网络问题。如果地图应用未显示任何图块,则表示网络问题。

你可以尝试关闭动画通过改变线路

[myMapView setRegion:adjustedRegion animated:YES]; 

通过

[myMapView setRegion:adjustedRegion animated:NO]; 
+0

是的,我检查模拟器上的地图应用程序,它也显示唯一的瓷砖。我现在做什么。 – user100

+0

然后它的你的网络问题... –

+0

好的。感谢您的建议 – user100

8

我有同样的问题MKMap视图只显示不显示地图视图网格。我发现它与我在我的Mac上对时间/日期所做的更改有关。当我将时间和日期固定到当前时间时,地图再次运行。