Script to calculate multiple distances at one

1,570 views
Skip to first unread message

mhh

unread,
Feb 16, 2011, 6:28:00 AM2/16/11
to Google Maps JavaScript API v3
Hello group,

I am looking for a script using the google API that can calculate
several driving distances at once.

I have 25 different coordinates as starting points and 1 single
coordinate as the ending point. The script should calculate all 25
distances at once.

Could anybody help me if there is no script available ? I know it's
possible since I saw it on a website.

Thanks a lot !

Martin™

unread,
Feb 16, 2011, 6:44:15 AM2/16/11
to Google Maps JavaScript API v3
The Directions service can do that but NOT all 25 routes in one batch.
http://code.google.com/apis/maps/documentation/javascript/services.html#Directions

You'd have to request one route after another and watch you don't fall
foul of the Directions services' limits.
(Don't request too many routes in too short a space of time).

Can't you look at the source code of the site where you've seen 25
routes calculated at once to see how that site did it?

Martin.

Rafael

unread,
Feb 16, 2011, 6:52:45 AM2/16/11
to Google Maps JavaScript API v3
I have a similar need, but I ended up calculating the distances one by
one.
If you want, I can send you a code sample.

By the way, I'm aware that for the Public Google Maps API, it is not
allowed to use geocoding/directions features without showing a map.

Does that also apply to the Premier API?
I couldn't find this information on the terms of service.

Thanks in advance,

Rafael

On Feb 16, 9:44 am, Martin™ <warwo...@gmail.com> wrote:
> The Directions service can do that but NOT all 25 routes in one batch.http://code.google.com/apis/maps/documentation/javascript/services.ht...

Diogo Outerelo da Silva

unread,
Feb 16, 2011, 5:56:48 PM2/16/11
to google-map...@googlegroups.com
Try the extendedApi...
you can use a latlng and call the function distanceFrom(latlng) to get the distance in meters... Just sum de results and get what you need.

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.




--
Atc,
Diogo

--

Chris Broadfoot

unread,
Feb 16, 2011, 6:21:55 PM2/16/11
to google-map...@googlegroups.com
Hi guys,

Could you file a feature request and link to it here so people can star it? This is how we measure user demand for a particular feature.

Thanks,

Ron

unread,
Mar 17, 2011, 11:10:09 PM3/17/11
to Google Maps JavaScript API v3
I'm actually trying to do the same thing (and I'll admit I'm not good
at javascript.. and this is my first time with the Google Maps API (ok
well maybe 2nd.. the other time was ages ago).

I have the map and all that working, but I'm trying to pull the start
location from MySQL using PHP (which is storing the info in an array
per row), and then trying to find a way to feed that into the Google
Maps API so the directions from the recorded starting points to the
single destination all show up on the same map. I'm having no luck and
am completely stuck

Thanks!

Ron
Reply all
Reply to author
Forward
0 new messages