How To Add Google Maps in WordPress
How To Add Google Maps in WordPress
Google also gives you a recurring $200 credit on your billing account each month to
offset your usage costs. So as you can see unless your generating thousands of requests, using
Google Maps on your site shouldn’t cost you anything.
If you are using a plugin like Google Maps Widget (as shown in the steps further below),
then you would choose the Google Maps Static API.
If you’re using a third-party plugin or theme, they should have documentation on which
type of Google Maps deployment they are using. Don’t worry, you can always add multiple
types and change these later on.
Step 5
Click “Enable.”
To do this, simply click on your API key’s name and it will allow you to add a restriction.
For your WordPress site, simply adding an HTTP referrer should be good enough. Such
as https://yourdomain.com/* . This will allow it to only make calls on your website.
Once you have the map that you want to embed, click on the hamburger menu in the
top-left corner:
<iframe src="https://www.google.com/maps/embed/v1/search?key=YOUR_API_KEY¶meters
allowfullscreen></iframe>
Republic of the Philippines
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
La Paz, Iloilo City
MIAG-AO CAMPUS
That will open a popup with the code, which you should copy. Don’t forget to add your
API key.
You can also use an interactive map right away if desired, and the Pro version lets you
embed maps anywhere on your site with a shortcode.
Intergeo
Intergeo is another popular option that lets you create your own maps with custom
markers and have control over map functionality.
Once you install and activate the plugin, you’ll be able to build your maps right from your
WordPress dashboard:
Republic of the Philippines
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
La Paz, Iloilo City
MIAG-AO CAMPUS
Intergeo interface
Then, you can embed them anywhere on your site using a shortcode.
Gutenberg Block For Google Maps Embed
Gutenberg Block For Google Maps Embed is a simple plugin that adds a dedicated
Google Maps block to the new WordPress Gutenberg block editor.
With this block, you can embed any address and also choose:
Dimensions
Zoom level
Interactive map vs static map (again, the latter method helps with performance)
It won’t let you create your own custom maps – but it is a convenient option if you use the
new block editor and just want an easy way to include some simple maps.
Google Maps Can Slow Down Your WordPress Site – Don’t Let It
While Google Maps lets you embed a ton of cool functionality to your site with its
interactive maps, there is a performance trade-off because it needs to load a large number of
scripts to power all of that interactive functionality.
Long story short, embedding interactive Google Maps can slow down your site.
There are a few ways that you can combat this.
First, if you don’t need people to be able to interactively browse your map on your
website, a simple way to speed things up without any third-party tools is to:
Republic of the Philippines
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
La Paz, Iloilo City
MIAG-AO CAMPUS
Google Maps placeholder image or, you can also use the Google Maps Static API, which
returns a regular image without any JavaScript. Some Google Maps plugins – including Google
Maps Widget and Gutenberg Block For Google Maps Embed – let you use the Static API when
you create your maps.
Republic of the Philippines
ILOILO SCIENCE AND TECHNOLOGY UNIVERSITY
La Paz, Iloilo City
MIAG-AO CAMPUS
However, we realize that sometimes this static approach just won’t cut it, and a lot of
people want to embed the interactive Google Maps experience right away.
If that’s the case, another good way to speed up Google Maps is to use lazy loading.
With lazy loading, your site will wait to load any below-the-fold Google Maps embeds until
visitors start scrolling down the page. That keeps your initial page load times fast, while still
letting you embed interactive Google Maps content.
There are a few plugins that will let you do this. For example, the a3 Lazy Load
plugin lets you lazy load iframe embeds, which includes Google Maps: