title: Clear the directions in google map v3
body: <p>We have two textboxes, in two text boxes giving the location names and converting in to latitude and longitude values. And pass the values to the below function. First time Direction loaded successfully, second time modify the text box value, It will overwriting the direction, of the previous. Its not clearing the previous loaded directions. I want to clear the direction and load the new direction. Please help. </p>
  
  <pre><code>var directionsService = new google.maps.DirectionsService();  
  var directionsDisplay;
  
  function loadDirections(start,end)
  {
      directionsDisplay = new google.maps.DirectionsRenderer();
      if (start &amp;&amp; end) 
      {
          resultsDiv.update(''); // So we clear the div out ourselves
          var request = {
                  origin: start,
                  destination: end,
                  travelMode: google.maps.TravelMode.DRIVING,
                  unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL 
          };
          directionsService.route(request, function(response, status) {
              if (status == google.maps.DirectionsStatus.OK) {
                    directionsDisplay.setDirections(response);
              }
          }); 
          directionsDisplay.setMap(map.map);
          directionsDisplay.setPanel(resultsDiv);
      }
  }
  </code></pre>