我有一个Parse类,它包含我在地图视图上每个注释所需的所有信息。我正在运行Parse查询来检索数据。我正在将数据添加到数组中,因为我正在使用数组来实现其他功能。我遇到的问题是,即使注释数组中包含我期望的注释数量,但我的地图上只显示了五个注释(98)。我做错了什么?
getMarkets方法(在viewDidLoad中调用)
- (void)getMarkets {
self.lat = [[NSMutableArray alloc]init];
self.lon = [[NSMutableArray alloc]init];
self.title1 = [[NSMutableArray alloc]init];
self.subtitle1 = [[NSMutableArray alloc]init];
self.phoneNumbers = [[NSMutableArray alloc]init];
self.websites = [[NSMutableArray alloc]init];
marketLocations = [[NSMutableArray alloc]init];
PFQuery *query = [PFQuery queryWithClassName:@"Markets"];
[query setLimit:1000];
[query orderByAscending:@"Name"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (NSDictionary *objectDictionary in objects) {
[self.title1 addObject:[objectDictionary objectForKey:@"CompanyName"]];
[self.subtitle1 addObject:[objectDictionary objectForKey:@"MarketAddress"]];
[self.phoneNumbers addObject:[objectDictionary objectForKey:@"MarketPhone"]];
[self.websites addObject:[objectDictionary objectForKey:@"Website"]];
[self.lat addObject:[objectDictionary objectForKey:@"Latitude"]];
[self.lon addObject:[objectDictionary objectForKey:@"Longitude"]];
marketAnnotation = [[FarmMarketAnnotation alloc]init];
location.latitude = [[objectDictionary objectForKey:@"Latitude"]floatValue];
location.longitude = [[objectDictionary objectForKey:@"Longitude"]floatValue];
marketAnnotation.coordinate = location;
marketAnnotation.title = [objectDictionary objectForKey:@"CompanyName"];
marketAnnotation.subtitle = [objectDictionary objectForKey:@"MarketAddress"];
marketAnnotation.phoneNumber = [objectDictionary objectForKey:@"MarketPhone"];
marketAnnotation.website = [objectDictionary objectForKey:@"Website"];
[marketLocations addObject:marketAnnotation];
}
dispatch_async(dispatch_get_main_queue(), ^ {
NSLog(@"Annotations Count: %lu", (unsigned long)marketLocations.count);
[worldView addAnnotations:marketLocations];
});
}
else {
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
答案 0 :(得分:0)
我发现了问题。对于除了这5个注释之外的所有注释,我的数据库中的经度前面都有一个新的线条字符。