Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

javascript - 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() {
$('#content').hide();
directionDisplay = new google.maps.DirectionsRenderer();
directionDisplay.suppressMarkers = true;
directionDisplay.setMap(map);
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.

Dave.

question from:https://stackoverflow.com/questions/5645920/remove-directions-from-google-map-api-v3

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

directionDisplay.setMap(null);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...