@flatfile/plugin-enrich-geocode
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

@flatfile/plugin-enrich-geocode

The @flatfile/plugin-enrich-geocode plugin for geocoding addresses using the Google Maps Geocoding API. This plugin enables automatic geocoding of addresses, reverse geocoding of coordinates, and enrichment of location data within your Flatfile imports.

Event Type: listener.on('commit:created')

Features

  • Forward geocoding: Convert addresses to latitude and longitude coordinates
  • Reverse geocoding: Convert latitude and longitude coordinates to formatted addresses
  • Automatic geocoding based on available data
  • Customizable field mapping
  • Error handling for invalid inputs and API errors
  • Extraction of additional location components (country, postal code)

Parameters

The enrichGeocode function accepts a configuration object with the following properties:

  • sheetSlug (string): The slug of the sheet containing address data. Default: "addresses"
  • addressField (string): The field name for the address input. Default: "address"
  • latitudeField (string): The field name for latitude. Default: "latitude"
  • longitudeField (string): The field name for longitude. Default: "longitude"
  • autoGeocode (boolean): Whether to automatically geocode records. Default: true

Installation

To install the plugin, use npm:

npm install @flatfile/plugin-enrich-geocode

Example Usage

import type { FlatfileListener } from "@flatfile/listener";
import enrichGeocode from "@flatfile/plugin-enrich-geocode";

export default function (listener: FlatfileListener) {
   listener.use(
      enrichGeocode(listener, {
         sheetSlug: 'customer_addresses',
         addressField: 'full_address',
         latitudeField: 'lat',
         longitudeField: 'lng'
      })
   );

   // ... rest of your Flatfile setup
}

Package Sidebar

Install

npm i @flatfile/plugin-enrich-geocode

Weekly Downloads

5

Version

0.3.1

License

ISC

Unpacked Size

42.1 kB

Total Files

12

Last publish

Collaborators

  • sarocu
  • dboskovic
  • jmmander
  • bangarang
  • carlbrugger
  • flatfileinfra
  • flatderek
  • bigcountrycrane
  • rjhyde
  • sambarrowclough
  • meritmalling
  • mmccooyyy
  • hjordan1990
  • nlazaris