如何更新 MKPolyline/MKPolylineView? [英] how to update MKPolyline / MKPolylineView?

查看:13
本文介绍了如何更新 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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