Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Error

I'm hoping someone has come across this problem also. I'm a newbie to all this, therefore excuse my lack of knowledge in advance.

I currently have Google Maps API setup on my wordpress site. When I perform a search on the site i.e. page containing Google Map, no listing results are been found. Upon further investigation I have been advised that:

there's a JS error on my website coming from Maps API. Chrome Dev Console shows:

js?key=++AIzaSyC_GzbCPmMM8Jme9ZAi-IbKOdaXo_SfK_I+&libraries=places&ver=3b47f53……:34 InvalidValueError: setComponentRestrictions: not an Object

in source view of the page the google maps JS is called via this https://maps.google.com/maps/api/js?key=++AIzaSyC_GzbCPmMM8Jme9ZAi-IbKOdaXo_SfK_I+&libraries=places&ver=3b47f534942a304aaad0d1a98d2531f8

the part "&ver=3b47f534942a304aaad0d1a98d2531f8" shouldn't be there (it's added to each JS file), so we assume it must be coming from some plugin that I have that might be causing that issue.

Before I start disabling every plugin on my wordpress site, has anyone come across this error before?

Any help would be much appreciated.

Thanks,

Justin

like image 595
Justin Avatar asked Jan 10 '17 21:01

Justin


2 Answers

OK - so apparently this was a bug introduced in the 3.27 release of Google Maps.

https://code.google.com/p/gmaps-api-issues/issues/detail?id=11253&q=setComponentRestrictions&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Stars%20ApiType%20Internal

The Google team has it logged and is working on it.

In the meantime you can do as follows:

Thanks for the report! We have created an internal ticket to investigate this. On the meantime, you can load JavaScript API version 3.26 to avoid getting this error.

UPDATE: It does not look like they plan on fixing this. So the correct fix would be to change your settings to:

autocomplete.setComponentRestrictions({'country': []});
like image 84
cman77 Avatar answered Sep 28 '22 22:09

cman77


I have the same problem, but I have changed to the version 3 and it has worked. Obviously, that it isn't the best way to correct it, but I can use this solution up to somebody publishes the correct fix.

Before http://maps.googleapis.com/maps/api/js?key=[MyKey]&libraries=places

After http://maps.googleapis.com/maps/api/js?key=[MyKey]&libraries=places&v=3

like image 29
Pablo Alaniz Avatar answered Sep 28 '22 20:09

Pablo Alaniz