我正在尝试从GoogleMaps V2
中删除折线
在标记拖动时,我要将从上一个标记绘制的多段线更改为拖动的标记。
这是用于标记拖动的类,但在其中如何删除多段线?
mMap.setOnMarkerDragListener(new OnMarkerDragListener()
{
public void onMarkerDragStart(Marker marker)
{
}
public void onMarkerDragEnd(Marker marker)
{
mMap.addPolyLine(///)
}
发布于 2012-12-26 16:49:31
可以调用clear()
从GoogleMap
中删除所有标记、多段线和多边形。或者,您可以在Marker
、Polyline
或Polygon
上调用remove()
以从映射中删除单个元素。
发布于 2018-04-19 13:56:21
如果要从地图中删除单个Polyline
,则必须以略有不同的方式添加它:
List<Polyline> lines = new ArrayList<Polyline>();
lines.add(googleMap.addPolyline(new PolylineOptions()
.addAll(lineCoordinates)
.width(width)
.color(color))); //the line will appear on the map here
lines.get(0).remove(); // the line should disappear
https://stackoverflow.com/questions/14043506
复制