Adding more than one destination on google map using googlemap javascript apiv3
I want to add more than one destination keeping the same source and get route directions to all destinations in a single time...here is the source开发者_运维知识库 code i want to modify it Google map driving direction source code for their example?
please suggest me, thanks
There still doesn't seem to be a documented way of doing this, but this has worked for me:
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=st.%20louis,mo&daddr=washington,dc%20to:chicago,il%20to:new%20york,ny");
startActivity(intent);
You can call the intent for VIEW and use the url for google maps via the browser. The important querystring items are the following:
saddr=the starting address daddr=destination address
the magic happens in the daddr item, which allow you to add a "to:" to add multiple directions. Example: "daddr=washington,dc%20to:chicago,il%20to:new%20york,ny" (%20 represent spaces) this says to follow washington,dc to chicago,il to the final destination which is new york, ny.
saddr would be the start to this process, so before washington,dc.
If you need more points, just keep adding "to:" in between points
This method will bring up a window giving you the choice of using the browser or the google maps app on the phone, so i routed mine to just assume the google maps app exist and to always use it (this is up to you if you want to go that way or not -- typically, not the best way, but it's the best for not bugging the user with what may be considered a redundant question).
I hope this helps and points you into a direction you can use.
BTW: This url will also work on the browser too! I only posted the code in android because the question was tagged as such.
I would suggest using Google Maps Waypoints.
精彩评论