更改 MKOverlayView 的 MKOverlay 坐标

发布于 2024-12-29 10:37:54 字数 1476 浏览 1 评论 0原文

我在地图上有一个叠加层,我想更改其坐标。为了无缝地做到这一点,我将调用 setNeedsDisplayInMapRect: 方法。

我已经通过更改 fillColor 进行了测试,效果很好:

overlayView.fillColor = [[UIColor greenColor] colorWithAlphaComponent:0.3];
[overlayView setNeedsDisplayInMapRect:mapView.visibleMapRect];

但是,我似乎遇到了砖墙,试图更改我的覆盖视图的中心坐标(这是一个 MKCircleView 带有 MKCircle)。有一个方法在 MKAnnotation ,MKCircle 符合,称为 设置坐标: -这似乎是我所需要的。但不幸的是,MKCircleView 中的circle 属性是只读的。此外, MKOverlayView 也是只读的。

实际上是否有一种方法可以更改覆盖层的坐标,而无需删除覆盖层视图并添加新的覆盖层视图(这会导致屏幕上出现非常明显的闪烁。)?

I have an overlay on the map, and I would like to change its coordinates. To do this seamlessly I'm going to call the setNeedsDisplayInMapRect: method after the change has been made to the view.

I've tested this out by just changing the fillColor and it works fine:

overlayView.fillColor = [[UIColor greenColor] colorWithAlphaComponent:0.3];
[overlayView setNeedsDisplayInMapRect:mapView.visibleMapRect];

However I've seemingly hit a brick wall trying to also change the center coordinates of my overlay view (which is an MKCircleView with an MKCircle). There is a method in
MKAnnotation, which MKCircle conforms to, called setCoordinate: - which seems like what I need. Unfortunately though, the circle property in MKCircleView is readonly. Moreover the overlay property in MKOverlayView is also readonly.

Is there actually a way of changing the coordinates for an overlay, without resort to remove the overlay view and adding a new one (which would cause very noticeable flicker on the screen.) ?

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

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

发布评论

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

评论(1

无戏配角 2025-01-05 10:37:54

这里发生了同样的问题,所以我正在创建一组方法并根据要求调用它。

-(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];
        }
    }
}

same problem is occurred here , so i'm creating set of method and calling it according to requirement.

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