I am trying to remove a polyline from GoogleMaps V2
On Marker Drag, i want to change the polyline drawn from previous marker to the dragged marker,
Here is the class for marker drag, but in it how can i remove the polyline?
mMap.setOnMarkerDragListener(new OnMarkerDragListener()
{
public void onMarkerDragStart(Marker marker)
{
}
public void onMarkerDragEnd(Marker marker)
{
mMap.addPolyLine(///)
}
you need to clear polylineCoordinates before plotting new paths. polylineCoordinates. clear(); // call this before checking result value.
You can call clear()
to remove all markers, polylines, and polygons from your GoogleMap
. Or, you can call remove()
on the Marker
, Polyline
, or Polygon
to remove an individual element from your map.
If you want to remove a single Polyline
from the map, you will have to add it in a slightly different way:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With