Support for restricting by multiple countries in Places Autocomplete

Created on 26 October 2021, about 3 years ago
Updated 27 August 2024, 3 months ago

Problem/Motivation

We are currently working on a site where we need to restrict Google Places's Autocomplete results to North American countries. (US, Canada and Mexico). Currently, providing a comma-separated or a pipe-separated list results in a "INVALID_REQUEST" response from the Autocomplete Service.

Proposed Solution

Accept a comma-separated list of country codes and explode into an array before attaching to Drupal settings.

Places Autocomplete Service Documentation: https://developers.google.com/maps/documentation/javascript/reference/pl...

Open to alternatives.

User interface changes

The current GoogleGeocoderBase's options form restricts the country input to 5 characters. This makes it hard to read the configuration once you get past 2 countries. The attached patch increases the size to 15 characters, like the already available options. I wouldn't mind updating the provided patch to make the Postal Code field also use 15 characters for the sake of uniformity.

Current

Proposal

✨ Feature request
Status

Fixed

Version

3.7

Component

GoogleMapsAPI

Created by

πŸ‡ΊπŸ‡ΈUnited States analiam319@gmail.com

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada gordonio

    It looks like this only got partially added. The part with the explode to separate the countries doesn't appear to be there. Here's a patch re-roll with just the country explode if anyone needs it.

Production build 0.71.5 2024