I'm trying to check features inside a polygon:
function howinpol(evt) {
var polygon_extent = evt.feature.getGeometry().getExtent(); // get polygone extent
var starr_uli = "", arr_fdgdg = [];
mySource8.forEachFeatureIntersectingExtent(polygon_extent, function(feature) {
xl = parseFloat(feature.get('lon')); // get lon
yl = parseFloat(feature.get('lat')); // get lat
feature.setProperties({ visible: 'visible' }); // add prop
feature.setProperties({ inpol: 'in' }); // add prop
arr_fdgdg.push(feature); // add features
// list
starr_uli += '<li><span id="'+ feature.getId() +'">' + feature.get('name_kontr') + ' id:' + feature.getId() + '</span><small>'+ feature.get('billing_address_city') +', '+ feature.get('billing_address_street') +'</small></li>';
});
$('#objects ul').replaceWith('<ul>' + starr_uli + '</ul>'); //name list
$('#cntobj').text(arr_fdgdg.length); //count in list
mySource8.clear(); //clear
mySource8.addFeatures(arr_fdgdg); //add select features
}
but it is beyond the scope if draw a circle or freehand polygon:
I tried to wrap if(evt.feature.getGeometry().intersectsCoordinate([xl, yl])):
function howinpol(evt) {
var polygon_extent = evt.feature.getGeometry().getExtent(); // get polygone extent
var starr_uli = "", arr_fdgdg = [];
mySource8.forEachFeatureIntersectingExtent(polygon_extent, function(feature) {
xl = parseFloat(feature.get('lon')); // get lon
yl = parseFloat(feature.get('lat')); // get lat
if(evt.feature.getGeometry().intersectsCoordinate([xl, yl])){
feature.setProperties({ visible: 'visible' }); // add prop
feature.setProperties({ inpol: 'in' }); // add prop
arr_fdgdg.push(feature); // add features
// list
starr_uli += '<li><span id="'+ feature.getId() +'">' + feature.get('name_kontr') + ' id:' + feature.getId() + '</span><small>'+ feature.get('billing_address_city') +', '+ feature.get('billing_address_street') +'</small></li>';
}
});
$('#objects ul').replaceWith('<ul>' + starr_uli + '</ul>'); //name list
$('#cntobj').text(arr_fdgdg.length); //count in list
mySource8.clear(); //clear
mySource8.addFeatures(arr_fdgdg); //add select features
}
It worked, but it loops through a very long time.
have any thoughts?