how to update MKPolyline / MKPolylineView?(如何更新 MKPolyline/MKPolylineView?)
问题描述
我正在尝试创建一个定期更新的折线 (MKPolyline) 叠加层,以模拟对象的移动.我可以通过删除旧的叠加层、更新折线并再次添加叠加层来实现这一点,但这会导致闪烁.
I am trying to create a polyline (MKPolyline) overlay that updates periodically, to simulate the movement of an object. I can achieve this by removing the old overlay, updating the polyline and adding the overlay again, but this leads to flickering.
对于一个点注解(MKPointAnnotation),你可以简单地改变它的坐标,视图会自动平滑地更新,而无需移除和重新添加注解.
For a point annotation (MKPointAnnotation) you can simply change its coordinate, and the view will be updated automatically and smoothly without having to remove and re-add the annotation.
这是否也可以通过某种方式覆盖?
Is this also possible somehow for an overlay?
推荐答案
是的,您必须添加一个额外的叠加层,其中包含从最后一个点到下一个点的点集.使用点创建 MKPolyline 后,在绘制 MKPolylineView 时无法更改它,而无需删除旧点并添加新创建的点.
yea, you would have to add an additional overlay with the point set of from your last point to your next point. Once you create the MKPolyline with your points, your not able to change it when it draws the MKPolylineView without removing the old and adding the newly created one.
您可以使用所有点(包括新点)创建一个新的折线视图并将其添加到地图中,但不要删除旧的.然后,一旦添加了新的,您就可以删除旧的较短的.实施起来可能不太好,但它应该摆脱更新时的闪烁.你可以用标签区分旧的和新的.也许标记会起作用.
you could create a new polyline view with all the points (including the new one) and add it to the map but do not remove the older one. then once the new one is added, you can remove the older shorter one. It might not be pretty to implement but it should get rid of the flashing on updates. you can distinguish the old and the new with a tag. maybe a point count as the tag would work.
这篇关于如何更新 MKPolyline/MKPolylineView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何更新 MKPolyline/MKPolylineView?
基础教程推荐
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01