MKCircle没有更新半径,但正在翻译

我必须将MKCicle绘制成MKMapView。 然后当用户通过滑块改变半径时,我必须重新绘制它。 我删除它,我重新创build它,重新添加到地图。 但是,不要做我期待的,我看到MKCircle在地图上翻译,保持相同的大小。

这是我的代码:

- (MKOverlayView *)mapView:(MKMapView *)map viewForOverlay:(id)overlay { MKOverlayView* overlayView = nil; if(overlay == self.circle) { //if we have not yet created an overlay view for this overlay, create it now. if(nil == self.circleView) { self.circleView = [[[MKCircleView alloc] initWithCircle:self.circle] autorelease]; self.circleView.fillColor = [UIColor blueColor]; self.circleView.strokeColor = [UIColor blueColor]; self.circleView.alpha = 50; self.circleView.lineWidth = 2; } overlayView = self.circleView; } return overlayView; } -(void)drawPolygonWithLocation { [self.mapView removeOverlay: self.circle]; MKCoordinateRegion region; region.center.latitude = self.geofenceLocation.latitude; region.center.longitude = self.geofenceLocation.longitude; region.span.latitudeDelta = 0.005; region.span.longitudeDelta = 0.005; MKCoordinateRegion adjustedRegion = [self.mapView regionThatFits: region]; [self.mapView setRegion:adjustedRegion animated:TRUE]; self.radius = (double)(slRadius.value); NSLog(@"Raggio: %f", self.radius); NSLog(@"Lat: %f, Lon: %f", region.center.latitude, region.center.longitude); self.circle = [MKCircle circleWithCenterCoordinate:self.geofenceLocation.coordinate radius: self.radius]; NSLog(@"CIRCLE: radius %f Lat: %f, Lon: %f", self.circle.radius, self.circle.coordinate.latitude, self.circle.coordinate.longitude); [self.mapView addOverlay:self.circle]; } -(IBAction)updateRadius:(id)sender { [self drawPolygonWithLocation]; } 

NSLog正在写入控制台右值,中心不会改变,半径会根据用户input而改变。 但是,MKCircle再次翻译了西北部。

在此先感谢,萨比埃拉比尼

固定。 我只是补充一下

 self.circleView = nil; 

之前

 [self.mapView addOverlay:self.circle]; 

以这种方式它工作正常。

塞缪尔