Openlayer 3矩形选择
Openlayer 3 rectangular selection
我在 openlayer 中添加了一些叠加层 3.Is 如果我单击 ctrl+鼠标左键单击并将鼠标拖动到 select 地图上的一个矩形区域,我可能需要获取叠加层在那个特定区域列出?
是的,可以使用 DragBox 元素。
这样声明元素:
var dragBox = new ol.interaction.DragBox({
condition: ol.events.condition.platformModifierKeyOnly
});
并且您可以将其作为交互添加到您现有的地图中:
map.addInteraction(dragBox);
如果您想添加一些行为,可以调用事件 boxstart 和 boxend:
dragBox.on('boxstart', function() {
// Your stuff when the box starts being drawn
});
dragBox.on('boxend', function() {
// Your stuff when the box is already drawn
});
您将在 OpenLayers 3 API 中找到更多信息:http://openlayers.org/en/latest/apidoc/ol.interaction.DragBox.html
您还可以在此处查看框选择示例:https://openlayers.org/en/latest/examples/box-selection.html
我在 openlayer 中添加了一些叠加层 3.Is 如果我单击 ctrl+鼠标左键单击并将鼠标拖动到 select 地图上的一个矩形区域,我可能需要获取叠加层在那个特定区域列出?
是的,可以使用 DragBox 元素。
这样声明元素:
var dragBox = new ol.interaction.DragBox({
condition: ol.events.condition.platformModifierKeyOnly
});
并且您可以将其作为交互添加到您现有的地图中:
map.addInteraction(dragBox);
如果您想添加一些行为,可以调用事件 boxstart 和 boxend:
dragBox.on('boxstart', function() {
// Your stuff when the box starts being drawn
});
dragBox.on('boxend', function() {
// Your stuff when the box is already drawn
});
您将在 OpenLayers 3 API 中找到更多信息:http://openlayers.org/en/latest/apidoc/ol.interaction.DragBox.html
您还可以在此处查看框选择示例:https://openlayers.org/en/latest/examples/box-selection.html