Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MKMapView not loading on mapType MKMapTypeStandard and MKMapTypeHybrid

I am developing an app in which 3 different maptype have to load.

  1. MKMapTypeStandard
  2. MKMapTypeHybrid.
  3. MKMapTypeSatellite.

MKMapTypeSatellite working fine but when load map in MKMapTypeStandard and MKMapTypeHybrid. It call following delegate method

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

It give me following error.

UserInfo={SimpleTileRequesterUnderlyingErrors=( "Error Domain=GEOErrorDomain Code=-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}"....

I am switching map type

-(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 hereenter image description hereenter image description here

UPDATE: I think i have similar issue MKMapView fails to load tiles with HTTP 410 error

when i reboot the simulator. Now map load perfectly. same my client tell me that if he kill the app on his device map loading perfectly. but every fresh load app having this issue. i am getting frustrated now. :(

like image 526
Bhushan Vaidya Avatar asked May 05 '16 09:05

Bhushan Vaidya


1 Answers

this code worked for me.. check below if you having some modifications.

- (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];

}

Just change the values mapView.mapType = MKMapTypeStandard;

MKMapTypeStandard, MKMapTypeHybrid & MKMapTypeSatellite

I have posted the images, too if you want to check.

MKMapTypeHybrid

MKMapTypeSatellite

MKMapTypeStandard

like image 147
Krutika Sonawala Avatar answered Oct 16 '22 15:10

Krutika Sonawala