Mapkit 查找注释当前位置时出现问题
我正在我的应用程序中实现地图套件,并且我是第一次使用它,所以请告诉我如何找到注释的当前位置。?
I am implementing map kit in my app and i am using this first time so please tell me how to find the current position of the annotation.?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要向MapKit添加注释,您需要实现一个实现MKAnnotation协议的注释委托。当您将注释添加到地图时,您将创建 Annotation Delegate 对象的实例,然后将其添加到 MKMapView。 MKAnnotation 包含一个 position 属性,您可以查询该属性来确定注释的位置:
将注释添加到地图中:
然后,当您获得 calloutAccessoryControlTapped 时em> 回调,您可以将 MKAnnotationView.annotation 转换为您的 Annotation Delegate 类,然后查询 position 属性:
To add annotations to MapKit you need to implement an Annotation Delegate which implements the MKAnnotation protocol. When you add the annotation to the map you create an instance of you Annotation Delegate object and then add it to the MKMapView. MKAnnotation includes a position property which you can query to determine the location of the annotation:
To add your annotation to the map:
Then when you get a calloutAccessoryControlTapped callback, you can cast the MKAnnotationView.annotation to your Annotation Delegate class and then query the position property: