user100 user100 - 3 months ago 7
iOS Question

MKMap View showing Only Grid not Showing Map View

In my app i am showing some place on map view using MKMapView . It was showing map fine. But from yesterday it is showing only grid and not showing the map , when i add delegate method it goes in the mapviewdidfiailtoload sometime.

I am using the below code

//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 )annotation {

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 is defined as 1609.344
and i have set delegate in .h file .

All thing was working fine but now it showing the grid only , it showing Pin atleaset

Answer

The iOS simulator comes with the official maps app included. Open that and verify that it can get tiles, it could be a network issue. If the Maps app isn't showing any tiles then you have network issues.

Can you try by turning off the animation by changing the line

[myMapView setRegion:adjustedRegion animated:YES];

By

[myMapView setRegion:adjustedRegion animated:NO];
Comments