The HubGEOAPI object (since v1.0.2.73) calls the Google Geocoding service to normalize an address and read its components (street, postal code, city, country...). It requires an active geolocation service: either ChronoScan credits or your own Google Cloud application with an API key, configured in the Administration tab.
It is available in every script. Successful ProcessAddressInfo requests consume credits (or are billed to your Google Cloud application).
Methods
|
Returns
|
Method
|
Description
|
|
string
|
GetAddressComponent
(string component)
Since v1.0.2.73
|
Returns a desired property from a successful ProcessAddressInfo request.
Parameters
component (string): check available properties
Allowed values: formatted_address, country_name, street, street_number, city, postal_code, latitude, lat (alias), longitude, lng (alias)
Returns: Property value
Example: see example 1 at the end of this page.
|
|
string
|
GetLastErrorText
()
Since v1.0.2.73
|
Returns last request error if any.
Returns: Error description if any, empty string if no error
Example
Dim err
err = HubGEOAPI.GetLastErrorText()
|
|
string
|
GetResponseText
()
Since v1.0.2.73
|
Returns the API response as a string.
Returns: API response
Example
Dim responseresponse = HubGEOAPI.GetResponseText()
|
|
short
|
ProcessAddressInfo
(string address, string country = "")
Since v1.0.2.73
|
Request to Google geocode service with a provided address and country (optional) and sets the response (json) inside the HubGEOAPI object.
Succesful ProcessAddressInfo requests consume credits or is under your Google Cloud app billing conditions.
Parameters
address (string): The address to be processed by Google Cloud
country (string) optional: Optional country param
Returns: 1 = Success, 0 = Error
Example: see example 1 at the end of this page.
|
Examples
Example 1 (GetAddressComponent, ProcessAddressInfo)
' ChronoScan HubGEOAPI
' since version 1.0.2.73
' It requires an active Google Geolocation service configured:
' Either a ChronoScan service account with credits or an external google cloud application with a valid API_KEY
Dim response
Dim request ' 1 => Ok, 0 => Fail
Dim prop
Dim lat
Dim lng
' from a static direction:
request = HubGEOAPI.ProcessAddressInfo("Calle Alcalá, 28080", "")
' Getting the address from an ocr field called 'Address' for example:
' requestSuccess = HubGEOAPI.ProcessAddressInfo(UserField_Address.value, "")
If request <> 1 Then
' getting the error
response = HubGEOAPI.GetLastErrorText()
msgbox response
else
' response will hold a full google Geocoding API response json
' response = HubGEOAPI.GetResponseText()
' Retrieving a specific property from the response json
' available properties:
' "formatted_address", "country_name", "country_code", "street", "street_number", "city", "postal_code",
' "latitude" or "lat", "longitude" or "lng", "place_id"
' example 1: get full address
prop = HubGEOAPI.GetAddressComponent("formatted_address")
msgbox "Full address: " & prop
' example 2: get coordinates
lat = HubGEOAPI.GetAddressComponent("lat")
lng = HubGEOAPI.GetAddressComponent("lng")
msgbox "Coordinates, latitude " & lat & " - longitude: " & lng
End If