✨ Instagram integration is live! Tutorial

Convert Address to Latitude & Longitude in Airtable using Google Maps API

May 17, 2022Rosie Threlfall

In this guide, we'll convert addresses to latitude and longitude and import this data into Airtable using the Google Maps Geocoding API and the Data Fetcher Airtable extension. We'll create a Google Maps Geocoding API key and then use it to the find latitude & longitude of specified addresses. This will all be done without using code.

Create Output Table

  • Create a table in your base called 'Location'.
  • Add a field called 'Address' with type 'Single line text'. Add the addresses you want to look up latitude & longitude for in this field.
Latitude-table-setup.png

Create a Grid view in the 'Locations' table called 'Needs coordinates' with the following filters:

The 'Address' field is not empty.

Latitude-show-records.png

Get a Google Maps Geocoding API Key

To use the Google Maps Platform APIs you need to set up a Google Cloud project. Follow these steps to create a project with a billing account.

After creating your account you'll be given an API key. Or find your Google Maps API key here.

To convert addresses to latitude and longitude, we will use the Geocoding API. This is a paid feature from Google, please read this page to understand the costs involved with the Geocoding API.

Install Data Fetcher

Install Data Fetcher from the Airtable marketplace. Either sign up for a free Data Fetcher account or if you already have an account, sign in using the 'Have an account?' option in the bottom left of the box.

Group 1Data Fetcher Sign Up .png

Convert Addresses to Latitude and Longitude in Airtable

On the home screen of the Data Fetcher extension, click 'Create your first request'. Requests enable you to import or send data to and from Airtable using Data Fetcher.

click-create-your-first-request.png

On the create request screen in Data Fetcher, for Application, select 'Google Maps'.

google-maps-application-selected.png

Next, enter your API Key (see previous step to find this).

google-maps-authorization-api-key.png

For Endpoint, select 'Geocode - find latitude/ longitude from address'.

Latitude-endpoint.png

Enter a Name for your request, e.g. 'Find Latitude & Longitude'. Then click 'Save & Continue'.

Latitude-settings.png

Make sure the Output table & View are set to your 'Locations' table and 'Needs coordinates' view.

Latitude-output-table-view.png

For Address click the + button in order to create a reference to our output table in Airtable.

Latitude-address.png

A new window will open to create the table reference. For Field, select 'Address'. For Run every record select 'Needs coordinates'. (Or you could select an individual address.)

Click 'Confirm'.

Latitude-link-table.png

The 'Address' field is now referenced here:

Latitude-address-origins.png

Click 'Save & Run'.

Latitude-import-settings.png

Data Fetcher will send the request to the Google Maps Geocoding API and the Response field mapping window will open. This is where you set specific fields to import from Google Maps and how they should map to your selected output table in Airtable. For each Google Maps Geocoding API field, you can either import or filter it. For an imported field, you can set whether to map to an existing field or create a new one. You can also choose which field type to create. 

Use the 'Filter all' button to clear any fields that are pre-selected, then you can use the 'Find field' search bar to find the fields you would like to import. For this example, we will import the 'Lattitude' and 'Longitude' fields. 

Click 'Save & Run'.

Google Maps field mapping to Data Fetcher

Data Fetcher will now create any required fields in the output table, then run the request to the Google Maps API in order to lookup the latitude and longitudes for the addresses in the 'Locations' table.

Latitude-output-table.png