dbTalk Databases Forums  

Consume Geodata web service

comp.databases.ms-access comp.databases.ms-access


Discuss Consume Geodata web service in the comp.databases.ms-access forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Lauren Quantrell
 
Posts: n/a

Default Consume Geodata web service - 01-03-2008 , 10:01 AM






I'm trying to get geodata from Google or Yahoo's web service using an
Access (2000-2003) application. I have this working fine in vb.net but
have no idea how to do this in Access.

I'm looking for any example code from someone who has done this in
Access, or for any code examples of using HTTP POST from Access so I
can see how this is done.

These web services return straight XML and do not use SOAP and do not
use expose a WSDL.

Any help is appreciated.
lq

Reply With Quote
  #2  
Old   
rkc
 
Posts: n/a

Default Re: Consume Geodata web service - 01-04-2008 , 01:15 AM






Sub Test_GoogleGeoRequest()
Dim addr As String

addr = "11 Place Antonin Poncet, Lyon, FR"
'addr = "5 High Street, Galway, IE"
'addr = "41 Mill St,Marion,NY"
'addr = "Stanley St,Belleville,ON"

If Not MakeGeoRequest(addr) Then
MsgBox "Request failed", vbCritical, "F'd Up Request"
Exit Sub
End If

If HasData Then
Debug.Print Address 'formatted address
Debug.Print CountryNameCode
Debug.Print AdministrativeAreaName 'state name if US address
Debug.Print SubAdministrativeAreaName 'county name if US address
Debug.Print PostalCode 'zip code if US address
Debug.Print Latitude, Longitude
Else
MsgBox "Status Code: " & StatusCode & vbCrLf _
& "No information was found for" & vbCrLf & addr, _
vbInformation, "Address Was Not Found"
End If

End Sub


<GoogleGeoRequest Module>

Option Compare Database
Option Explicit

Const Map_Api_Key = "yourKeyHere"
Private m_Xml As String
Private doc As MSXML2.DOMDocument
'Private doc As Object

Public Property Get RawXML() As String
RawXML = m_Xml
End Property


Public Property Get CountryNameCode() As String
CountryNameCode =
GetNodeText("//Placemark/AddressDetails/Country/CountryNameCode")
End Property

Public Property Get Address() As String
Address = GetNodeText("//Placemark/address")
End Property

Public Property Get AdministrativeAreaName() As String
AdministrativeAreaName = _

GetNodeText("//Placemark/AddressDetails/Country/AdministrativeArea/AdministrativeAreaName")
End Property

Public Property Get SubAdministrativeAreaName() As String
SubAdministrativeAreaName = _

GetNodeText("//Placemark/AddressDetails/Country/AdministrativeArea/SubAdministrativeArea/SubAdministrativeAreaName")
End Property

Public Property Get PostalCode() As String
PostalCode = _

GetNodeText("//Placemark/AddressDetails/Country/AdministrativeArea/SubAdministrativeArea/PostalCode/PostalCodeNumber")
End Property

Public Property Get StatusCode() As String
StatusCode = GetNodeText("//Status/code")
End Property

Public Property Get HasData() As Boolean
HasData = StatusCode = "200"
End Property

Public Property Get Coordinates() As String
Coordinates = GetNodeText("//Placemark/Point/coordinates")
End Property

Public Property Get Latitude() As String
Latitude = Split(Coordinates, ",")(1)
End Property

Public Property Get Longitude() As String
Longitude = Split(Coordinates, ",")(0)
End Property

Public Function MakeGeoRequest(Address As String) As Boolean
Dim msXml As MSXML2.XMLHTTP
Set msXml = New MSXML2.XMLHTTP
'Dim msXml As Object
'Set msXml = CreateObject("Microsoft.XMLHTTP")

On Error GoTo errHandler

msXml.Open "GET", "http://maps.google.com/maps/geo?q=" & Address &
"&output=xml&key=" & Map_Api_Key, False
msXml.setRequestHeader "Content-Type", "text/html"
msXml.send

'Set doc = New MSXML2.DOMDocument
Set doc = CreateObject("MSXML2.DOMDocument")
m_Xml = msXml.ResponseText
doc.loadXML m_Xml

MakeGeoRequest = True
Exit Function

errHandler:
'return false
End Function

Private Function GetNodeText(path As String) As String
Dim n As IXMLDOMNode
'Dim n As Object
Set n = doc.selectSingleNode(path)
If Not n Is Nothing Then
GetNodeText = n.Text
End If
End Function

</GoogleGeoRequest Module>

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.