简体   繁体   English

Google地方信息自动填充功能和搜索功能无效

[英]Google Places autocomplete and search not working

Google places autocomplete dropdown is not populating any places and when I click on search i am getting this below error. 谷歌放置自动完成下拉列表不填充任何地方,当我点击搜索我得到以下错误。

But if I do keyboard ENTER - i see the results on the map. 但如果我做键盘输入 - 我在地图上看到结果。

Everything was working fine till yesterday and nothing changed in regards to code. 一切都工作正常,直到昨天,在代码方面没有任何改变。

(index):9 Uncaught TypeError: Cannot set property 'handled' of undefined
    at _.Ec (js?key=AIzaSyDiIbcf012mobkCgUHnNjqRYzNCmTDeR1g&libraries=places:48)
    at HTMLInputElement. (js?key=AIzaSyDiIbcf012mobkCgUHnNjqRYzNCmTDeR1g&libraries=places:49)
    at Object.trigger (js?key=AIzaSyDiIbcf012mobkCgUHnNjqRYzNCmTDeR1g&libraries=places:119)
    at HTMLButtonElement. ((index):2699)
    at HTMLButtonElement.dispatch (jquery.min.js:338)
    at HTMLButtonElement.elemData.handle (jquery.min.js:311)
    at HTMLButtonElement.nrWrapper ((index):9)

My search button also started failing with the same error. 我的搜索按钮也开始失败并出现同样的错误。 I think a API change somewhere between V3.31 and V3.34 made the final argument to event.trigger required instead of optional. 我认为V3.31和V3.34之间的API变化使得event.trigger的最终参数成为必需而不是可选的。

https://developers.google.com/maps/documentation/javascript/reference/event#event.trigger https://developers.google.com/maps/documentation/javascript/reference/event#event.trigger

My code looked like this: 我的代码看起来像这样:

button.click(function () {

    google.maps.event.trigger(input, 'focus');
    google.maps.event.trigger(input, 'keydown', {
        keyCode: 13
    });
});

I added an empty third argument to the focus trigger, like this: 我在焦点触发器中添加了一个空的第三个参数,如下所示:

google.maps.event.trigger(this, 'focus', {});

and everything started working again. 一切都开始了。 Hope this helps anyone in a similar situation! 希望这可以帮助处于类似情况的任何人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM