Add Google places autocomplete provider

Created on 14 February 2023, over 1 year ago

The default Google plugin uses the geocoding API to suggest addresses. This is cheap and gives reasonable results.
However Google also offers a purpose built autocomplete API as part of Places (aka Maps) that gives way better results.

The following patch adds a new provider that supports this API.

Due to the decoupled nature of this functionality this provider bypasses the stock Drupal autocomplete widget in favor of the one provided by the Google Maps API. This is both for ease of use purposes, and also because attempting to implement this API using the Drupal autocomplete widget results in large numbers of expensive (as in money) queries in order to function.

When the google_autocomplete provider is enabled the default route and javascript file is not loaded and a Google autocomplete specific javascript file is loaded instead.

Note that if this patch is used on Drupal versions before 9.5.0 then the autocomplete widget will fail to load in address forms loaded via ajax due to this bug: #1988968: Drupal.ajax does not guarantee that "add new JS file to page" commands have finished before calling said JS β†’

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rhovland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024