Jimmy Lee Jimmy Lee - 7 months ago 16
HTML Question

Clear / Reset Direction Panel in Google Map API v3

Every time we search the route by the direction service, the result will be append to the bottom of the direction panel. Some people recommend to reset the panel in div tab as null... Can anyone suggest how to do it....`

function calcRoute() {

directionsDisplay = new google.maps.DirectionsRenderer({
'map': map,
'preserveViewport': false, //Google Map will change the zoom extent to match with the Direction route if set false
'draggable': true
});
directionsDisplay.setPanel(document.getElementById("directions_panel"));


HTML part:

<div id="directions_panel" style="width:90%"></div>

Answer

This should work:

  document.getElementById("directions_panel").innerHTML = "";