在拖动过程中查看MKA注释坐标 [英] Seeing MKAnnotation Coordinates During Drag

查看:98
本文介绍了在拖动过程中查看MKA注释坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在拖动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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆