I am trying to generate the direction on a button click. User selects locations point a and point b and then press a button and code draw direction from that point a to point b. I have successfully completed this code but I am not able to remove the previous directions drawn on map. Please see the image link https://i.sstatic.net/z1fqo.png . I want to remove the a,b direction from the map as it was last direction.
$et_main_map.gmap3({
getroute:{
options:{
origin:org,
destination:dest,
travelMode: google.maps.DirectionsTravelMode.DRIVING
},
callback: function(results){
console.log(results);
if (!results) return;
$(this).gmap3({
directionsrenderer:{
divId:'directionPath',
options:{
directions:results,
suppressMarkers: true
}
}
});
}
}
});
The above code adds the directions. The below code is not removing the directions on map.
$et_main_map.gmap3({
clear: {
name:["directionRenderer"]
}
});
I have tried many things for eg followed below links. http://gmap3.net/forum/viewtopic.php?id=341 Gmap3 Clear Directions
Please help me. Thanks
I needed to update my gmap3 library. For those who want to fix this issue just update gmap3.js to version 5.1.1. This will fix the issue.