簡體   English   中英

如何在Openlayers 3 ol.interaction.Select上手動導致“選擇”事件?

[英]How do I manually cause a 'select' event on an Openlayers 3 ol.interaction.Select?

我想使ol.interaction.Select obj在用戶單擊與該功能相關的按鈕時“選擇”該功能。 我希望能夠重用用戶單擊功能時已經使用的事件處理代碼。

有沒有辦法通過選擇交互來做到這一點?

<!-- UPDATE -->

也許當此PR合並時,我們可以調度select事件。 關於重用代碼,我想您可以解決將其包裝在函數上的問題,將功能推入集合時,請使用該功能調用函數。

<!-- End of update -->

獲取ol.interaction.Select 集合,然后根據需要pushpop

var select = new ol.interaction.Select({
    //some options
});
map.addInteraction(select);

var collection = select.getFeatures();
collection.push(some_feature);

//or push an array of features
collection.extend(some_array_features);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM