Trying to extract the drawn features on openlayers. I have written the below code and it is working fine when we draw polygon on four objects. But, when we try to draw polygon on three objects it is returning four features instead of three, not sure why the function(evt.feature.getGeometry().getExtent()) is returning four features when polygon drawn on three objects on a map.
draw = new ol.interaction.Draw({
source: sourceMeasure,
type: /** @type {ol.geom.GeometryType} */ ('Polygon')
});
openlayerMap.addInteraction(draw);
draw.on('drawstart',
function(evt) {
// set sketch
}, this);
draw.on('drawend',
function(evt) {
var extent = evt.feature.getGeometry().getExtent();
vectorSource.forEachFeatureIntersectingExtent(extent, function(feature) {
var layer = feature.get('LAYER');
/* here my logic is written and it working fine with four coordinates */
});
}, this);