views:

152

answers:

2

I know you can programmaticaly add markers for directions on the map. But how do you let the user do that? Like on the Google maps site, you just right click and then click on 'directions from/to here' and the marker is added. This functionality seems to be absent from the API.

EDIT: Maybe I wasn't clear enough. I am not talking about the API functions. I just want to enable the user to get the directions menu that you get once you right click. Look at the the google maps site for reference.

+4  A: 

Google map API has directions functionality called GDirections. You can see directions example for more info.

antyrat
+1  A: 

There is nothing built into the API to show the "Directions from here" and "Directions to here" context menus, you will need to build that functionality yourself.

You can handle * rightclick* event on the map object to get your context clicks (and the associated location) and then pass the locations into the Directions Service .

N.B. It is now recommended that you use the Version 3 Google Maps API (Directions Service) rather than the Version 2 API suggested in the previous answer (GDirections).

Cannonade