从地图中删除 mkoverlay

发布于 2024-09-24 02:49:27 字数 130 浏览 3 评论 0原文

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

i added overlay (MKOverlay) with custom drawings to the Mapview. The overlay showing fine and i can see the drawings. But when i remove that overlay its not removing perfectly some part of the drawing is still there. What is the reason? im using removeOverlay: for removing that overlay. Any help is appreciated..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

遮云壑 2024-10-01 02:49:27

不知道你们是否仍然想知道这个问题,但以下内容对我有用:

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

希望这有帮助!

Don't know if you guys are still wondering about this, but the following works for me:

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

Hope this helps!

夢归不見 2024-10-01 02:49:27

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

将此功能添加到 yourviewController :

-(void)deleteMapOverlays
{

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

}

使用:

 [self deleteMapOverlays];

you can delete all overlay in your map. it's working very well

add this function to yourviewController :

-(void)deleteMapOverlays
{

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

}

using :

 [self deleteMapOverlays];
爱的故事 2024-10-01 02:49:27

位置更新后,我的 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)

I kept getting multiple overlays on top of my MKCircle() after the location was updated. Here's the Swift 4 answer of @ErhanDemirci answer with my MKCircle being added to it afterwards. Step 2. is the Swift 4 version of the answer.

// 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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文