JsonGetGoogleLongitude(jsonData As String) As String
Get longitude of an address from Google Geocoding.
Convenience function in order to parse a JSON result
string from Google geocoding of an address.
You can get your Google API key here:
https://developers.google.com/maps/documentation/places/web-service/get-api-key
Parameters:
Name |
Type |
Description |
jsonData |
String |
The response of the webservice: JSON string like the example below |
Returns:
Type |
Value |
Description |
String |
"0.#######" |
longitude number of geolocated address |
Available in:
WindowMain |
WindowLink |
YES |
NO |
Example XojoScript:
Dim conID
As String = htmlConnection
If response
= "ERROR" Then
MsgBox("RequestHeader : " + response)
Return
End If
Dim streetNr
As String = "790"
Dim street As String = "Bündtenweg"
Dim city As String = "Kleinlützel"
Dim zip As String = "4245"
// use your own api
key here, in order to make this example work
Dim qry
As String = "https://maps.googleapis.com/maps/api/geocode/json?address="_
+ urlEncode(streetNr + "+" + street + "," + zip + "+" + city) _
+ "&key=AIzaSyAPoOR_9JMwSRB_M89-rbGa_KJHunhn766hUZcQE"
Dim response As String
response = htmlSendSync(conID, "GET", qry,15)
MsgBox(response)
Dim lat
As String = jsonGetGoogleLatitude(response)
Dim lng
As String = jsonGetGooglelongitude(response)
MsgBox(lat + " / " + lng)
Call htmlConnectionClose(conID)
|
|
JSON response string from maps.googleapis.com :