Google Map Route: Single origin with multiple destinations

5,031 views
Skip to first unread message

Webista

unread,
Oct 24, 2011, 11:30:41 PM10/24/11
to Google Maps JavaScript API v3
Is there any way or functions in Google map that allows you to have a
single origin with multiple directions?

e.g.

A --> B
A --> C
A --> D
So far what I did was this, using waypoints:

A --> B --> A --> C --> A --> D
But the problem with that solution is that, every destination goes
back to the origin.(B to A, C to A)

What I want is origin "to destinations only" without showing routes of
the destination going back to the origin just to go to the next
destination like the first example.

Thanks.

MymsMan

unread,
Oct 25, 2011, 5:41:01 AM10/25/11
to google-map...@googlegroups.com
You can call the directions service multiple times and then create multiple directions renderer objects to display each of your routes.

Vasile Cotovanu

unread,
Oct 25, 2011, 6:22:22 AM10/25/11
to google-map...@googlegroups.com
Isn't Google Distance Matrix API what you need ? 

Webista

unread,
Oct 25, 2011, 9:35:12 PM10/25/11
to google-map...@googlegroups.com
Hi Vasile, thanks. I'm trying it now, hope it'll work.

Barry Lavides

unread,
Oct 25, 2011, 9:52:42 PM10/25/11
to google-map...@googlegroups.com
I just tried it, but the problem with distance matrix is it does not return detailed route information like the DirectionsService, which is what I need.

Vasile Cotovanu

unread,
Oct 26, 2011, 2:22:49 AM10/26/11
to google-map...@googlegroups.com
Then call DirectionsService.route() 3x and store the results in an array. Watch out because the request is asyncronous, so you need some kind of a mechanism that is triggered at the last successful DirectionsService call.  Something like http://pastie.org/2760389

mauro mauro

unread,
Feb 16, 2012, 12:35:28 AM2/16/12
to google-map...@googlegroups.com
Hi sir, Can I ask for your code, I find your code very useful to what I need, thanks very much, please bear with me

mauro mauro

unread,
Feb 16, 2012, 12:35:59 AM2/16/12
to google-map...@googlegroups.com
P.s, my mail is iiim...@yahoo.com

haak...@gmail.com

unread,
Jul 21, 2016, 7:56:02 PM7/21/16
to Google Maps JavaScript API v3, vasile....@gmail.com
Hi, on of my clients also wants the same thing.. multiple destination in just one display. Can you please post the sample code. It would be very grateful. Thanks


Reply all
Reply to author
Forward
0 new messages