In this guide, we'll calculate the distance & time between pairs of locations using the Google Maps Distance Matrix API and the Data Fetcher Airtable extension. This tutorial is 100% no-code. We'll create a Google Maps API key and use it to calculate distance & time. Finally, we'll see how to schedule this to run automatically.
Install Data Fetcher from the Airtable marketplace. After the extension launches, sign up for a free Data Fetcher account by entering a password and clicking 'Sign up for free'.
On the home screen of the Data Fetcher extension, click 'Create your first request'. Requests in Data Fetcher are how you import data to or send data from your Airtable base.
On the create request screen in Data Fetcher, for Application, select 'Google Maps' to use the Airtable Google Maps integration.
Next, enter your API Key from the previous step.
For Endpoint, select 'Calculate distance and time between start and end locations'.
Enter a Name for your request, e.g. 'Import Distance & Time'. Then click 'Save & Continue'.
We want to use the values in the 'Origin' field for Origin location. Under Origin location, click the + button to insert a reference to the table.
A modal will open where we can create the table reference. For Field, select 'Origin'.
For Run for every record in view, select 'To process'.
Click 'Confirm'.
The Origin location now has a reference to our table.
Do the same for Destination location to create a reference to the 'Destination' field.
Select the Units for the text representation of the distance. e.g. 'Metric' to get a value expressed in km.
Optionally set the Transportation mode you want to use. If you do not set this, 'Driving' will be used.
If you selected 'Transit' for Transportation mode, you can set the type of transit (public transport) by opening 'More options for this Google Maps endpoint' and setting the Transit mode.
Click 'Save & Run'.
The request will run and the Response field mapping modal will open. This is where you set which fields to import from the Google Distance Matrix API and how they should map to your output table. For each Google Distance Matrix API field, you can either import or filter it. For an imported field, you can set whether to map them to an existing field or create a new field.
Make sure you import 'Distance', 'Distance (metres)', 'Duration' & 'Duration (seconds)'. Then click 'Save & Run'.
Note that 'Distance' & 'Duration' are a text representation of the numerical values. You should use 'Distance (metres) and 'Duration (seconds)' if you need the numerical values.
Data Fetcher will create any fields that need to be created in the output table, then run the request and calculate the distance & time between each pair of locations in the 'Orders' table.
At the moment, you have to calculate the delivery time & distance by manually clicking the 'Run' button. Let's set them to update automatically by using Data Fetcher's scheduled requests feature.
In Data Fetcher, scroll to Schedule and click 'Upgrade'.
A new tab will open where you can select a plan and enter your payment details to upgrade.
Return to the Data Fetcher extension and click 'I've done this'.
Under Schedule click '+ Authorize'.
A window will open where you'll be prompted to authorize which Airtable bases you want Data Fetcher to have access to.
It's recommended to choose 'All current and future bases in all current and future workspaces' which means bases will always be authorized for future use.
Click 'Grant access'.
In Data Fetcher, Schedule this request will now be toggled on.
Select how often you want the request to run, e.g. 'Every 15 mins'. Click 'Save' The request will now run on the schedule and calculate the delivery distances and times automatically.
May 7, 2024
•Andy Cloke
•GoogleGoogle SheetsJun 20, 2023
•Rosie Threlfall
•GoogleNov 9, 2022
•Rosie Threlfall
•Google Maps