Cannot set properties of undefined error using Google Places API Geocoder

Created on 13 July 2023, over 1 year ago
Updated 12 September 2023, over 1 year ago

Problem/Motivation

Using the Geolocation CommonMap views style plugin with the Google Places API autocomplete input results in a JavaScript error that results in the map not loading.

The error is:

Uncaught TypeError: Cannot set properties of undefined (setting '_renderItem')
    at Drupal.geolocation.geocoder.googlePlacesAPI.attach (geolocation-google-places-api-geocoder.js?v=8.x-3.x:97:18)
    at geolocation-google-places-api-geocoder.js?v=8.x-3.x:133:53
    at Function.<anonymous> (geolocation-google-maps-api.js?v=8.x-3.x:523:9)
    at Function.each (jquery.min.js?v=3.6.3:2:3003)
    at Drupal.geolocation.google.load (geolocation-google-maps-api.js?v=8.x-3.x:520:7)
    at Object.attach (geolocation-google-places-api-geocoder.js?v=8.x-3.x:137:33)
    at drupal.js?v=9.5.9:24:24
    at Array.forEach (<anonymous>)
    at Drupal.attachBehaviors (drupal.js?v=9.5.9:21:34)
    at success (ajax.js?v=9.5.9:609:20)

The error appears to occur because there are cases when the autocomplete instance is undefined. The attached patch ensures that it is defined before the autocomplete is instantiated.

Steps to reproduce

  1. Create a view using the Geolocation CommonMap views style plugin
  2. Add a location input that uses the Google Places API geocoder
  3. Turn ajax on the view. The error will still occur with ajax off, but ajax turned on will result in the map failing to load.
πŸ› Bug report
Status

Fixed

Version

3.0

Component

GoogleMapsAPI

Created by

πŸ‡ΊπŸ‡ΈUnited States mtalt Maryland

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

Comments & Activities

Production build 0.71.5 2024