How to Get a Google Maps API Key: Retrieve Latitude and Longitude from Addresses in Google Sheets

Have you ever wanted to automatically retrieve latitude and longitude from addresses to enhance data analysis or improve workflow efficiency?
With the Google Maps API, this becomes possible.
However, to get started, you first need to obtain an API key.
In this article, we’ll walk you through the step-by-step process of obtaining your Google Maps API key.

About Google Maps API
The Google Maps API is a platform provided by Google that allows you to access various map-related features.
It supports a wide range of applications, including map display, route navigation, and retrieving location information.
To meet diverse mapping needs, Google offers specialized APIs tailored to specific purposes.
For example, the Google Maps API is commonly used in the following scenarios:
- Geocoding API: Converts addresses to latitude and longitude, and vice versa.
- Directions API: Provides route navigation and calculates travel distances.
- Places API: Searches for nearby places and retrieves detailed information about them.
The Geocoding API specializes in retrieving latitude and longitude from addresses (known as “geocoding”).
In this guide, we’ll focus on obtaining the API key required to use the Geocoding API, one of the many features offered by the Google Maps API.
Steps to Obtain a Google Maps API Key
Obtaining a Google Maps API Key

Visit the official Google Cloud Platform (GCP) website.
If you’re using GCP for the first time, click on “Get Started for Free” and log in with your Google account or create a new one.
You’ll receive $300 in free credits to use for various GCP services, including the Google Maps API.

After logging in, click on “Select a Project” located in the top-left corner of the screen.
Create a new project here to begin setting up and preparing for API usage.

Click on “New Project” to create a new project.

Choose a name for your project and click the “Create” button.
- Example: My Maps Project
- A default project name will be pre-filled, but you can change it to any name you like.

Go to “Select a Project” and choose the project you just created.

After selecting your project, click on “APIs & Services” from the menu.

Next, click on “Library” under the APIs & Services section.

Use the search bar to look for “Geocoding API”.


From the search results, select “Geocoding API”.
Click the “Enable” button to activate the API.

Navigate to “APIs & Services” > “Credentials” from the menu.
Click “Create Credentials” and select “API Key”.

Copy the generated API key.
Save it securely for later use in Google Apps Script or other integrations.
Saving the API Key in Script Properties
To use the API key in Google Apps Script (GAS), store it in the script properties.
- Security:
-
By storing the API key in script properties, you avoid hardcoding it into the script, reducing the risk of exposure to third parties.
- Ease of Maintenance:
-
If the API key needs to be updated, you can simply modify the property without editing the script itself.
- Reusability:
-
The same API key can easily be reused across different functions or projects without duplicating code.

Open your Google Sheets, go to the “Extensions” menu, and click on “Apps Script” to open the editor.

In the Apps Script editor, select “Project Settings”.

Select “Add Script Properties”.

Enter the key name (e.g., “Maps_API_KEY”) and the API key.
Once entered, click “Save Script Properties”.
Free Tier for Google Maps API
The Google Maps API offers a free usage tier of $200 per month.
This allows many projects to operate without incurring any costs.
For more details, visit the Google Maps Platform.
Conclusion
You’ve now successfully obtained your Google Maps API key.
With this API key, you can not only retrieve latitude and longitude from addresses but also leverage other features of the Google Maps API.
In the next article, we’ll show you how to integrate this API key with Google Sheets to fetch latitude and longitude from addresses. Stay tuned!

Our company offers support for improving work efficiency through the use of Google Apps Script.
If you need assistance with Google Apps Script customization or error resolution, please feel free to contact us.
We are fully committed to supporting your business improvements.
Contact us here
Comments