---
title: "Implementing Google Directions Module in Drupal 8 – A quick guide"
description: "The Drupal Google Directions module allows you to create and add a block to your content where users can add two locations and find directions between the two points. Also displayed are suggested routes based on modes of transport (public transit, cycling, walking or driving) and the time it will…"
url: https://www.specbee.com/blogs/implementing-google-directions-module-drupal-8-quick-guide
type: Article
author: "Ankitha Shetty"
categories: "Drupal Talk"
published: 2020-01-28
updated: 2026-10-05
---

# Implementing Google Directions Module in Drupal 8 – A quick guide

Communicating with Google services is simple and effortless with a wealth of API’s to choose from. With Drupal 8’s powerful API-first capabilities, interacting with these services are now easier and more effective. The API in focus is the Google Directions API. Drupal 8 offers a Google Directions module that integrates with the Google Directions API.

## What does the Google Directions Module do?

The Drupal Google Directions module allows you to create and add a block to your content where users can add two locations and find directions between the two points. Also displayed are suggested routes based on modes of transport (public transit, cycling, walking or driving) and the time it will take to get there. This block can be positioned via the Block layout and customized to fit any website’s style guidelines.

## Getting Started with Google Directions Module

Let’s get started with implementing the Google Directions module.

### Get the Google API Key 

A Google API Key is required to access the Google Directions Service.
To get a key, visit https://developers.google.com/maps/documentation/directions/start with your Google account and follow the Guide.
To get an API key:

- Visit the Google Cloud Platform Console.
- Click on the project drop-down and select or create the project for which you want to add an API key.
    
     ![Google-maps](https://www.specbee.com/sites/default/files/styles/large/public/migrated/google_maps_0.jpg.avif?itok=fjZ2-IL_)
- Click on the menu button and select APIs & Services -> Credentials

![google direction module](https://www.specbee.com/sites/default/files/inline-images/google-direction-module.jpg)- On the Credentials page, click on Create credentials -> API key.

![direction module api key](https://www.specbee.com/sites/default/files/inline-images/direction-module-api-key.jpg)- The “API key created” dialog displays your newly created API key. Copy the API key as it must be configured in your Drupal Project.
    
     ![google-direction-module-api-key](https://www.specbee.com/sites/default/files/styles/large/public/migrated/google_maps_api_created_min_0.jpg.avif?itok=u0BrGEUH)
- Select Close. The new API key is listed on the Credentials page under API keys.
    
     ![Google-direction-module-api-key](https://www.specbee.com/sites/default/files/styles/large/public/migrated/google_direction_map_API_key_listed_min_0.jpg.avif?itok=nVezPejX)

### Enable the required APIs

- In the Google Developer Console Dashboard, click on the menu button, select APIs & Services -> Library
    
     ![google cloud form](https://www.specbee.com/sites/default/files/styles/large/public/migrated/google_cloud_form_min_0.jpg.avif?itok=WOxHYnRq)
- Search for and enable the following APIs

 ○ Google Directions API

 ○ Google Maps JavaScript API

 ○ Google Places API

 ○ Google Geocoding API

## Installing

Install and enable the Google Directions module as you would normally install a contributed Drupal module. Use your preferred method to download the modules. I’m using the Composer to install since it automatically takes care of all the necessary dependencies and Drush command to enable the module.

```
specbee@specbee-HP-ProBook-640-G1:/var/www/html/drupal_php$ composer require drupal/google_directions

specbee@specbee-HP-ProBook-640-G1:/var/www/html/drupal_php$ drush en google_directions
```

## Configuration

- Configure user permissions as required in **Administration -> People -> Permissions:** 
     ○ Administer Google Directions
    
     ![administer google directions](https://www.specbee.com/sites/default/files/styles/large/public/migrated/administer_google_directions_0.jpg.avif?itok=uWICIpJ6)
- Once Google Directions is installed and enabled and permissions are granted:
     ○ Visit /admin/config/services/google-directions to enter your Google API Key that we copied earlier.
    
     ![google-direction-setting](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Google_direction_settings_0.jpg.avif?itok=u-R_jPOT)
- ○ Use the Block layout page (/admin/structure/block) to position the block in one or more regions to suit your use case for the Google Directions module.
    
     ![direction-module-visibility](https://www.specbee.com/sites/default/files/styles/large/public/migrated/direction_module_visibility_min_0.jpg.avif?itok=dcvdehfd)
- ○ For each block placement, configure Visibility and other block settings to suit your use case.
     ○ Click on Save Block and visit the page. The following Google Directions block appears in the region it was placed.

![google module block](https://www.specbee.com/sites/default/files/inline-images/google-module-block.jpg)Good to Note : 
If the menu does not display, flush cache and try again.

- In the block enter the locations in “From” and “To” fields and hit “Go”.

![google module block](https://www.specbee.com/sites/default/files/inline-images/google-direction-blocks.jpg)The API-first initiative taken up by the community in Drupal 8 is giving a lot of power and flexibility in the hands of developers and website owners. Talking to API’s like the above discussed Google Directions API via the Drupal 8 Google Directions module is easy and compelling. Need help with setting up your Drupal website and leveraging Drupal 8’s power? Learn more about our [Drupal services](https://www.specbee.com/services/drupal-web-development) and get it touch with us.