Routing Multiple Points

Topics: General
Sep 30, 2011 at 10:23 PM

Is it possible with GMap, to route multiple points? Most of the example I see have just 2 points. I have a list of stops (all in random order) and would like to order them (sort of route optimization at basic), giving a starting point. Is this possible?

Thanks.

Oct 1, 2011 at 11:48 AM

everything is possible ;}

Oct 3, 2011 at 9:16 PM
Edited Oct 3, 2011 at 9:17 PM

This would be very handy :-) I have been looking at the TSP algorithm and was going to use that for the time being

Oct 4, 2011 at 4:05 PM

If you have I think upto 25 points so 23 waypoints on a return to base then this is the place to look

http://code.google.com/apis/maps/documentation/directions/#XML

Oct 5, 2011 at 2:49 PM

delcom5,

build up your url string like

http://maps.googleapis.com/maps/api/directions/xml?origin=Liverpool,UK&destination=Birmingham,UK&waypoints=optimize:true|Leeds,UK|Birkenhead,UK|stoke-on-trent,UK&sensor=false

then search for

<waypoint_index>1</waypoint_index><waypoint_index>0</waypoint_index><waypoint_index>2</waypoint_index>

this will give you the waypoints that have been sorted, the important part is optimize:true

then all you have to do is route from waypoint to waypoint, not the best idea but it will work :-)

May 2, 2012 at 11:16 AM

Where about in the code does the URL string go and get executed?

Thanks.

May 2, 2012 at 11:25 AM

in googlemap provider

May 3, 2012 at 3:13 PM

Thanks radioman, but specifically where in the googlemap provider?

May 3, 2012 at 3:25 PM

debug, routing function, without testing you can't add this feature anyway

May 3, 2012 at 3:46 PM

Ok, thanks for the super quick reply radioman - great service :-)

If I go and add this (by overloading the existing function), it will be overwritten on your next updated version I download - is that correct? If yes, if I do it, how can I get it merged into your live source so I don't loose these changes, and I'd like to make it available to other users as I'm sure it would be useful to many other users.

Many thanks

Charlotte :-)

May 3, 2012 at 4:28 PM

yes, thats the point!

you can make a fork or just share it here, i'll add it

Jan 20, 2013 at 5:18 PM

done!