Results 1 to 5 of 5
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Google maps XML


    I'm considering adding a feature to our front end that lets you put in two suburbs and then an XML feed from Google (or json) the distance between them in km/Miles after requesting the info from google

    Therefore I would need a way to

    send the two address requests to google then receive an xml feed, so some sort of interaction

    handle the xml

    can Access do this? Has anyone ever tried this before?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by orange View Post
    http://www.access-programmers.co.uk/...d.php?t=225339Not XML specifically but look at this one

    There is someone who I believe has made an XML one, using createObject("MSXML2.XMLHTTP")

    they uploaded their database and it works like I want it to so I will post the code once completed

    Thanks orange!!

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by orange View Post
    http://www.access-programmers.co.uk/...d.php?t=225339Not XML specifically but look at this one
    Update: the code I have is working - I am getting distance in time and in the format I want. All within access. Will post code once finished and clean it up for everyone to use.

  5. #5
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Of course this can be changed to get KM, time etc

    Code:
    'gets google value of time distance in seconds
    Public Function googleTravelTime(AddressOrigin As String, AddressDestination As String) As Long
    
    
    
    
    
    
    Dim objHttp As Object
    Dim strURL As String, strDisType As String, strHTML As String, strOrigin As String, strDest As String
    
    
    Dim lTopicstart As Long, lTopicend As Long
    Dim strDist As String, strDura As String, lngDuraV As String
    
    
    
    
    If IsMissing(AddressOrigin) Then
        strOrigin = ""
    Else
        strOrigin = AddressOrigin
    End If
    
    
    
    
    If IsMissing(AddressDestination) Then
        strDest = ""
    Else
        strDest = AddressDestination
    End If
    
    
        On Error GoTo GoogleError:
        strDisType = "metric"
    
    
        'GMap webservice with XML output
        strURL = "http://maps.googleapis.com/maps/api/distancematrix/xml?origins="
        strURL = strURL & URLEncode(strOrigin) & "&destinations=" & URLEncode(strDest)
        strURL = strURL & "&units=" & strDisType & "&sensor=false"
    
    
        Set objHttp = CreateObject("MSXML2.XMLHTTP")
        
        objHttp.Open "GET", strURL, False
        objHttp.send
        strHTML = objHttp.responseText
        Set objHttp = Nothing
    
    
        Debug.Print strHTML
        'get seconds
        'Parse the xml to get the Duration (Time value)
        lTopicstart = InStr(strHTML, "<duration>")
        lTopicend = InStr(strHTML, "</duration>")
        strDuraV = Trim(Mid(strHTML, lTopicstart + 10, lTopicend - lltopicstart - 10))
        'Debug.Print Len(strDura) & "[" & strDura & "]"
        lTopicstart = InStr(strDuraV, "<value>")
        lTopicend = InStr(strDuraV, "</value>")
        strDuraV = Mid(strDuraV, lTopicstart + 7, lTopicend - lTopicstart - 7)
        
        
        googleTravelTime = CLng(strDuraV)
        
        'in seconds
        'Debug.Print googleTravelTime
        Exit Function
    
    
    GoogleError:
    MsgBox "error with google"
    Exit Function
    
    
    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Web Browser Google Maps Error, Script Error
    By trini46petes in forum Access
    Replies: 2
    Last Post: 03-03-2015, 06:36 AM
  2. Google Maps in webbrowser control
    By bfc in forum Forms
    Replies: 10
    Last Post: 08-27-2014, 10:53 PM
  3. Replies: 7
    Last Post: 08-12-2014, 07:20 PM
  4. Google maps from form
    By JeroenMioch in forum Programming
    Replies: 11
    Last Post: 03-04-2014, 10:53 AM
  5. using google maps address into a text field
    By thanosgr in forum Programming
    Replies: 5
    Last Post: 04-26-2012, 03:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums