Reputation: 91
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
Upvotes: 5
Views: 5604
Reputation: 1783
OK - so apparently this was a bug introduced in the 3.27 release of Google Maps.
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': []});
Upvotes: 8
Reputation: 313
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
Upvotes: 3
Reputation: 10425
I just started noticing a similar error as well, InvalidValueError: setComponentRestrictions: in property country: not a string; and not an Array
. It turns out I was passing an empty object, {}
, as the componentRestrictions
option when trying to initialize a Place Autocomplete.
It looks like that componentRestrictions
option is used by the Google Maps API, you can read more about it here. I am assuming that Google recently made a change that throws an exception if it is configured wrong.
So in your particular case I imagine either you, or one of your plugins, is not setting componentRestrictions
correctly.
Upvotes: 0