MKAnnotations are being made successfully, however they sometimes fail to render on MKMapView
- by jtkendall
I'm working on an iPhone app using the 3.1.3 SDK, my app finds the users current location, displays it on a MKMapView and then finds nearby locations and renders them as MKAnnotations. My code is working, however sometimes the nearby annotations do not appear on the map. They are still being made as I see the correct data in the console (from NSLog which runs just after the annotations are made).
When it fails is completely random, it could be the 5th time I've hit "Build and Run" for the day, or the 500th it doesn't appear to have any pattern and doesn't throw any type of error, it just doesn't add the annotations to the MapView.
This is the method called for each nearby location to add the MKAnnotation.
- (void)addPinsWithLocation:(NSDictionary *)spot
{
CLLocationCoordinate2D location;
location.longitude = [[spot objectForKey:@"spot_longitude"] doubleValue];
location.latitude = [[spot objectForKey:@"spot_latitude"] doubleValue];
PlaceMarks *placemark = [[PlaceMarks alloc] initWithCoordinate:location title:[spot objectForKey:@"spot_name"] subtitle:@""];
NSLog(@"Adding Pin for Location: '%@' at %f, %f", [spot objectForKey:@"spot_name"], location.latitude, location.longitude);
[mapView addAnnotation:placemark];
}
Any ideas on how to get MKAnnotations to always show?