Provides an endpoint to calculate distance between two points, cache the results, and provide the results as a function for Google Sheets.
- Clone this repo and install dependencies
npm i
- Create a new Firebase project @ http://console.firebase.google.com/
- Install the Firebase CLI https://firebase.google.com/docs/cli
- Enable the directions API in the Google Cloud Console https://console.cloud.google.com/marketplace/product/google/directions-backend.googleapis.com
- After enabling the Directions API, copy your API key
- From the command line, set this as a remote config value for your Firebase functions:
firebase functions:config:set google_api.maps_key="YOUR_API_KEY"
- Deploy functions from the
functions
directory vianpm run deploy
. Make note of the deployed function endpoint: https://console.firebase.google.com/project/[YOUR_PROJECT_ID]/functions/list
- Install the addon found in
src/appscript.js
by opening the Script Editor from your Google Sheet
- Set the
CLOUDFUNCTION_ENDPOINT
variable to the endpoint you've deployed via Firebase functions. - Save this file. You can now call the function with
==GOOGLEMAPS_DURATION(origin, destination)
You should enable billing notifications as a just-in-case measure. This script should cache data reliably but you never know!