1

我在 Mapview 中添加了带有自定义绘图的叠加层(MKOverlay)。覆盖显示很好,我可以看到图纸。但是当我删除该覆盖时,它并没有完全删除绘图的某些部分仍然存在。是什么原因?我正在使用 removeOverlay: 来删除该覆盖。任何帮助表示赞赏..

4

3 回答 3

4

不知道你们是否仍然对此感到疑惑,但以下内容对我有用:

// assuming you have mapView and overlay defined somewhere
MKOverlayView *overlayView = [mapView viewForOverlay:overlay];
overlayView.hidden = YES;
[overlayView setNeedsDisplay];
[mapView removeOverlay:overlay];

希望这可以帮助!

于 2011-02-13T21:44:46.340 回答
2

您可以删除地图中的所有叠加层。它工作得很好

将此功能添加到 yourviewController :

-(void)deleteMapOverlays
{

    for (id<MKOverlay> overlay in mapView.overlays)
    {
        [self.mapView removeOverlay:overlay];
    }

}

使用 :

 [self deleteMapOverlays];
于 2013-10-01T08:39:17.390 回答
0

位置更新后,我不断在 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)
于 2018-11-02T07:28:50.317 回答