Выбор полигонов OpenLayers 3
Как вы можете выбрать объекты с многоугольным рисованием? Это можно сделать с помощью квадратного прямоугольника, выбранного в соответствии с примерами.
Мне интересно, есть ли способ инициировать событие после создания многоугольника, чтобы проверить наличие пересечений с ним и другими функциями. В моем случае я пытаюсь захватить точки данных.
var select = new ol.interaction.Select();
map.addInteraction(select);
var selectedFeatures = select.getFeatures();
// a DragBox interaction used to select features by drawing boxes
var dragBox = new ol.interaction.DragBox({
condition: ol.events.condition.platformModifierKeyOnly
});
map.addInteraction(dragBox);
var infoBox = document.getElementById('info');
dragBox.on('boxend', function() {
// features that intersect the box are added to the collection of
// selected features, and their names are displayed in the "info"
// div
var info = [];
var extent = dragBox.getGeometry().getExtent();
vectorSource.forEachFeatureIntersectingExtent(extent, function(feature) {
selectedFeatures.push(feature);
info.push(feature.get('name'));
});
if (info.length > 0) {
infoBox.innerHTML = info.join(', ');
}
});
// clear selection when drawing a new box and when clicking on the map
dragBox.on('boxstart', function() {
selectedFeatures.clear();
infoBox.innerHTML = ' ';
});
map.on('click', function() {
selectedFeatures.clear();
infoBox.innerHTML = ' ';
});
Это возможно в открытых слоях 3?