/
/
Wordpress education
/
How to add a Google map to your site

How to add a Google map to your site

How to add a Google map to your site

Google map on the page. Ways to implement and customize the map style

Adding a Google map to a website is very simple and doesn't require too much time. The benefits of embedding a map are enormous. At the cost of a few minutes, we can easily embed the map in the contact sub-page or anywhere on the site. We will tell you how to solve the problem with the message : This page cannot load Google Maps correctly

Benefits of adding a Google map

Learn the benefits from implementing Google maps on your site. With Google map :

  1. you will use additional information and data about the company on the site,
  2. improve the credibility of the company, Google maps with high ratings, inspire confidence,
  3. show feedback from customers and real users,
  4. improve the visibility of the site in search results / although this is not a priority factor /.
  5. allow customers to share the route to the company
  6. with a well-run map i.e.; Google business card, you can build visibility in local results in Google maps

See our offer : wordpress website development

Table of Contents :

Ways to implement Google maps on your site

We can implement Google maps in two ways: by embedding a code frame on the page, which we download directly into the maps, or through Google's API. We will discuss the above ways of adding a map below.

How to insert a Google map through the Google Maps API ?

This is our recommended way to implement the map on the site.

The advantage of this implementation is:

  • The ability to personalize the appearance and settings of the map,
  • zoom settings for the map,
  • customize the pin and put your own content including logos and graphics,
  • Better implementation performance over the way it is embedded via iframe,

To use the API you need to plug in a payment card. You will receive $200 from Google to start which gives you 28,000 map impressions per month.

It is possible to set the budget so that it does not exceed $200 - that is, the use of Google Maps will remain free. However, in that case, if the limit of free impressions is reached, the map will stop displaying.

The way to use only free map displays is to set limits for payments in the payment option. Set the limit to 0 $.

Placing a map through the API step by step

You will get access to the API when you go to the Google platform at https://cloud.google.com/maps-platform where you will create an API key.

Logging in and creating an account with Google Maps Platform

Logging into the panel is done by clicking 'Get Started'.

Google Maps Platform

If you do not have a Google Maps Platform account, you will be asked to enter your data and plug in your payment card.

In steps 1 and 2, we fill in the necessary data needed to create an account

filling out the account creation form

Generating an API key when creating a Google Maps account

In step 3 we enter the data needed to generate the API key

Enter payment details and set up an account

Next, the wizard will guide us in the process of creating an account and generating an API

Wizard for setting up a google maps account

Generated API key

Enter key protection against unnecessary calls. Select http and enter the name of your domain *.domain.pl

View after logging into the panel.

Google Maps dashboard after login - overview of the interface

Subsequent module views after scrolling the panel. Available options for enabling and editing the API

In case if you want to plug / add / another key or project to your account, click the 'Create Project' button.

Important interfaces that should be included

It is also worth activating the API for Geocoding and Geolocation services. You will do the activation from the AP Interfaces side menu or through indicators.

Below is a list of the necessary interfaces that should be enabled in the status.

  • Directions API
  • Distance Matrix API
  • Geocoding API
  • Geolocation API
  • Maps Embed API
  • Maps JavaScript API
  • Maps Static API
  • Places API

How to insert a Google map into a page through an iframe ?

A simpler technique to implement, it does not require complicated technical procedures, logging and downloading codes. All you have to do is as you enter your company's map or through the link https://www.google.pl/maps, click the 'share and post map' button directly from Google map.

In the popup that shows up :

  1. click the ''place map'' button,
  2. select size,
  3. Click 'copy HTML',
  4. the generated code can be pasted anywhere on the page regardless of the CMS system and the technique of making the page

Place the map on the page through an iframe. After entering the company name, click Share

Placement of map, generation of iframe code and map dimension

Disadvantages of inserting a Google map in an iframe

There are several drawbacks to this method of embedding the map that are worth mentioning:

  1. Lack of visual customization and personalization of the map,
  2. Inserted code is an iframe that is the placement of other code rigidly in the code of our site,

Ways to secure API keys in Google Maps

Google Maps supports four types of security that can be set. Application security restricts the use of an API key to specified websites, IP addresses, servers, or applications, which you can set when you first create an account for a key or in editing a project.

The types of application security are :

  • HTTP referer allows you to set restrictions for a specific domain, site, group of sites
  • IP addresses - restricts use to one or more IP addresses
  • Android applications - restricts use to calls from Android applications
  • iOS apps - restricts use to calls from iOS apps

Don't put your API keys directly into the code of your website or application

A good practice according to the recommendations that Google (https://cloud.google.com/docs/authentication/api-keys) has made available is that API keys should not be placed directly in the code making them vulnerable to accidental public disclosure. It is a good idea to store them in variables or files outside the main structure of the site or application.

How to add a Google map to a site on Wordpress ?

In the case of Wordpress, the map can be added both through a non-recommended iframe solution and using the received API code from Google Maps.

We can place the code, as appropriate, depending on the implementation, either in the theme configuration, plugin or prepared configuration in ACFpro fields.

Example of Keys integration field for Google Maps API.

WP Go Maps plugin

If your wordpress does not have the option to integrate after API with Google maps in the settings, you can use the plugin. Link to the plugin : https://pl.wordpress.org/plugins/wp-google-maps/

By going to the plugin menu ie: maps -> settings -> advanced - paste the API key

General settings

In the settings of the WP Go Maps plugin, you can choose options:

  • Shortcode - shortcode to place the map anywhere on the page,
  • Map name - the name of your map
  • Zoom level - map view
  • Width - the width of the map in the container, if not defined then the dimensions of the map will be taken from this field, to set the value in px, %.
  • Height - to be set similarly to width

Themes tab

You can also change the look of the map according to predefined presets.

Advanced

In the free version of the plugin, you can add multiple tags but without the option to adjust them. Only a standard pin is available.

In addition to move in :

  • GPS address/position,
  • Animation - animation of the tag,
  • Information window open by default - that is, a tooltip/smoke above the marker that can be opened on start or when clicked on

See also:

This page cannot load Google Maps correctly

We often get inquiries from customers about the problem and reported message in google map not displaying correctly. The map view on the site is blocked and looks like below.

This page cannot load Google Maps correctly - map message

The problem with the correct loading of the google map may occur for two reasons:

  1. Connected payment methods have been removed or payment from the card has not occurred. For this, it is worth checking the billing tab in the Google Maps dashboard. The problem occurs with the embedding of maps before the period of introduction of restrictions and limits on map displays in the free version, where you did not yet have to provide a payment card to unlock the API
  2. The project has been removed from the panel.