Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Provides a widget for Drupal text fields with autocomplete suggestions from the Google Places API.
Also you can use the autocomplete path it defines for your own FAPI implementation.

How to use the module

1. The module exposes a widget for text fields.
2. Set the Google Places Autocomplete widget for the text field you want.
3. When typing into the text field, you can see suggestions based on the characters you typed.

How to configure the module

1. Go to admin/config/services/places
2. Insert the Google API Key

How to get a Google API key

1. Go to https://code.google.com/apis/console/
2. Create a new project
3. Enable Google Places API (By going to https://console.developers.google.com/apis/library?project=YOUR_PROJECT). Be warned that skipping this step will make the request to the Google Places Api fail with 500 code.
4. Go to Credentials
5. Create New Key
6. Select Server key
7. Copy the API key.
8. Paste it in the module configuration page, at admin/config/services/places

How to configure the parameters

The Google Places Api requests can use parameters to restricte the results, such as location, country, language. These can be configured either per field or in the general settings of the module for non field usages. Documentation about the parameters and the possible values can be found here.

More complex use case example

1. Create a text field, and use the widget provided by this module on that field.
2. Using the Geocoder and Geofield modules,create a geofield on the same entity, and geocode a value to be stored in the geofield based on the text field from above.
3. Use the Openlayers module, which provides a formatter for the geofield from the previous field. This will show the geocoded feature described in the field from 1. on a map.

Advantages over using alternative solutions, such as Addressfield:

  • Ease of use, you don't have to jump from field to field, no ajax requests when changing the country.
  • Speed, the user will input his address in a shorter time.

Disadvantages over using alternative solutions, such as Addressfield:

  • The address is not formatted, you can't extract only the country, or only the street address, at least not easily.
  • External dependecy, it uses Google's Places API.
  • If the website is quite large, it could go over the free quota of Google's Places API, and a fee would be required to use this solution.
Supporting organizations: 
Sponsored time for the module development.

Project information