根据用户移动 android googleMaps v2 更新折线 [英] update polyline according to the user moving android googleMaps v2

查看:27
本文介绍了根据用户移动 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.

推荐答案

3.1.36 版本的唯一方法:

The only way as of version 3.1.36:

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屋!

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