gpt4 book ai didi

javascript - Google Places API 中 "places search box"的事件是什么?

转载 作者:行者123 更新时间:2023-11-27 23:10:39 25 4
gpt4 key购买 nike

我正在使用 Google Maps JavaScript API。

对于从 google.maps.places.SearchBox(document.createElement('nameForElement')) 返回的对象,除了“places_changed”事件之外,还有其他事件吗?

您可以在此示例中看到地点搜索框。 Google Maps JavaScript API- places search box sample code

最后,我需要做的是在单击搜索框时清除它。但我认为这个搜索框没有“点击”事件。捕获点击事件的正确关键字是什么? “鼠标单击”、“单击”、“单击”...?

最佳答案

将点击监听器添加到 <input> .

对于链接的示例,它将是:

  // Create the search box and link it to the UI element.
var input = document.getElementById('pac-input');
var searchBox = new google.maps.places.SearchBox(input);

google.maps.event.addDomListener(input,'click',function(){
this.value='';
});

关于javascript - Google Places API 中 "places search box"的事件是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36217446/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com