Skip to main content
Function Geocode()

Geocode your address into GPS coordinates, and "cleansed" address (reverse-geocoded from the coordinates)

Sergey Shurygin avatar
Written by Sergey Shurygin
Updated over 2 years ago

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

Did this answer your question?