谷歌地图错误

Jus*_*tin 4 javascript google-maps

我希望有人也遇到过这个问题.我是这一切的新手,因此请原谅我提前缺乏知识.

我目前在wordpress网站上安装了Google Maps API.当我在网站上搜索包含谷歌地图的页面时,没有找到列表结果.经过进一步调查,我被告知:

我的网站上有来自Maps API的JS错误.Chrome开发者控制台显示:

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

在页面的源视图中,通过此https://maps.google.com/maps/api/js?key=++AIzaSyC_GzbCPmMM8Jme9ZAi-IbKOdaXo_SfK_I+&libraries=places&ver=3b47f534942a304aaad0d1a98d2531f8调用google地图JS

部分"&ver = 3b47f534942a304aaad0d1a98d2531f8"不应该存在(它被添加到每个JS文件中),因此我们假设它必须来自我可能导致该问题的某个插件.

在我开始禁用我的wordpress网站上的每个插件之前,有没有人遇到此错误之前?

任何帮助将非常感激.

谢谢,

贾斯汀

cma*_*n77 8

好的 - 显然这是3.27版谷歌地图中引入的一个错误.

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

谷歌团队已经记录并正在开展工作.

在此期间,您可以执行以下操作:

谢谢你的报道!我们已经创建了一张内部机票来调查此问题.在此期间,您可以加载JavaScript API版本3.26以避免出现此错误.

更新:看起来他们不打算解决这个问题.因此,正确的解决方法是将您的设置更改为:

autocomplete.setComponentRestrictions({'country': []});
Run Code Online (Sandbox Code Playgroud)


the*_*ang 0

我刚刚开始注意到类似的错误InvalidValueError: setComponentRestrictions: in property country: not a string; and not an Array。事实证明,我在尝试初始化Place Autocomplete{}时传递了一个空对象,作为选项。componentRestrictions

看起来componentRestrictionsGoogle Maps API 使用了该选项,您可以在此处阅读有关它的更多信息。我假设 Google 最近做出了一项更改,如果配置错误,则会引发异常。

因此,在您的特定情况下,我想您或您的插件之一设置不componentRestrictions正确。