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.
Google Maps allows you to customize maps by adding markers manually or as a group. This method is simple and free, making it a great choice for anyone with limited experience or budget. Click on the Menu icon in the top left-hand corner. Click on the “Your Places” option in the menu.
You remove markers by using set_map(null) on the particular marker you want to clear, if you want to clear all then loop through using this function.
You can change the map binding for the DirectionsRenderer to "null" to remove the direction overlay
directionDisplay.setMap(null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With