- Issue created by @rhovland
- Status changed to Needs review
over 1 year ago 11:32am 14 February 2023
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 β
Needs review
1.0
Code