Closed Thread
Results 1 to 16 of 16

Excel - Google Maps API Distance Calculator

  1. #1
    Registered User
    Join Date
    02-07-2012
    Location
    Internet
    MS-Off Ver
    None
    Posts
    13

    Excel - Google Maps API Distance Calculator

    Hello,

    I have read soo many different threads on making a distance calculator, but I have found that most of them do not work now due to Google changing the HTML on the Maps pages.

    I know that there is a way to make the same thing with the Google API (http://maps.googleapis.com/maps/api/...N&sensor=false)

    It can be done by reading the XML and displaying the results within the Steps/Distance/Values tags.

    I read about it here: http://stackoverflow.com/questions/3...xcel-web-query

    I have found a copy of one that is on Google Docs where the function need to read XML is readily available here: http://winfred.vankuijk.net/2010/12/...e-spreadsheet/

    But I am still struggling to make a working version that isnt based on Google Docs.

    Thanks in advance for all of your help.

    Phil.
    Last edited by philipryoung; 02-07-2012 at 06:42 AM.

  2. #2
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Excel - Google Maps API Distance Calculator

    Hi,

    Code provided by site: http://stackoverflow.com/questions/3...xcel-web-query
    works fine.
    Please Login or Register  to view this content.
    Check if you have refereces to proper XML Active-X (in VBE menu->Tools->References->Microsoft XML, v6.0)
    Best Regards
    MaczaQ
    ---------------------------------------------------------------------------------------------------------------------------
    If you are satisfied with the solution(s) provided, please mark your thread as Solved
    If you are pleased with my answer consider to rate it. To thank someone who has helped you, click on the star icon below their name.
    - This way you will add him some reputation points ... thanks in advance.

  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Excel - Google Maps API Distance Calculator

    What's wrong with the solution I provided on your explicit request (by PM) over here ?



  4. #4
    Registered User
    Join Date
    02-07-2012
    Location
    Internet
    MS-Off Ver
    None
    Posts
    13

    Re: Excel - Google Maps API Distance Calculator

    Hello,

    It seems to only work for areas in Netherlands.

    I was also interested in seeing if it would work with the Google API insteas (as I imagine this would run a lot cleaner).

    Thanks for the help.

  5. #5
    Registered User
    Join Date
    02-07-2012
    Location
    Internet
    MS-Off Ver
    None
    Posts
    13

    Re: Excel - Google Maps API Distance Calculator

    @maczaq

    I saw that code but I wondered if someone who knew what they were doing could adapt the code so that it would be used as a function within the worksheet. This way I could define the start and end destination from 2 different cells and then display the results in a 3rd cell.

    Thanks again for the help.

    Phil.

  6. #6
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Excel - Google Maps API Distance Calculator

    Hi philipryoung,

    I think you always should post your messages in public part of forum.

    SNB provieded very fine solution. Try to work a bit with it.

    For example I've tried to check zip codes in Poland - only one change which had to be done it was change source to google maps
    from
    Please Login or Register  to view this content.
    into
    Please Login or Register  to view this content.
    Just keep try to modify SNB's file into your needs (http://www.excelforum.com/attachment...6&d=1328624457)

  7. #7
    Registered User
    Join Date
    02-07-2012
    Location
    Internet
    MS-Off Ver
    None
    Posts
    13

    Re: Excel - Google Maps API Distance Calculator

    Hello,

    I have finally got it working thanks to all of your help!

    I would like to turn it into a UDF where I can call it using =GetDistance(A1, A2) where A1 contains start destination and A2 contains end destination and the function will return the distance. Im not to bothered about the time part at the moment.

    If anyone could shed some light on how to convert this brilliant code to a UDF then please help.

    I have attached what I am currently using. - __postcode country google snb 2.xlsm

    Please Login or Register  to view this content.
    Thanks again everyone

    phil.

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Excel - Google Maps API Distance Calculator

    you need something like:
    Please Login or Register  to view this content.
    Last edited by Kyle123; 02-08-2012 at 05:51 AM.

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Excel - Google Maps API Distance Calculator

    Although I would prefer:
    Please Login or Register  to view this content.
    Last edited by Kyle123; 02-08-2012 at 06:02 AM. Reason: Neatening up

  10. #10
    Registered User
    Join Date
    02-07-2012
    Location
    Internet
    MS-Off Ver
    None
    Posts
    13

    Re: Excel - Google Maps API Distance Calculator

    Works like magic,

    Thank-you very much! Finaly got there after about a week of not giving up.

    I am just wondering whether the same thing can be applied through the Google API?

    Regards,
    Phil.

  11. #11
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Excel - Google Maps API Distance Calculator

    yes, but it's not much faster and breaches the terms and conditions of the service

  12. #12
    Registered User
    Join Date
    03-19-2013
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: Excel - Google Maps API Distance Calculator

    Interestingly the code is only working if source address is based in the UK.
    I am looking for the same working in the netherlands. Unfortunately changing the url to *.nl is not working.
    Any ideas?

  13. #13
    Registered User
    Join Date
    04-12-2013
    Location
    Cincinnati, Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: Excel - Google Maps API Distance Calculator

    Hi, new user here.

    How can I modify this code to use the US Google Maps?
    Also, I would like to setup name shortcuts (ie Name = Complete address of location) and have Google Maps be able to calculate, is that possible?

    Thank you in advance!

  14. #14
    Registered User
    Join Date
    03-11-2014
    Location
    Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Excel - Google Maps API Distance Calculator

    Very interesting function! Only thing is that I get an error for "can't find project or library" (Excel 2010) and adding the Xml 6.0 as a reference does not solve it

  15. #15
    Registered User
    Join Date
    03-11-2014
    Location
    Amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Excel - Google Maps API Distance Calculator

    Previous Error I got for the Excel as posted in the tread - when I build a customfunction - I always get "0" as an asnwer...

  16. #16
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,601

    Re: Excel - Google Maps API Distance Calculator

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1