更改MKOverlayView的MKOverlay坐标 [英] Change coordinate of MKOverlay for an 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.
我已经通过更改fillColor进行了测试,效果很好:
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];
但是,我似乎碰到一堵砖墙,试图同时更改覆盖视图的中心坐标(这是一个MKCircleView 和 MKA注释 ,它称为overlay属性> MKOverlayView 也是只读的.
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.) ?
推荐答案
在这里发生了同样的问题,所以我正在创建一组方法并根据需要调用它.
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];
}
}
}
这篇关于更改MKOverlayView的MKOverlay坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!