If you have ever wanted to create a custom Google map using the Divi Map Module, I am sure you will have been frustrated by how damn hard it is. But it isn’t the fault of Divi. Google forces website owners to have a Developer Console Account, Active Billing and API keys to display a custom map. Creating the Divi Map Module and applying styles is the easy bit. It is the Developer Console setup which is the tricky bit but it can be done!
I have worked through this disjointed process a few times so I thought I’d write up this Divi Map Module Tutorial to hopefully make things easier for you and me both!
Following this tutorial you will be able to use either the Divi Map Module or create a customised map using Snazzy Maps and the Code Module instead. Good luck.
Google Developer Console
If you really want a custom map for your website you have to go through this process and create a Developer Console Account, Active Billing and API keys to display a custom map.
01 Developer Console Setup
You will need access to a Gmail account associated with the website.
This can be a Gsuite or regular Gmail account.
- Login to the Gmail account you will use to set up the Map API and Billing.
- Then go to: https://console.developers.google.com/
Even though Google requires a billing account, you won’t have to pay anything if your map won’t be displayed more than 25 000 times/month.
- The first thing you need to do is set up a billing account.
- Click the burger menu top left and select Billing.
- Add your billing details.
02 Create a new project for your website
- Click the little arrow top left next the domain name.
- In the pop up window click NEW PROJECT.
- Give it a name. Example: My Website Map API Project.
- Click CREATE.
- Make sure are in the correct Project by selecting the little black arrow.
03 Enable the API’s you need
- Click the burger menu top left.
- APIs & Services / Library
- Search: Maps
- Enable the following APIs:
- Maps JavaScript API – Needed for Divi Map Module and Snazzy Maps.
- Geocoding API – Needed for Divi Map Module.
You can enable each API by clicking the name.
In the next window click ENABLE.
04 OAuth Consent
- Click the burger menu top left.
- Click APIs & Services / OAuth consent screen.
- Click Internal.
- In the next window add an Application name. Example: My Website Map OAuth
- Add the authorised domains.
- Click Save.
05 Verify Your Domain
- Click APIs & Services / Domain verification.
- Add domain.
06 Credentials & API Key
- Click APIs & Services / Credentials
- At the top of the screen click + CREATE CREDENTIALS / API key
- Copy and save your API key. Keep it secret!
- Click RESTRICT KEY. (If you are going to use Snazzy Maps and the code module do not restrict the key. Just keep the API key secret).
- Give your API key a name. Example: My Website API Key 01
- Check HTTP referrers (websites)
- Below, click ADD AN ITEM
- Enter your domain like this – ensure you enter your correct domain: *.yourdomain.com/*
- Check Restrict key.
- Select the API’s to restrict.
- Click Save.
07 Add the API Key to Divi
- Login to your Divi WordPress website.
- Click Divi / Theme Options
- Enter the Google API Key
- Save Changes.
08 Add the Divi Map Module
- Edit a Divi page.
- Add a map module.
- Be sure to add a map pin and the map centre address in the module settings.
SNAZZY MAPS
If you want even more map control and styling you might want to look at Snazzy Maps.
Now you have all your Google developer stuff sorted we can create a Snazzy Map and use this instead (if you like).
- Go to https://snazzymaps.com/
- Create an account by clicking the avatar icon top right.
- Click EXPLORE STYLES or BUILD A MAP to create a map for your site.
- Go through the process.
- To get your map location Latitude and Longitude visit https://www.latlong.net/
- When you save your map you are prompted to add your API key.
- Once saved get the iFrame code to use on your website.
When you create a map with Explore Styles it’s possible to remove controls if you want to under the Advance Settings.
- View the code and copy it.
- Come back to your website.
- Add a Divi Code Module.
- Paste in the code.
If the snazzy map doesn’t show correctly you will need to remove the restrictions under Credentials in the developer console.
Don’t forget that making changes in the Google Developer Console can take up to 5 minutes to take effect.
Good luck!