Use Geocode()
for two purposes:
to get the GPS coordinates of an address;
to "cleanse" an address: correct typos and fill in missing components like county or zip code.
The "cleansed" address is essentially the address that has been immediately reverse-geocoded from the coordinates.
How to use
Use the function in the following way:
Geocode(address)
Geocode(address, params)
Input
address
(text): the address that needs to be geocoded or cleansed.
params
(optional): a JSON-object containing a language key specifying a 2-letter language code that determines in which language to return the "cleansed" address. Example:
{"language": "en"}
See the list of available language codes here.
Output
A JSON-object containing the result of the geocoding. In all cases the result will contain the success
(bool) key indicating if geocoding was successful.
In case of successful geocoding, the output will contain the exact
(bool) key indicating if the input address specified a rooftop location or a larger region, the latitude / longitude key pair with the resulting coordinates, and - if available - the address object containing the "cleansed" address.
In case the input address specifies a region rather than a rooftop location, which may happen in case of an incomplete address with a missing house number or street address, the coordinates will contain the location of the geographic center of the region.
In case of a failed geocoding, the output will contain the message
key describing the error.
The full structure of the output object:
when geocoding has been successful and the "cleansed" address is available:
{
"success": false,
"exact": ...,
"message": null,
"latitude": ...,
"longitude": ...,
"address": {
"country": "...",
"countryShort": "...",
"state": "...",
"stateShort": "...",
"county": "...",
"countyShort": "...",
"city": "...",
"district": "...",
"street": "...",
"zip": "...",
"houseNumber": "..."
}
}
when geocoding has been successful but the "cleansed" address is not available:
{
"success": true,
"exact": ...,
"latitude": ...,
"longitude": ...,
"address": null
}
when geocoding failed:
{
"success": false,
"message": "..."
}
Example
Geocode(record.Billing_Address)
See also
Route() - get the traveling distance and time between two locations.
CurrentRoute() - get the traveling distance and time between the base record and the current match candidate (when used in a 'Match record' action's Rating formula) or the matched record (when used in 'Match record' action's Match actions) without explicitly specifying coordinate fields.
DirectDistance() - get the direct distance between any two locations in your Mapsly org's distance units
CurrentDirectDistance() - get the direct distance between the base record and the match candidate (when used in a 'Match record' action's Rating formula) or the matched record (when used in 'Match record' action's Match actions) without explicitly specifying coordinate fields.