Hi,
I am trying to replicate a project posted by Will Shank back in January 2014.
I am using Xojo 2019 R1. This is what I have done as per Will’s Code:
-
Added TextField and called it addressFld
-
Added TextField and called it latLonResultsFld
-
Added a Button and called it downloadLatLonButton
-
Added a URL connection. I can’t find the HTTPSocket. ( I have no idea where that is.) Called it latLonSocket
-
On the button I added this code:
[code]Dim head, query, tail As String //build url
head = “http://maps.googleapis.com/maps/api/geocode/xml?address=”
query = addressFld.Text.Trim.ReplaceAll(" ", “+”)
tail = “&sensor=false”
latLonSocket.Get(head + query + tail) //request data[/code]
- On the latLonSocket ContentReceived event (There is no PageReceived event) I added this code.
[code]Dim doc As New XmlDocument(content) //parse to tree
Dim lat, lon As String
lat = xqlFirstInnerText(doc, “//geometry/location/lat”) //extract values
lon = xqlFirstInnerText(doc, “//geometry/location/lng”)
latLonResultsFld.Text = "latitude: " + lat + ", longitude: " + lon //show
[/code]
7) I created a Method and called it xqlFirstInnerText
Function xqlFirstInnerText(doc As XmlDocument, query As String) As String
dim nl As XmlNodeList = doc.Xql(query)
if nl.Length = 0 then return ""
dim n As XmlNode = nl.Item(0).FirstChild
if n = nil or not n IsA XmlTextNode then return ""
return n.Value
End Function
When I run it I get the error:
Window1.downloadLatLonButton.Action, line 6
Type “URLConnection” has no member named “Get”
latLonSocket.Get(head + query + tail) //request data
I’m not sure hat I am doing wrong here. The project is attached here.
If anyone can help, I would appreciate it.