7

我在地图上有一个叠加层,我想更改它的坐标。为了无缝地做到这一点,我将在对视图进行更改后调用setNeedsDisplayInMapRect:方法。

我已经通过更改 fillColor 对其进行了测试,它工作正常:

overlayView.fillColor = [[UIColor greenColor] colorWithAlphaComponent:0.3];
[overlayView setNeedsDisplayInMapRect:mapView.visibleMapRect];

但是,我似乎碰壁了,试图也改变我的覆盖视图的中心坐标(这是一个带有MKCircleMKCircleView)。MKAnnotation中有一个 MKCircle 符合的方法,称为setCoordinate: - 这似乎是我需要的。不幸的是,circleMKCircleView 中的属性是只读的。此外MKOverlayViewoverlay中的属性也是只读的。

实际上有没有一种方法可以更改叠加层的坐标,而无需删除叠加层视图并添加一个新视图(这会导致屏幕上非常明显的闪烁。)?

4

1 回答 1

0

这里发生了同样的问题,所以我正在创建一组方法并根据要求调用它。

-(void)removeAllAnnotationFromMapView{
    if ([[self.tmpMapView annotations] count]) {
        [self.tmpMapView removeAnnotations:[self.tmpMapView annotations]];
    }
}
-(void)removeAllOverlays{
    if ([[self.tmpMapView overlays] count]) {
        [self.tmpMapView removeOverlays:[self.tmpMapView overlays]];
    }
}

-(void)removeOverlayWithTag:(int)tagValue{
    for (MKOverlayView *oView in [self.tmpMapView overlays]) {
        if (oView.tag == tagValue) {
            [self.tmpMapView removeOverlay:oView];
        }
    }
}
于 2013-08-25T08:45:25.157 回答