title: How to remove all the polylines from a map
body: <p>Following</p>
  
  <p><a href="https://stackoverflow.com/questions/14702621/answer-draw-path-between-two-points-using-google-maps-android-api-v2">How to draw a path between two markers</a></p>
  
  <p>I had to add lot of polylines between two markers, to make a path.</p>
  
  <p>One of the markers is draggable, lets say source is draggable.</p>
  
  <p>So, when user starts dragging the marker, the path previously drawn must be erased and a new path between new source and destination must be draw.</p>
  
  <p>I am able to draw the new path, but how can i erase the previous path?</p>
  
  <p>This is how the path is drawn:</p>
  
  <pre><code>    for (int z = 0; z &lt; list.size() - 1; z++) {
          LatLng src = list.get(z);
          LatLng dest = list.get(z + 1);
          Polyline line = map.addPolyline(new PolylineOptions()
                  .add(new LatLng(src.latitude, src.longitude),
                          new LatLng(dest.latitude, dest.longitude))
                  .width(2).color(Color.RED).geodesic(true));
      }
  </code></pre>
  
  <p>One solution i can get is</p>
  
  <blockquote>
    <p>map.clear();</p>
  </blockquote>
  
  <p>To clear all the polylines, markers etc.. and add the markers again, then drawn the path.</p>
  
  <p>But as soon as I start dragging, the marker is cleared, hence not visible on the map :(</p>
  
  <p>Thank You</p>