gpt4 book ai didi

ios - 更改 MKOverlayView 的 MKOverlay 坐标

转载 作者:可可西里 更新时间:2023-11-01 03:35:14 26 4
gpt4 key购买 nike

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

我已经通过更改 fillColor 测试了这一点,它工作正常:

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

然而,我似乎碰壁了,试图同时更改我的叠加 View 的中心坐标(即 MKCircleViewMKCircle )。里面有一个方法 MKAnnotation ,MKCircle 符合,称为 setCoordinate: - 这似乎是我需要的。不幸的是,MKCircleView 中的 circle 属性是只读的。此外,MKOverlayView 中的 overlay 属性也是只读的。

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

最佳答案

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

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

关于ios - 更改 MKOverlayView 的 MKOverlay 坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9058612/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com