daveredfern daveredfern - 1 year ago 196
Javascript Question

Remove directions from google map api v3

I have a google map using API v3 which gets directions from one location to another. The app works great but the window which gets the directions is an overlay on the map. I'd like it so when this window is closed directions are removed from the map but other markers remain.

I have tried the following:

$('#content .close').live('click', function() {
directionDisplay = new google.maps.DirectionsRenderer();
directionDisplay.suppressMarkers = true;
return false;

This seems to hide the window as expected but doesn't do anything regards with removing directions from the map.

Any help is much appreciated.


Answer Source

You can change the map binding for the DirectionsRenderer to "null" to remove the direction overlay