我有一个MKPolyline
个对象的叠加数组和一个要在地图视图上添加的注释数组。正在添加注释,但叠加层未添加到地图视图中。
我添加这些叠加层和注释的代码为 -
-(void) addOverlay:(TropicalStorm *)storm{
//tropicalStorm is my model class for storing an overlay array and annotation array
NSArray *overlay = storm.overlays;
NSArray *annnotations = storm.annotations;
dispatch_async(dispatch_get_main_queue(), ^{
[self.mapView addOverlays: overlay];
[self.mapView addAnnotations:annotations];
});
MKMapRect flyTo = MKMapRectNull;
for (id <MKOverlay> overlay in storm.overlays) {
if (MKMapRectIsNull(flyTo)) {
flyTo = [overlay boundingMapRect];
} else {
flyTo = MKMapRectUnion(flyTo, [overlay boundingMapRect]);
}
}
MKCoordinateRegion region = [MapUtilities regionForAnnotations:storm.annotations];
[self.mapView setCenterCoordinate:region.center zoomLevel:6 animated:YES];
}
此代码中可能存在什么问题,或者为什么没有呈现?