The easiest way to embed a Google Maps map in WordPress is probably the one we’re about to look at.
It’s actually very simple, since Google Maps itself gives us the code.
To do this, on the map we’re using, in Google Maps, in the left sidebar where the details of the selected search appear, we click the Share button.

A modal window then appears with the map we want to embed, but on the tab that lets us send the map as a link. So we switch to the Embed a map tab.
We’ll then see some code, a selector that lets us choose between medium, large or small, and a link that says Copy HTML.
Once we’ve chosen the map size, we click the Copy HTML link.

The full copied code will look like this.
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3179.016523905674!2d-3.5903353482002385!3d37.176078279774075!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd71fcb7977fb93b%3A0x808dd1ef1221a27f!2sAlhambra!5e0!3m2!1ses!2ses!4v1626065631650!5m2!1ses!2ses" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>
Note that it’s an HTML iframe tag, whose source (the src attribute) is the URL of the Google Maps view we currently have on screen.
In fact, if we simplify it so you can see the code more clearly, we’d have this:
<iframe src="#" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>
If you look closely, the first parameter (src) is the URL, the second is the window width (width), the third (height) is the window height, then there’s another that lets us define the window style (style), in this case with no border, and two more that let us show the map full screen (allowfullscreen) and load the map only when it actually becomes visible on screen rather than from the start (loading=”lazy”).
Now that we know how the code works, we insert it into our post with the Custom HTML block. We simply add the block and paste the code.

Once that’s done, we could change a parameter such as the width, for example setting it to 100% of the screen width.
If you click Preview, you’ll see the map on the block. And once published, the final result will be as shown below. You can see it on wpgis.com.


So, as you can see, there’s not much to it: you just copy the code Google Maps gives you and paste it into the Custom HTML block.
However, you’ll find there’s a small catch: to show a Google Maps map on your website, you’ll have to sign up for the Google Maps API for your website.
That said, there’s a trick to avoid having to sign up for this API. It involves adding the following query to the end of the src URL:
?output=embed
That way, it ends up like this:
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3179.025006883144!2d-3.589958633773272!3d37.175876679872985!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd71fcb7977fb93b%3A0x808dd1ef1221a27f!2sAlhambra!5e0!3m2!1ses!2ses!4v1626608197369!5m2!1ses!2ses?output=embed" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3179.025006883144!2d-3.589958633773272!3d37.175876679872985!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0xd71fcb7977fb93b%3A0x808dd1ef1221a27f!2sAlhambra!5e0!3m2!1ses!2ses!4v1626608197369!5m2!1ses!2ses?output=embed" style="border:0;" allowfullscreen="" loading="lazy" width="600" height="450"></iframe>

Leave a Reply