Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing PolyLine from googlemaps v2

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(///)
}
like image 468
Muhammad Umar Avatar asked Dec 26 '12 16:12

Muhammad Umar


People also ask

How do you delete a polyline in flutter?

you need to clear polylineCoordinates before plotting new paths. polylineCoordinates. clear(); // call this before checking result value.


2 Answers

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.

like image 152
CommonsWare Avatar answered Sep 19 '22 01:09

CommonsWare


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
like image 32
Simon Avatar answered Sep 20 '22 01:09

Simon