11

I would like to achieve something whereby I have a spreadsheet such that the columns are:

  • Column A - place name
  • Column B - place name
  • Column C - distance by road between places in columns A and B
  • Column D - travel time by road between places in columns A and B

I thought it might be possible using Google Docs' spreadsheet and its 'Google' functions, but I've not found any that might do the trick.

In the end I could knock up an app to do it using the Google Maps API but would rather avoid it if I can.

migrated from superuser.com May 5 '11 at 18:48

This question came from our site for computer enthusiasts and power users.

4

MapQuest seems to be the best bet, as they have a URL-based API for directions, whereas Google Maps seems to be a JavaScript library.

This worked for me in a Google Docs Spreadsheet. This one gets the distance (miles):

=importXML("http://mapquestapi.com/directions/v1/route?key=YOUR_KEY_HERE&outFormat=xml&from=" & A2 & "&to=" & B2,"//response/route/distance")

And this one gets the time (formatted in hh:mm:ss):

=importXML("http://mapquestapi.com/directions/v1/route?key=YOUR_KEY_HERE&outFormat=xml&from=" & A2 & "&to=" & B2,"//response/route/formattedTime")

where A2 is the origin and B2 is the destination.

You have to get an API key from MapQuest and replace the value YOUR_KEY_HERE with it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.