Cedric Dugas Cedric Dugas - 5 months ago 26
Javascript Question

remove route with google map

I got a small app that use the Direction Service feature of Google Map. It is working well, I can change routes, but I have a small problem, where a user could go back to a list of markers after tracing a route.

I can't find a way to delete routes with google map. For markers I store them and do

setMap(null)
, do not see a way here...

Answer

if you are using DirectionsRenderer to display the routes, you can call setMap(null) on it too. That way you delete the displayed route.

Using the example code here http://code.google.com/apis/maps/documentation/javascript/examples/directions-simple.html

just call

directionsDisplay.setMap(null);
Comments