2016-03-25 54 views
1

我正在使用Google Maps JavaScript API。Google Places API中的「地點搜索框」有哪些事件?

從google.maps.places.SearchBox(document.createElement('nameForElement'))返回的對象是否存在除'places_changed'事件以外的任何事件?

您可以在本示例中查看地點搜索框。 Google Maps JavaScript API- places search box sample code

最後,我需要做的是清除搜索框,當我點擊它。但我認爲這個搜索框沒有「點擊」事件。捕捉點擊事件的關鍵詞是什麼? '鼠標點擊','點擊','點擊'...?

+1

你在JS或Android做什麼呢? –

回答

1

<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=''; 
    }); 
相關問題