Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.JS console gives me "Cannot read property 'height' of undefined" and I see no map when I select the Google Geocoder widget
Comments
Comment #2
christianadamski commentedCould you resave your view settings and try again? Is this still happening?
Comment #3
fotidim commentedI am not entirely sure what you mean by "view settings". I tried saving my field settings, the form display settings, setting a value with lat/long and then switch back to Geocoder widget but nothing.
This is what I see
I also tried creating a demo site on http://simplytest.me and I replicated it right away by adding a geolocation field to content type 'article' and setting the 'Google Geocoder' widget.
Comment #4
torreytoomajanian commentedI believe this may have been fixed in the latest 8.x-1.6 release that appears to have covered a lot of bugs. I will need to test myself when I have some time, but the root of this problem was related to lines 86 & 87 in the function geolocation.add_map() within the geolocation.js file (in the prior version). The lines in question apply the height/width CSS to the new Map:
In the new version, this is located on lines 180 & 181 within the newly named function Drupal.geolocation.addMap() which now look like this:
The .height and .width values did not exist on map.settings in the past version because they actually existed on map.settings.google_map_settings. I'm speaking off of memory from a week ago when I ran into this error, but judging by the number of changes & fixes included in the latest version update, I believe this can be marked as fixed. Will confirm when I have some free time.
Comment #5
fotidim commentedI am using 8.x-1.6 stable. I tried messing with the js file and hardcoding the values of height and width but it complains for every property of map.settings.google_map_settings. Not just height and width.
Comment #6
christianadamski commentedComment #7
christianadamski commentedOk, the new JS test at #2769305: Add Mink/Javascript test confirms this issue as well as another one. See
https://www.drupal.org/pift-ci-job/380555
Once the test is committed, at least we will potentially notice JS errors earlier.
Comment #8
isholgueras commentedI have the same issue as @axiaos.
In the file
geolocation.js:180,map.settings.google_map_settingsis undefined. I'm in 8.x-1.6 version.It seems that isn't taking the right settings from Drupal.
I will try to debug to find what happens.
Comment #9
christianadamski commented@isholgueras,
most of the GoogleMap handling on the PHP side was moved to the GoogleMapsDisplayTrait.php
This especially includes handling the common Google Maps settings that are the same across the GoogleMap Formatter, the GeocoderWidget and the CommonMap views style.
Somewhere along that line, Geocoder isn't properly hooked up to this new functionality.
Comment #10
isholgueras commentedYep,
I found that google_map_settings are set on that trait, but when I put a breakpoint there, it doesn't stop.
I will follow that way.
Comment #11
christianadamski commentedThis should do it. Besides fixing this error, it also allows the usual settings on the geocoder widget.
Comment #12
christianadamski commentedIf somebody can confirm this fixing the issue, I will push it.
@derjochenmeyer: if you happen to read this: we should probably also release a new bug-fix-release once this is taken care of.
Comment #16
christianadamski commentedAdded schema definitions. This is non-ideal currently, but I don't know how to avoid repeating those settings over and over in schema.
Comment #20
christianadamski commentedMore schema fixes
Comment #21
derjochenmeyer commentedI applied the latest patch on simplytest.me. No console errors. Screens look good, works like a charm.
Node edit:

Node view:

I agree, lets put this in a 8.x-1.7 release.
Comment #22
derjochenmeyer commentedComment #24
christianadamski commentedComment #25
isholgueras commentedYes, The patch applies right and now it works perfect.
Thanks
Comment #26
fotidim commentedI am getting some weird errors with 8.x-1.7. The map tries to load momentarily and then I get this:

and on the console:

Comment #27
christianadamski commented@axaios
as of late, you do need a valid Google API key to use Google Maps. So that second "Missing Key" error is okay and expected. Follow the link mentioned in the error and follow the steps. You can add the API key later to gelocation at /admin/config/services/geolocation
That autocomplete one is more interesting. But will probably be resolved, once the map actually loads, so the search elements can be attached.
Comment #28
fotidim commented@ChristianAdamski
You were right. Perhaps you can improve it by showing a message to the user if the API key is not set and not try to load the map at all.
Many thanks for the great module!
Comment #29
fotidim commentedMaybe I rushed a bit. After adding the API key the map load but the console still shows "$(...).children(...).first(...).autocomplete is not a function". And the problem is that autocomplete actually does not work. When I type something in the search field no suggestions show up and pressing enter reloads the whole page. I also tried testing it on simplytest.me and there it works. Any suggestions?
Comment #30
fotidim commentedI have narrowed down the issue. Please see here: https://www.drupal.org/node/2770143
Comment #31
huzookaThe pushed patch contains schema change without any schema update hook.