webewitch
webewitch

Reputation: 89

Remove Directions not working

I'd like a javascript link that will remove the directions from my map.

Elsewhere on this forum Remove directions from google map api v3 someone asked a similar question and had a solution - but the solution doesn't work for me. Based on that I've tried:

 function clearDirections() {
directionDisplay = new google.maps.DirectionsRenderer();
directionDisplay.suppressMarkers = true;
directionDisplay.setMap(null);
return false;
 }

What am I doing wrong?

Upvotes: 0

Views: 825

Answers (1)

barryhunter
barryhunter

Reputation: 21081

Hmm, that function creates a new renderer, and then displays it on no map. Ie it does nothing.

You need to keep a reference to the original directions display - so that you can the setMap(null) - which will remove it from the map.

Upvotes: 1

Related Questions