(iPhone) 如何使用 OS 4.0 MapKit 实现可拖动图钉?

发布于 2024-09-08 14:16:54 字数 54 浏览 3 评论 0原文

任何人都可以提供使用 MapKit 框架在 OS 4.0 中实现可拖动引脚的示例代码/说明吗?

Can anyone provide any sample code/instructions for implementing draggable pins in OS 4.0 using the MapKit framework?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

沦落红尘 2024-09-15 14:16:55

当然,伙计(是的,我在自言自语),

在您的自定义注释中添加:

@property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate; 

这满足了实现 setCooperative 的要求,如 http://developer.apple.com/iphone/library/documentation/MapKit/Reference/MKAnnotationView_Class 中所述/Reference/Reference.html#//apple_ref/occ/instp/MKAnnotationView/draggable

在您的 MapView 委托中添加:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState 
{
//..Whatever you want to happen when the dragging starts or stops
}

并在您的 AnnotationView 中将draggable 设置为 true,例如:

customAnnotationView.draggable      = YES;

我认为这就是我为使其正常工作所做的一切。如果您有困难请告诉我。

Sure thing buddy (yes I'm talking to myself),

In your custom annotation add:

@property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate; 

This satisfies the requirement of implementing setCoordinate, as mentioned inhttp://developer.apple.com/iphone/library/documentation/MapKit/Reference/MKAnnotationView_Class/Reference/Reference.html#//apple_ref/occ/instp/MKAnnotationView/draggable

In your MapView delegate add:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState 
{
//..Whatever you want to happen when the dragging starts or stops
}

and in your AnnotationView set draggable to true, so for example:

customAnnotationView.draggable      = YES;

I think that was everything that I did to get it working. Tell me if you have troubles.

月棠 2024-09-15 14:16:55

查看 Ching-Lang Huang 的 MapKitDragAndDrop 以及作者随附的 博客文章

Check out MapKitDragAndDrop by Ching-Lang Huang and the author's accompanying blog post.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文