我在地图上有一个叠加层,我想改变它的坐标。为了无缝地执行此操作,我将在对视图进行更改后调用setNeedsDisplayInMapRect:方法。
我只是通过更改fillColor来测试它,它运行正常:
overlayView.fillColor = [[UIColor greenColor] colorWithAlphaComponent:0.3];
[overlayView setNeedsDisplayInMapRect:mapView.visibleMapRect];
然而,我似乎碰到了一堵砖墙,试图改变我的叠加视图的中心坐标(MKCircleView带有MKCircle)。有一种方法
MKCircle符合的MKAnnotation称为setCoordinate: - 这似乎是我所需要的。不幸的是,MKCircleView中的circle
属性是只读的。此外,MKOverlayView中的overlay
属性也是只读的。
实际上是否有办法更改叠加层的坐标,而无需删除叠加层视图并添加新的叠加层视图(这会在屏幕上引起非常明显的闪烁。)
答案 0 :(得分: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];
}
}
}