Automatically enrich location data using the Google Maps Geocoding API to convert addresses into geographic coordinates and vice-versa.
commit:created
), processing records in bulk before they are finalized.
enrichGeocode
function.
Parameter | Type | Default | Description |
---|---|---|---|
sheetSlug | string | "addresses" | The slug of the sheet you want the plugin to process |
addressField | string | "address" | The field key/name in your sheet that contains the address to be geocoded |
latitudeField | string | "latitude" | The field key/name in your sheet for the latitude value |
longitudeField | string | "longitude" | The field key/name in your sheet for the longitude value |
autoGeocode | boolean | true | A flag to enable or disable the automatic geocoding process |
bulkRecordHook
compatible with the Flatfile listener’s use()
method.
Parameters:
config
(object): Configuration object with the parameters described abovelistener.use()
and will be executed on the commit:created
event.
input
(object): Must contain either:
address
(string): The address to geocodelatitude
(number) and longitude
(number): The coordinates to reverse geocodeapiKey
(string): Your Google Maps Geocoding API keyGOOGLE_MAPS_API_KEY
or in Flatfile secrets with the name GOOGLE_MAPS_API_KEY
.
latitude
, longitude
, formatted_address
, country
, and postal_code
. Your Flatfile Sheet must be configured with these fields to store the enriched data. The latitude and longitude fields are configurable; the others are hardcoded.
ZERO_RESULTS
, REQUEST_DENIED
) or if the network request fails, the plugin will not halt the import process. Instead, it will add an error message to the specific record and field that caused the issue using record.addError()
. This allows users to see which records failed to geocode and why directly in the Flatfile UI.
listener.on('commit:created')
event. This means it processes data after a user has reviewed their data and clicked the final submit button, but before the data is sent to its final destination.