Learn Learn
August 05, 2021

Guide to creating a
Google Maps API key

Google Maps API
August 05, 2021

Share

Twitter Icon LinkedIn Icon

Why Google Maps?

Google's Maps service has been the number 1 in maps and navigation for years and is used by tens of millions of users every day.

No wonder, if you ask me. The maps and addresses are up to date and the entire Maps service is available to everyone free of charge. Anyone can access the maps, the pictures, the ratings, but also the address data from anywhere in the world.

Added to this are the reliability and the highest possible stability of the service. And because the map service belongs to the Google Corporation, it is constantly being developed and will remain so in the coming years.

Why do I need a Google Maps API key?

Google's map service is primarily intended to provide added value to the end user. However, the service can also be used for commercial purposes, e.g. to validate a customer's address entry and correct it if necessary.

For this purpose, Google provides an API, which can be used by anyone. Assuming that one is in possession of this API key. The key and the use of the API is virtually free. There is a limit of accesses, which is 50-1000 QPS (calls per second). But I doubt that these limits will ever take effect in the normal case. More about the quota limits can be found here.

If you have an API key, it can be used for various purposes. A good example would be our plugin Shipping Maps Widget, which displays a map view of the customer's shipping address on the last order confirmation page (so-called Thank You Page).

Show shipping map on Thank You page

With our extension you can easily display the customer's shipping address when he enters the last checkout step. This is a small gimmick to increase the customer's satisfaction.

Our plugin uses the Maps API to validate the delivery address. This is important because we want to decide whether the customer address can be correctly resolved and later displayed as a concrete pin on the map.

Where can I get a Google Maps API key?

Below I will explain to you how to get this key in five simple steps. You don't need any technical knowledge to perform the steps.

1. Register at the Google Compute Platform (GCP)

To register at GCP, you only need a Google Account. The registration is free and without obligation. Only a valid phone number and credit card are required for registration.

Follow this link and click on the blue button in the upper right corner.

Google Compute Platform Registration
Google Compute Platform Registration

Google will even give you a $300 credit that can be spent on the entire GCP suite.

After registering at GCP, you only need to create a project. Projects are a kind of hard separation between resources. You could do almost everything you do on Compute Cloud in one project. But I prefer the multi-project strategy. Every technical solution, no matter how small, is implemented in a separate project.

2. Follow to the Google Maps Platform section

After you have successfully registered, click on this link and you will directly enter the right section. This is the overview of all your keys that you have created in your project. You can manage, edit or delete them here.

Overview over all your Google Maps API keys
Overview over all your Google Maps API keys

3. Create a new key

Click the "Create Credentials" button at the top and select "API Key".

Create a new key
Create a new key

And promptly a new entry with a randomly generated API key is created. In our example it is "Api key 2", in the right column the key code is stored.

List of all existing keys
List of all existing keys

Google will still ask you if you want to restrict the use of this key. For example, you could allow the use of your key only from certain IP addresses.

4. Restrict API key

Of course, we want to do this so that the key is allowed to access only the APIs we want. To do this, simply click the pencil in the list on the right to edit the key.

In the following screen, we select the "Restrict key" item under the "API Restriction" option and limit our newly created key to the two APIs "Geocoding API" and "Maps Embed API".

Selection of APIs for enabling
Selection of APIs for enabling

Now just confirm everything, save and close. The API key is ready and can be used directly.

5. Store the key in your desired application

And you're done. You can now copy the key and store it wherever you need it. If we stick to our example with the Shipping Maps Widget Plugin, a key must be stored in the Shopware administration area so that our plugin can work properly.

To do this, go to the extensions, select our plugin "Maps Widget for Shipping Address" and open the configuration screen.

Plugin overview in Shopware administration
Plugin overview in Shopware administration

You can paste the key into the desired field and save it. Now we are done and the plugin will use the API key to validate the shipping addresses on Google Maps.

Configuration screen of our Shipping Maps Widget Plugin
Configuration screen of our Shipping Maps Widget Plugin

If the customer buys something in the store now, he gets the delivery address displayed as a map view afterwards. Pretty cool feature, don't you think? And all this is made possible thanks to the Google Maps API key.

Maps widget on the Thank You page
Maps widget on the Thank You page

Conclusion

The Google Maps API is a powerful tool. Without a doubt, Google dominates the current market with this solution. The map material and the address data are almost always up to date and this is exactly the opportunity you can take advantage of.

Awesome, share it

Contact Us

Want to Talk?

Get to Know