CALayer (MKOverlay 上) に一連のアニメーション画像を含む MKOverlay があります。マップ上で移動またはズームするたびに、MKOverlay が再度追加されます。これにより、同じオーバーレイの複数のバージョンが何度も表示されます。オーバーレイを一度だけ表示するように設定する方法はありますか?
オーバーレイをマップに追加するコードは次のとおりです。
- (void)mapRadar {
[self.mapView removeOverlay:self.mapOverlay];
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.mapOverlay = [[MapOverlay alloc] initWithLowerLeftCoordinate:CLLocationCoordinate2DMake(appDelegate.south, appDelegate.west) withUpperRightCoordinate:CLLocationCoordinate2DMake(appDelegate.north, appDelegate.east)];
self.mapView.showsUserLocation = YES;
MKMapPoint lowerLeft2 = MKMapPointForCoordinate(CLLocationCoordinate2DMake(appDelegate.south2, appDelegate.west2) );
MKMapPoint upperRight2 = MKMapPointForCoordinate(CLLocationCoordinate2DMake(appDelegate.north2, appDelegate.east2));
MKMapRect localMapRect = MKMapRectMake(lowerLeft2.x, upperRight2.y, upperRight2.x - lowerLeft2.x, lowerLeft2.y - upperRight2.y);
MKMapPoint lowerLeft = MKMapPointForCoordinate(CLLocationCoordinate2DMake(appDelegate.south, appDelegate.west) );
MKMapPoint upperRight = MKMapPointForCoordinate(CLLocationCoordinate2DMake(appDelegate.north, appDelegate.east));
MKMapRect nationalSectorMapRect = MKMapRectMake(lowerLeft.x, upperRight.y, upperRight.x - lowerLeft.x, lowerLeft.y - upperRight.y);
[self.mapView addOverlay:[MKCircle circleWithMapRect:nationalSectorMapRect]];
[self.mapView setNeedsDisplay];
[self.mapView setVisibleMapRect:localMapRect animated:YES];
}
#pragma Mark - MKOverlayDelgateMethods
-(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id)overlay{
MapOverlayView* circleView = [[MapOverlayView alloc] initWithCircle:(MKCircle *)overlay];
return circleView;
}