[英]Catch Leaflet Search event
我正在嘗試向我的傳單地圖查看器添加搜索框 :
var controlSearch = new L.Control.Search({
layer: new L.LayerGroup()
}).on('search_expanded', function () {
console.log('search_expanded!')
}).on('popupopen', function(e) {
var marker = e.popup._source.feature.properties.markerid;
}).addTo(map);
我需要添加自定義代碼,以便對具有斷點的事件執行搜索功能。 但是,當我按下搜索按鈕或鍵入文本時,代碼未達到我的活動。
我正在使用地圖顯示該地區的土地。 搜索必須根據其自定義屬性識別區域,並突出顯示它們或其他內容以向用戶識別。 因此,搜索不應應用於位置或類似位置,而應應用於顯示的項目的自定義屬性。 該頁面主要使用jQuery,沒有Angular。
我無法找到事件列表。
那么,如何捕獲用戶鍵入的事件?
您可以將這樣的事件添加到搜索輸入框中:
var controlSearch = new L.Control.Search({
layer: new L.LayerGroup()
}).on('search:expanded', function () {
this._input.onkeyup = function(){
console.log(this.value)
}
}).addTo(map);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.