我正在使用 ADClusterMapView 对 facebook 位置的注释进行聚类。我在这里更新 Places,但每次都会删除所有内容并将所有内容放回原处。
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
double centerLatitude= mapView.centerCoordinate.latitude;
double centerLongitude= mapView.centerCoordinate.longitude;
[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"search?type=place¢er=%f,%f&distance=%d&limit=100&offset=0", centerLatitude, centerLongitude,kDistanceFromCenter] completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (error) {
NSLog(@"error.localizedDescription:%@", error.localizedDescription);
}
//Pins
NSMutableArray * annotations = [[NSMutableArray alloc] init];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
for (NSDictionary * annotationDictionary in [result objectForKey:@"data"]) {
ADClusterableAnnotation * annotation = [[ADClusterableAnnotation alloc] initWithDictionary:annotationDictionary];
[annotations addObject:annotation];
}
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"Building KD-Tree…");
[self.mapView setAnnotations:annotations];
});
});
//End Pins
}];
}
有没有更好的方法来更新地方而不删除所有内容?
谢谢