I am currently working with MKMapView and I am trying to make the data appear on the screen. To do this, I decided to choose a small MapDataProvider, which splashes out an array of MKAnnotation objects - each of which contains a coordinate with random values ββof latitude and longitude.
I have already made sure that my MKMapView is connected to my controller, and the array of MKAnnotation objects comes from my MapDataProvider correctly ... but for some reason .. when I try to specify coordinates in North America (for example, 48, -84) .. nothing is displayed in MKMapView.
After the game, I found out that any value of longitude less than 0 gives me this problem.
I tried to check the coordinate value for each MKAnnotation object in my collection, but CLLocation2DIsValue () continues to return false.
Question
What range of values ββcan I enter for latitude and longitude for CLLocationCoordinate2D so that my contacts appear in North America?
To give a little more context, here is the method called in MapDataProvider:
+ (NSArray *) getMockMapData {
NSMutableArray *tempMapData = [[NSMutableArray alloc] initWithCapacity:15]; for (int i=0; i< 15; i++) { double latitude = rand()%20 +50; double longitude = -107 + rand()%10; CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(latitude, longitude); if(CLLocationCoordinate2DIsValid(coord) == NO) continue; [tempMapData addObject:[MockMapData dataForValues:[@"Item " stringByAppendingString:[[NSNumber numberWithInt:i] description]] subTitle:[@"Item " stringByAppendingString:[[NSNumber numberWithInt:i]description]] coordinate:coord]]; } return tempMapData; }
source share