在拖动过程中查看MKA注释坐标 [英] Seeing MKAnnotation Coordinates During Drag
问题描述
我希望能够在拖动MKAnnotation
时跟踪其坐标.目前,我只能在拖动开始时获取坐标.
I want to be able to track the coordinates of my MKAnnotation
as I drag it. Currently, I am only getting the coordinates as the drag begins.
我尝试用touchesMoved
实现自定义的MKAnnotationView
子类,但是这似乎不起作用. (如此处的建议:在拖动时获取MKAnotnotation的坐标.)
I have tried implementing a custom MKAnnotationView
subclass with touchesMoved
, however this appears not to work. (As suggested here: Obtaining MKAnnotation's coordinate while dragging.)
通过在拖动注释时接收到新坐标,我将依次更新多边形形状.
By receiving the new coordinates as I drag my annotation, I will in turn be able to update my polygon shape.
推荐答案
您可以从MKAnnotationView
跟踪坐标.
拖动视图时,将调用以下委托.
When your view is dragged.The following delegate gets called.
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState
您可以使用:
if (newState == MKAnnotationViewDragStateDragging) {
CLLocationCoordinate2D location = [_polyMapView convertPoint:view.center toCoordinateFromView:view.superview];
}
这里_polyMapView
将是您的mapView,view
将是您的注释视图.这将为您提供注释的当前坐标.
Here _polyMapView
would be your mapView and view
would be your annotation view.This would get you the current coordinates of the Annotation.
这篇关于在拖动过程中查看MKA注释坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!