我在地图上有一个叠加层,我想改变它的坐标。为了无缝地完成此操作,我将在对视图进行更改后调用setNeedsDisplayInMapRect:方法。
我已经通过更改fillColor测试了这一点,它工作得很好:
overlayView.fillColor = [[UIColor greenColor] colorWithAlphaComponent:0.3];
[overlayView setNeedsDisplayInMapRect:mapView.visibleMapRect];然而,我似乎碰壁了,试图同时改变我的覆盖视图(这是一个带有MKCircle的MKCircleView )的中心坐标。MKCircle所遵循的MKAnnotation中有一个叫做setCoordinate:的方法--这似乎就是我需要的。不幸的是,MKCircleView中的circle属性是只读的。此外,MKOverlayView中的overlay属性也是只读的。
实际上有没有一种方法可以改变覆盖图的坐标,而不需要移除覆盖图并添加一个新的覆盖图(这会导致屏幕上非常明显的闪烁)?
发布于 2013-08-25 16:45:25
同样的问题也发生在这里,所以我创建了一组方法,并根据需要调用它。
-(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];
}
}
}https://stackoverflow.com/questions/9058612
复制相似问题