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.

Comments

mtalt created an issue. See original summary.

mtalt’s picture

mtalt’s picture

Assigned: mtalt » Unassigned
Status: Active » Needs review

christianadamski’s picture

Status: Needs review » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.