The Divi Map module integrates with Google Maps seamlessly and is an easy way to add an interactive map to your Divi website. This is great for showing your businessโs location or creating a local guide of your favorite boutiques and businesses.
In this post, weโre going to show you how to add a button to the location info box for one of your pinned addresses.
Design Preview
First, letโs take a look at what weโre trying to accomplish. With some simple HTML, weโll be able to accomplish adding a button inside the location info box for a pinned address.
Letโs dive in!
What You Need to Get Started
To get started, you will need to do the following:
- Install Diviย on your WordPress website.
- Add a Page, give it a title, and publish it.
- Enable the Visual Builder.
- Create yourย Google API Key.
Select Build From Scratch
Once you click the โUse Divi Builderโ button the page will reload using Diviโs drag and drop builder interface. Three options will pop up โ Build From Scratch, Choose A Premade Layout, and Clone Existing Page. For todayโs purposes, select โBuild From Scratchโ. This will give us a blank slate where we can build our designs.
Add Your Google API Key
Before weโll be able to fully use the map module and its functionalities, youโll need to add yourย Google API Keyย to your Theme Options.
- From your WordPress dashboard, go to Divi > Theme Options and paste your Google API Key.
- Click โSave Changesโ.
Letโs get into the tutorial! Hereโs how to add a button to the location info box.
Add a Section and Row and the Map Module
Navigate back to the page you just created and add a section and a one-column row to your page. Then load the module library and click Map. Once added, the module window will pop up with all the settings and functionalities available within the map module.
Addย a Pin
Click โAdd New Pinโ to add a pin to your map. This will bring up that pinโs settings where you can type in a title and add a description text. To add a button in the text area, add the following HTML:
<a href="#google-map-link-here" class="et_pb_button">Get Directions</a>
The key here is to add the class of et_pb_button to the linkโs HTML so that it becomes a button. Donโt forget to replace the # sign with the URL you want this button to link to.
Then add your pinโs location in the Map tab in the Map Pin Address field and click find.
And there you have it! A button appears in the pinโs location info box.
Thereโs also another way to achieve this and itโs to add a unique CSS class to the HTML to style the button. Here is the HTML youโll need:
<a class="get-directions-btn" href="#paste-link-here">Get Directions</a>
The unique CSS class we added wasย get-directions-btn. We can use this CSS class to apply unique styles to the button. You can do this by pasting on-page CSS or by using your child themeโs style sheet. In todayโs example, weโre going the paste the CSS in our Page Settings.
To achieve the button style below, copy and paste this CSS in to your Page Settings:
.get-directions-btn { background-color: #1d1d1d!important; color: #f9f9f9; border-radius: 100px!important; padding: 5px;}
Final Thoughts
Adding a button to your pinโs location box offers a clean direction button link that makes it easy for your visitors to get directions fast. You can also style the button using CSS added to your page! With that, the styling options are endless. Have fun customizing!
Yes, in Europe, we can’t use this way anymore, another way to do this? With another map system or plugin?
This may be helpful:
https://devowl.io/2021/embed-google-maps-gdpr/
Unfortunately the Google map does not conform to European data protection legislation. What can we use instead? And: are there any plans to have alternatives for google fonts?
Thanks,
Petra