Setting Up Google Maps API Keys and Libraries
Google only serves maps to sites that identify themselves with an API key. You create the key in your own Google Cloud account, switch on the APIs that Events Manager calls, and paste the key into your settings.
Google changes its console screens often, and they differ between account types, so this page says what each step has to achieve and links to Google's own instructions for the clicks.
You need a Google account, and a billing account to attach to the Google Cloud project. Google asks for a payment method even if your usage stays within its free allowances. See Google Maps API Usage for what is counted.
1. Create a Google Cloud project with billing
Sign in to the Google Cloud console and create a project for your site, or pick one you already have. Link a billing account to it.
Google's guide: Getting started with Google Maps Platform.
2. Enable the APIs
In the project's API library, enable each API that matches a feature you use. Leave the rest off: an API that isn't enabled can't be billed.
| Google API | Needed for |
|---|---|
| Maps JavaScript API | Dynamic maps on your site, the [locations_map] and [events_map] shortcodes, and the map preview in the location and event editors. Needed by almost every setup. |
| Geocoding API | Finding the coordinates of an address as you type it in the location or event editor |
| Places API | The Near... field of the search form, which suggests places as visitors type |
| Maps Embed API | The Embedded map type, and static maps set to load an embedded map on click |
| Maps Static API | The Static map type Pro |
If the Near... field is switched off on your site (Show geolocation search? in Events then Settings then Formatting then Search Form), you can leave the Places API out.
3. Create the key
In the console's Credentials area, create an API key. Give it a name you will recognize later, such as "Events Manager browser key".
Google's guide: Use API keys.
4. Restrict the key
The key is visible to anyone who views your pages, so an unrestricted key can be copied and used on someone else's site, at your expense. Give it two restrictions:
- A website restriction that only accepts requests from your own domain. Add both forms of your address so every page matches, for example
yoursite.com/*and*.yoursite.com/*. - An API restriction that limits the key to the APIs you enabled in step 2.
Google's guide: API security best practices.
While you are there, check any other keys in the project. Restrict those too, and delete the ones you don't use.
5. Add the key to Events Manager
-
Go to Events then Settings then General then Google Maps and Location Services.
-
Set Enable Google Maps integration? to Yes.
-
Paste the key into Google Maps API Browser Key and click Save Changes.
-
Open a location under Events then Locations to check that the map appears in the editor, then view the location's page on your site.
A second key for static maps
ProStatic maps need Events Manager Pro.
Pro's static maps can fetch map images from your server instead of the visitor's browser. Requests made that way don't come from a web page, so a key restricted to your website would be refused. Create a second key, restricted by your server's IP address and to the Maps Static API, and enter it as the Google Maps API Server Key. Static maps also need a URL signing secret. Both are covered in Google Static Maps.
Troubleshooting
Maps don't load after adding the key
Work through these in order:
- Remove the website restriction from the key for a moment and reload. If maps appear, the pattern is wrong: compare it with the address in your browser, including
www. - Confirm that the APIs in the table above are enabled in the same project the key belongs to.
- Confirm the project has an active billing account.
A change to a key can take a few minutes to reach Google's servers. If maps still fail with no restrictions at all, see Google Maps troubleshooting.
Where do I see how much I'm using?
In the Google Cloud console, under the Google Maps Platform reports for your project. See API Usage for setting limits.