Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 213
The Orca Avatar asked Mar 08 '11 12:03

The Orca


People also ask

Can you edit route on Google Maps?

You can change where your route begins and ends. Important: You can't start navigation if you don't use your current location, but you can still get a preview of the route. Search for your destination or tap it on the map. To edit your starting point, at the top, tap Your location.


2 Answers

You could also use:

directionsDisplay.setDirections({routes: []}); 

In this way, you can keep using one map with one renderer for all routes.

like image 103
thomaux Avatar answered Sep 20 '22 13:09

thomaux


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); 
like image 42
Tomik Avatar answered Sep 20 '22 13:09

Tomik