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

查看:146
本文介绍了如何更新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天全站免登陆