MKMapView无法加载到mapType MKMapTypeStandard和MKMapTypeHybrid上

时间:2016-05-05 09:07:39

标签: ios objective-c dictionary mkmapview

我正在开发一个应用程序,其中必须加载3种不同的maptype。

  1. MKMapTypeStandard
  2. MKMapTypeHybrid。
  3. MKMapTypeSatellite。
  4. MKMapTypeSatellite工作正常,但在MKMapTypeStandard和MKMapTypeHybrid中加载地图时。它调用以下委托方法

    - (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error;
    

    它给了我以下错误。

    的UserInfo = {SimpleTileRequesterUnderlyingErrors =(     "错误域= GEOErrorDomain代码= -204 \"(null)\" UserInfo = {HTTPStatus = 410,NSErrorFailingURLStringKey = http://gspe19.ls.apple.com/tile.vf?flags=1&style=1&size=2&scale=0&v=11043961&z=12&x=660&y=1590&sid=1311957767904651942802757092322405105280&accessKey=1462435981_hSWhfZAWqY7wbLSz_6yKz632EUigAIfHlARfHz5OZnObk4SFpRyFZH9qim7suxznqeD333wldHPDaCADTpx1hD98l55WMoqg6qjh2BMyZtDwLayiLzpSWLxfuYD4Oi%2BI3wB%2BGvMwttokk5y8UlnR1E68zLU6KuXF4MWLKLhvv%2F6utSC8RDmorsQksacSTvCwYc45PeV5ba%2Fjvt2d3}" ....

    我正在切换地图类型

    -(IBAction)valuechange:(id)sender{
        switch (((UISegmentedControl *) sender).selectedSegmentIndex) {
            case 0:
                _mapView.mapType = MKMapTypeStandard ;
                break;
    
            case 1:
                _mapView.mapType = MKMapTypeSatellite ;
                break;
    
            case 2:
                _mapView.mapType = MKMapTypeHybrid ;
                break;
    
            default:
                break;
        }
    

    enter image description here enter image description here enter image description here

    更新 我想我有类似的问题 MKMapView fails to load tiles with HTTP 410 error

    当我重新启动模拟器时。现在地图加载完美。同样我的客户告诉我,如果他杀死他的设备地图上的应用程序完美加载。但每个新负载应用程序都有此问题。我现在感到沮丧。 :(

1 个答案:

答案 0 :(得分:1)

这段代码对我有用..如果你做了一些修改,请查看下面的内容。

- (void)viewDidLoad {

[super viewDidLoad];

mapView = [[MKMapView alloc]initWithFrame:
           CGRectMake(10, 100, 300, 300)];
mapView.delegate = self;
mapView.centerCoordinate = CLLocationCoordinate2DMake(37.32, -122.03);
mapView.mapType = MKMapTypeHybrid;
CLLocationCoordinate2D location;
location.latitude = (double) 37.332768;
location.longitude = (double) -122.030039;

// Add the annotation to our map view
MapAnnotation *newAnnotation = [[MapAnnotation alloc]
                                initWithTitle:@"MKMapTypeHybrid" andCoordinate:location];
[mapView addAnnotation:newAnnotation];
CLLocationCoordinate2D location2;
location2.latitude = (double) 37.35239;
location2.longitude = (double) -122.025919;
MapAnnotation *newAnnotation2 = [[MapAnnotation alloc]
                                 initWithTitle:@"MKMapTypeHybrid" andCoordinate:location2];
[mapView addAnnotation:newAnnotation2];
[self.view addSubview:mapView];

}


// When a map annotation point is added, zoom to it (1500 range)
- (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views
{

MKAnnotationView *annotationView = [views objectAtIndex:0];
id <MKAnnotation> mp = [annotationView annotation];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance
([mp coordinate], 1500, 1500);
[mv setRegion:region animated:YES];
[mv selectAnnotation:mp animated:YES];

}

只需更改值即可 mapView.mapType = MKMapTypeStandard;

MKMapTypeStandard,MKMapTypeHybrid&amp; MKMapTypeSatellite

如果你想检查,我也发布了图片。

MKMapTypeHybrid

MKMapTypeSatellite

MKMapTypeStandard