iPhone - 更新mapkit中的注释字幕
我有一个带有标题和副标题的自定义地标。副标题实际上是使用反向地理编码器显示放置的图钉的地址。
我有一个按钮,可以执行放下图钉的操作。此操作获取用户的位置坐标,然后调用 [geocoder start],它使用反向地理编码器获取完整地址并生成自定义注释,然后调用 [mapView addAnnotation:customPlacemark]。
我的问题是,使用这个序列顺序,当没有 WiFi 连接(只有 3G 或可能是 Edge)时,引脚需要很长时间才能放下,因为它需要等待获取反向地理编码信息。
所以基本上我需要在没有字幕的情况下删除引脚,并从 viewDidAnnotation 调用地理编码器并在反向地理编码器内更新字幕,但我不知道如何做到这一点。
我想显示没有地址详细信息的注释,并在从反向地理编码器获取信息时更新它。
有什么建议吗?
提前致谢
I have a custom placemark with title and subtitle. The subtitle is actually displaying the address of the dropped pin using the reverse geocoder.
I have a button which has an action to drop the pin. This action gets the location coordinates of the user, and then calls [geocoder start] which gets the full address with Reverse Geocoder and generates the custom annotation and then calls [mapView addAnnotation:customPlacemark].
My problem is that using this sequence order, when there's no a WiFi connection (only 3G or maybe Edge) the pin takes a lot to drop because it's watigin to get the reverse geocoding info.
So basically I need to drop the pin without a subtitle and from the viewDidAnnotation call the geocoder and inside the reverseGeocoder update the subtitle but I'm not sure how to do that.
I want to display the annotation without the address details and update it when it gets the information from the reverse geocoder.
Any suggestions?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MKMapView
通过 KVO 观察其注释的更改。因此,如果您以符合 KVO 的方式更新注释的属性,它应该可以正常工作。例如,当反向地理编码器返回注释的地址时,您首先宣布
title
和subtitle
属性即将更改:请注意,上面的代码假定为在注释类中。
然后使用地理编码器中的信息更新注释。完成后:
请注意
didChangeValueForKey:
的顺序发生了变化,因为它们需要正确嵌套,有点像 HTML 标签。这也适用于坐标属性,这将导致图钉移动。
MKMapView
observes changes its annotations via KVO. Therefore if you update your annotation's properties in a KVO compliant manner, it should Just Work.For example, when the reverse geocoder returns an address for your annotation, you first announce the
title
andsubtitle
properties are about to change:Note that the above code is assumed to be in the annotation class.
Then update the annotation with information from the geocoder. When you are done:
Note the order changed for
didChangeValueForKey:
as these need to be nested properly, somewhat like HTML tags.This also works for the
coordinate
property, that will cause the pin to move.我将放置注释,在属性中保留对其的引用,然后当反向地理编码器回调时,使用对注释的引用并更新其属性。
I'd place the annotation, keep a reference to it in a property, then when your reverse geocoder calls back use the reference to the annotation and update its properties.