Not properly working with Google maps provider

Created on 4 August 2022, over 2 years ago
Updated 5 August 2024, 4 months ago

Problem/Motivation

The address predictions are not coming from the google API.

Steps to reproduce

Select google maps as current provider in module settings, provide an API key.
Ensure you're not getting address prompts if a part of an address is typed in the field.

Proposed resolution

Currenlty the API endpoint id hardcoded as https://maps.googleapis.com/maps/api/geocode/json and uses address query parameter, which must contain a full address only.
Another endpoint has to be used instead: https://maps.googleapis.com/maps/api/place/autocomplete/json, it takes input query parameter instead, which can contain e.g. just a part of a street's name.

Remaining tasks

Change the api endpoint, adjust json parsing (the autocomplete api uses different json fields).
Also the autocomplete api seems not to return zip code, so this has to be done maybe with en extra query to geocode api.
The administrative area should be also handled (see comment HERE )

User interface changes

n/a

API changes

n/a

Data model changes

n/a

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇦🇹Austria granik Vienna

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

Merge Requests

Comments & Activities

Not all content is available!

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

  • First commit to issue fork.
  • 🇧🇪Belgium dieterholvoet Brussels

    I created a MR based on the last patch and fixed an issue where results were not being returned in the correct language. Everything else seems to be working fine.

  • 🇧🇪Belgium dieterholvoet Brussels

    I also changed the types filter to allow searching for parts of addresses like just the city, instead of having to search for full addresses.

  • 🇫🇷France GuillaumeDuveau Toulouse

    Doesn't work for me. With and without the patch, no requests are made.

  • 🇷🇸Serbia vaish

    This patch incorporates the following:

    1. patch by chrisolof from #10
    2. commit 78502842 from merge request !7: Fix results not being returned in the correct language
    3. updated dependencies in libraries.yml to bring in compatibility with Drupal 10: Use core/once instead of core/jquery.once

    Patch is compatible with both Drupal 9.5 and 10.1. If you want to use it with Drupal 10 you will also need #3349849-12: Drupal 10 compatibility .

    I decided not to push my updates to the existing merge request !7 because, I wanted to exclude two commits related to "Filter to full addresses or parts of addresses". In my opinion behavior introduced by those two commits may not match user expectations. When you start typing into the Street address field what you are entering is part of the street name. However, with the commits I excluded, results returned at first include only matching city names, not a single matching street name. Only after you type at least a whole word or more you start seeing street matches. I can image that this can be desired in certain use cases but I don't think it should be default module behavior. Perhaps this could be added as an additional feature in a separate issue.

  • This patch incorporates the following:

    1. patch by vaish from #17
    2. exposes the following routes, taking them out of the admin. This allows anonymous users to use this autocomplete field.
      • address_autocomplete.addresses
      • address_autocomplete.address_details
  • Updated patch after finding a path to one of the routes I updated had been hardcoded.

  • Merge request !11Improve support for Google Maps provider → (Merged) created by vaish
  • 🇷🇸Serbia vaish

    vaish changed the visibility of the branch 1.0.x to hidden.

  • 🇷🇸Serbia vaish

    Merge request !11 created from the patch in #17. I've been using this patch in production for very long time.

    @Blush I didn't include your changes from #19 because I didn't experience any issues with anonymous users not being able to use address autocomplete. If you still think there is a problem, please test the new release of the module which will be created soon and create new issue with steps how to reproduce it. Thanks.

  • Pipeline finished with Skipped
    4 months ago
    #231093
    • vaish committed 5832315a on 1.0.x
      Issue #3301846 by chrisolof, DieterHolvoet, vaish, granik: Not properly...
  • Status changed to Fixed 4 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024