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.
我在地图上有一个覆盖层,我想改变它的坐标。为了无缝地实现这一点,我将在对视图进行更改之后调用setNeedsDisplayInMapRect:方法。
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.
然而,我似乎碰到了一堵砖墙,试图改变叠加视图的中心坐标(它是一个带有MKCircleView的MKCircle)。MKAnnotation中有一个方法,MKCircle符合这个方法,名为setCoordinate:——这似乎是我需要的。不幸的是,MKCircleView中的circle属性是只读的。而且MKOverlayView中的叠加属性也是只读的。
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.) ?
是否有一种方法可以改变覆盖的坐标,而不需要移除叠加视图并添加一个新视图(这会在屏幕上引起非常明显的闪烁)?
1 个解决方案
#1
0
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];
}
}
}
#1
0
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];
}
}
}