Those of us who’ve been at this for a few years remember how wonderful it was to embed a Google Maps map on a website. You just copied and pasted. But one fine day a concept came into our lives that changed everything: the API.
In this post I’ll explain how to sign up for the Google Maps API, whether to embed a map on your website or to work with tools such as Advanced Custom Fields.
How to sign up for the Google Maps API
To sign up for the Google Maps API, you need to go to the Google Maps developer platform. Specifically, we can go straight to the Google Maps section.

Of course, for this tutorial I’m assuming you have a Google account, which you’ll need to sign in to this platform, part of Google Cloud.
Since Google Cloud is a paid service, you need to sign up as a customer even if you already have a Google account.
So when you click Get started, it makes you take a somewhat redundant step: first it takes you to a screen with instructions, where you’ll see a similar Get started button.

If you’ve never signed up for Google Cloud Platform, a welcome modal window will appear asking you to accept the terms.
Of course, you need to choose the country you’re accepting the service from (Spain in my case) and agree to the Google Cloud Platform Terms of Service and the terms of any applicable services and APIs.
Also, if you want to receive regular news about this service by email, you can tick the next box, but that’s up to you.
Finally, you’ll need to click Agree and continue.

How much does Google Maps Platform cost?
Once you’ve confirmed this step, an information window tells you that you’ll get $300 of free credit to use within 90 days. This lets you practice with the platform for a while.
Personally, I’m a bit uneasy about being charged based on traffic and so on, especially since Google is very fond of changing prices. However, there’s no need to worry too much if your usage is typical, since embedding maps costs nothing.
Still, here’s a link where you can check the prices for this service, and you’ll see they’re not outrageous unless you run a huge site whose entire infrastructure is built on Google Maps.
In any case, in this step 2 of 3, all you need to do is add your phone number so they can send you an account verification code. But we’re getting ahead of ourselves.

Once you’ve added your phone number and received the code, in step 3 of 3 you’ll need to verify your payment information. This is where you have to commit (well, potentially at least).
So here you’ll need to add your billing details and enter the payment method. A tip: what I do is use one of those prepaid cards banks offer for online shopping.

After adding your payment and billing details, you’ll need to fill in a short survey about why you’re signing up for Google Maps Platform, what sector you work in, promising you’ll behave, that you behaved at school…

And finally the long-awaited moment arrives: Google gives you your API key.
As you’ll see, it’s an alphanumeric string of respectable length, which you must keep safe and not share around, because it’s the key that would let anyone use it at your expense, with you picking up the tab.
When it gives you the key, you can enable all the Google Maps APIs for the project you’re setting up the API for. This isn’t secure. In this case, since it’s an exercise, I did it, but in a normal project you should only enable the APIs you’re going to use.
It also lets you enable alerts to keep you informed about your monthly budget and whether you’re going over your free credit. You definitely want to enable this.

How to protect your Google Maps API key
A bit like two-factor authentication, and since the folks at Google are very clever, they’ve set up a system to protect your key using several methods, which I’ll show and list below.

There are 5 ways to protect a Google API:
- HTTP referrers (websites): the most common. Basically, the API will only run under your website’s URL or domain. It accepts wildcards so, as you can see in the example, you can add one wildcard for subdomains and another after the slash following the domain for any URL within it. If you like, you can be more restrictive.
- IP addresses (web servers, cron jobs, etc.): With this mode you can allow the API to be called only from a specific server by its IP, for example from your VPS. This would let every website on that hosting make calls to the API.
- Android apps: As you can imagine, this allows requests from a specific Android app.
- iOS apps: The same as the previous one, but for requests from an iOS app.
- API restrictions: With this option you can select which APIs that API key can access.
In my case, for the example I’m going to do, I used the referrer URL restriction and limited it to the domain wpgis.com, which is my test site.

How to rename a project in Google Cloud Platform
At the top left you’ll see My First Project, which, I don’t know about you, but I think is a rubbish name for a project.

If you had several projects, opening that selector would show you all of them and let you switch between them.
But now we’re going to rename that project, so make sure you’re in that specific project (My First Project). To do this, go to the hamburger menu (the three horizontal lines) at the top left and open it.

A side menu opens, where you need to go to Home –> Dashboard. There you can edit the project information in one of the cards at the top of the screen.

That card looks like this, with a link at the bottom (Go to project settings). Click that link.

Here, in the project details, you can change the name to whatever you like. Then click Save, the link right next to it.

How to access the different APIs
In the side menu that opens from the hamburger menu, you can go back to the earlier dashboard via APIs & Services –> Dashboard, but if you want to access and manage the different APIs, click Library.

You’ll see something like a grid showing the different map APIs.
In the categories on the side we can filter all the map APIs by clicking Maps, where there are 17 APIs.

Remember that we had enabled all the APIs, but if you open each one, you’ll see confirmation that the API is enabled and you’ll be able to manage them and disable the ones you don’t need.

From now on you can use any of the enabled APIs on your website.
You can now embed a map, enter your Google Maps API key in your favorite map plugin, and so on.

Leave a Reply