我正在获取每次onLocationChange的纬度和经度,并根据这些信息制作路线,如下所示:
public void onLocationChanged(Location location) {
PolylineOptions rectLine2;
rectLine2.add(new LatLng(lat, lon));
mGoogleMap.addPolyline(rectLine2);
}
现在我希望可以一键清除这条路线,再次移动时,应该重新绘制新的路线,但是在我的情况下,旧路线没有被清除。
我已经尝试了以下方法,但并没有起作用:
mGoogleMap.clear();// It clear's the map, but when I again draw the old route again comes.
此外
Polyline polyline;
polyline = mGoogleMap.addPolyline(rectLine2);
polyline.reomve()// This also didn't work.
还有其他方法可以清除地图吗?
谢谢提前!