![](/img/trans.png)
[英]Openlayers 3: how to select a feature programmatically using 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
集合,然后根据需要push
或pop
:
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.