6

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

user3126427
  • 855
  • 2
  • 14
  • 29
user100
  • 327
  • 5
  • 19

2 Answers2

8

I had the same problem MKMap View showing Only Grid not Showing Map View. I found out it was related to a change I made to the time/date on my mac. When I fixed the time and date to current time, the map worked again.

user3126427
  • 855
  • 2
  • 14
  • 29
0

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];
Nithin Michael
  • 2,166
  • 11
  • 32
  • 56
  • Yes i check the map app on simulators it also shows the only tiles . what shoud i do now. – user100 Dec 18 '13 at 10:11
  • some time my app is hanged whaen i use MKMap view and it take so may memory by using map view . i have to display map several time in my app and it takes so many memory that causing crashes . please suggest some thing . – user100 Dec 18 '13 at 10:23
  • see the solutions here..http://stackoverflow.com/questions/12641658/ios6-mkmapview-using-a-ton-of-memory-to-the-point-of-crashing-the-app-anyone-e – Nithin Michael Dec 18 '13 at 10:27