开发者

Allow user to add directions on a map (google maps API)

I know you can programmaticaly add markers for directions on t开发者_开发百科he 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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜