私のアプリでは、Parse クエリから他のデータと共に緯度と経度を取得します。ただし、156 個あるはずの注釈が約 100 個しか追加されません。コンソールで、マップ上の欠落部分の座標が取得されていることを確認しましたが、単にそれらの注釈が追加されていません。明らかな何かが欠けていますか?
-(void) viewWillAppear:(BOOL)animated {
CLLocationCoordinate2D coord = {.latitude = 15.8700320, .longitude = 100.9925410};
MKCoordinateSpan span = {.latitudeDelta = 3, .longitudeDelta = 3};
MKCoordinateRegion region = {coord, span};
[mapViewUI setRegion:region];
PFQuery *query = [PFQuery queryWithClassName:@"Share"];
[query setLimit:1000];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
self.mapViewData = objects;
NSLog(@"HOW MANY ARE THERE %lu", (unsigned long)[objects count]);
for (int i=0;i<[objects count];i++)
{
// Question * q = [[Question alloc]init];
PFObject * obj = [self.mapViewData objectAtIndex:i];
NSLog(@"%@", obj);
self.theObject = obj;
NSString *string = obj[@"WhereAt"];
NSArray *stringArray = [string componentsSeparatedByString: @","];
CLLocationDegrees myLatitude = [[stringArray objectAtIndex:0] doubleValue];
CLLocationDegrees myLongitude = [[stringArray objectAtIndex:1] doubleValue];
CLLocationCoordinate2D coord2 = {.latitude = myLatitude, .longitude = myLongitude};
NSLog(@"LATITUDE %@", [stringArray objectAtIndex:0]);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"MMM dd, yyyy";
MKPointAnnotation *annotation2 = [[MKPointAnnotation alloc] init];
[annotation2 setCoordinate:coord2];
[annotation2 setTitle:obj[@"FamilyName"]];
[annotation2 setSubtitle:obj[@"Result"]];
[mapViewUI addAnnotation:annotation2];
}
} else {
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
if (annotation == mapViewUI.userLocation)
{
return nil;
}
else
{
MKPinAnnotationView *annotationView = [[MKPinAnnotationView alloc] init];
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"MMM dd, yyyy";
if ([annotation.subtitle isEqualToString:@"Accepted Bible"]) {
NSLog(@"Accepted");
annotationView.pinTintColor = [UIColor greenColor];
}
else if ([annotation.subtitle isEqualToString:@"Requested Different Material"]) {
NSLog(@"Different");
annotationView.pinTintColor = [UIColor blackColor];
}
else if ([annotation.subtitle isEqualToString:@"Not Home"]) {
NSLog(@"Not Home");
annotationView.pinTintColor = [UIColor yellowColor];
}
else if ([annotation.subtitle isEqualToString:@"Rejected Bible"]) {
NSLog(@"Rejected");
annotationView.pinTintColor = [UIColor redColor];
}
return annotationView;
}
return nil;
}