1. Home
  2. Docs
  3. Local Delivery Drivers for WooCommerce Premium
  4. Getting Started
  5. How to generate and set Google Maps API keys

How to generate and set Google Maps API keys

Before starting the setup process of API Keys you must first have Billing Enabled on your Google Console Account.
Please go to the following URL and select your project to enable billing
https://console.cloud.google.com/project/_/billing/enable

The next step is to create API Keys to use them inside the plugin settings. In this step, we will create 2 different API Keys. The first one will be used for the website and the second one will be used for the server.

  1. Go to the Google Cloud Platform Console.
  2. if you don’t have a project please click create a project, you can call the project by the name of your site. 
  3. Click the Select a project button, then select the project you set up for the delivery drivers plugin and click Open.
  4. On the left menu click on Library and enable the following APIs: Distance Matrix API, Directions API, Maps Embed API, Maps JavaScript API.
  5. On the left menu click on Credentials and follow the next steps.

Create a key for website Application restrictions.

  1. Click on the Create Credentials button at the top of the page and select API Key.
  2. The new pop-up window will show up with your new key, click restrict key.
  3. On the key settings page, you can call the key as website key.
  4. On the Application restrictions section choose HTTP referrers (web sites).
  5. A Website restrictions section will show up, click Add an item.
  6. Write your domain as follows: *.example.com/* , example.com/* , http://example.com/* , https://example.com/* and click done.
  7. On the API restrictions section, you can choose none or If you want to enabled APIs click Restrict key and select the following APIs: Directions API, Maps Embed API, Maps JavaScript API.
  8. Click the Save button.
  9. Copy the key and go to the plugin settings and set the key on the Key for Maps Embed API and Maps JavaScript API. ( Application restrictions: HTTP referrers ) input.

Create a key for Server Application restrictions.

  1. Click on the Create Credentials button at the top of the page and select API Key.
  2. The new pop-up window will show up with your new key, click restrict key.
  3. On the key settings page, you can call the key as website key.
  4. On the Application restrictions section choose IP addresses (web servers, cron jobs, etc.).
  5. Accept requests from these server IP addresses section will show up, click Add an item.
  6. Write your server IP address and click done.
  7. On the API restrictions section, you can choose none or If you want to enabled APIs click Restrict key and select the following APIs: Directions API, Distance Matrix API.
  8. Click the Save button.
  9. Copy the key and go to the plugin settings and set the key on the Key for Maps Directions API and Distance Matrix API. ( Application restrictions: IP addresses ) input.

You are Done!

Troubleshootings

Error:

Google Maps Platform rejected your request. This IP, site or mobile application is not authorized to use this API key. Request received from IP address 0.0.0.0, with referer: example.com

Solution:

For the Application restrictions section try to add your website as following:

*.example.com/* and example.com/* and http://example.com/* and https://example.com/*