我将带有自定义图形的覆盖(MKOverlay)添加到了Mapview。覆盖图显示良好,我可以看到图纸。但是,当我删除覆盖时,它并没有完全删除绘图的某些部分仍然在那里。原因何在?我正在使用removeOverlay:来移除那个覆盖。任何帮助都将不胜感激..
发布于 2011-02-14 05:44:46
不知道你们是否还在对此感到疑惑,但以下方法对我来说是有效的:
// assuming you have mapView and overlay defined somewhere
MKOverlayView *overlayView = [mapView viewForOverlay:overlay];
overlayView.hidden = YES;
[overlayView setNeedsDisplay];
[mapView removeOverlay:overlay];希望这能有所帮助!
发布于 2013-10-01 16:39:17
可以删除地图中的所有覆盖。它工作得非常好
将此函数添加到yourviewController:
-(void)deleteMapOverlays
{
for (id<MKOverlay> overlay in mapView.overlays)
{
[self.mapView removeOverlay:overlay];
}
}使用:
[self deleteMapOverlays];发布于 2018-11-02 15:28:50
位置更新后,我在MKCircle()上不断得到多个覆盖。这是@ErhanDemirci的Swift 4答案,之后我的MKCircle会被添加到其中。步骤2.是答案的Swift 4版本。
// 1. add the MKCircle
let circle = MKCircle(center: location.coordinate, radius: whateverRadius)
// 2. loop through the map view's overlays then remove it. The overlay is the MKCircle
for overlay in mapView.overlays {
mapView.remove(overlay)
}
// 3. add your the MKCircle to the mapView
mapView.add(circle)https://stackoverflow.com/questions/3766604
复制相似问题