I would like to have all the points highlighted within the other highlighted GeoJSON polygon.
Next, I would like to have them displayed in the panel next to or at least in the console (for now).
The problem is, that code I provided doesn't work. I can't see these points anywhere.
var ptsWithin = turf.within(placesLayer.toGeoJSON(), total.toGeoJSON());
map.on('draw:created', function (e) {
placesLayer.clearLayers();
layer = e.layer;
placesLayer.addLayer(layer);
GetSelection(placesLayer);
});
function GetSelection(layer){
var shape2 = placesLayer.toGeoJSON() //All facilities
var ptsWithin = turf.within(total, layer.toGeoJSON());
alert('Found ' + ptsWithin.features.length + ' features');
alert("results "+JSON.stringify(ptsWithin));
};
which I've picked up from here:
Leaflet and Turf.js Points within poly
I also tried another approach:
var eclplaces = total.toGeoJSON().geometry.coordinates
placesLayer.eachLayer(function (layer) {
if(turf.booleanContains(eclplaces, layer.toGeoJSON().geometry.coordinates)){
selPts.push(layer.feature);
}
but with no effect at all.
The same as this code:
Determine if a point reside inside a leaflet polygon
Is there any way to highlight and list the points, which are located inside the highlighted polygon?
My full code is here:
UPDATE:
I found another option here:
https://github.com/hayeswise/Leaflet.PointInPolygon
Determine if a point reside inside a leaflet polygon
but these functions are not suitable with my problem.
from Leaflet highlight GeoJSON points within the other highlighted GeoJSON polygon
No comments:
Post a Comment