Dhe*_*yay 1 android routes map
我在每个onLocationChange上得到纬度和经度并制作这样的路线:
public void onLocationChanged(Location location) {
PolylineOptions rectLine2;
rectLine2.add(new LatLng(lat, lon));
mGoogleMap.addPolyline(rectLine2);
}
Run Code Online (Sandbox Code Playgroud)
现在我想在一次点击时清除这条路线,并且当我移动时,应该画一条新路线,但在我的情况下,旧路线不清楚.
我做了以下但没有工作:
mGoogleMap.clear();// It clear's the map, but when I again draw the old route again comes.
Run Code Online (Sandbox Code Playgroud)
也
Polyline polyline;
polyline = mGoogleMap.addPolyline(rectLine2);
polyline.reomve()// This also didn't work.
Run Code Online (Sandbox Code Playgroud)
有没有其他解决方案来清除地图?
提前致谢!
小智 5
mGoogleMap.clear()
用于清除整个地图,以便您可以重绘折线...
否则你需要为折线分配一个变量,你可以删除它...
PolylineOptions rectLine2;
rectLine2.add(new LatLng(lat, lon));
Polyline polyline = mGoogleMap.addPolyline(rectLine2);
polyline.remove();
Run Code Online (Sandbox Code Playgroud)
这些是......为什么你需要任何其他解决方案来清除..?
如果您有多条折线,那么只需创建一个数组,并在需要清除后删除所有折线
归档时间: |
|
查看次数: |
6234 次 |
最近记录: |