根据用户移动android googleMaps v2更新折线 [英] update polyline according to the user moving android googleMaps v2
问题描述
我在googleMap(v2)中使用了折线,它在用户当前位置和目的地点之间呈现路线。
现在,我想根据用户移动来更新折线。
当位置改变但多段线闪烁时,我试图重绘整个多段线。
我在PolylineOptions类中找不到任何适当的函数(函数add()仅用于添加顶点但不能更新或删除)
你有什么想法如何更新多义线吗?
感谢您给予您的时间。
I have googleMap (v2) with polyline that presents a route between the user current location and the destination point.
Now, I want to update the polyline according to the user moving.
I tried to redrawing the whole polyline when location is changed but the polyline is flickering.
I didn't find any appropriate function in the PolylineOptions class
(the function add() is only to add a vertex but not to update or remove)
do you have any idea how to update the polyline ???
thank you for giving your time.
推荐答案
List<LatLng> points = polyline.getPoints();
points.add(newPoint);
polyline.setPoints(points);
希望API能够在后续版本中得到增强。
Hopefully the API will be enhanced in later versions.
这篇关于根据用户移动android googleMaps v2更新折线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!