Is there a way to retrieve all markers within polygons in Leaflet's draw
? How do I accomplish this?
To create the markers:
for (let i = 0; i < addressPoints.length; i++) {
var point = addressPoints[i];
var marker = L.marker(new L.LatLng(point["lat"], point["lng"]))
.on('click', onClickMarker);
markers.addLayer(marker);
}
After creating the markers, draw the polygon:
map.on(L.Draw.Event.CREATED, function (e) {
var layer = e.layer;
drawnItems.addLayer(layer);
var polygon = layer.getLatLngs();
console.log(polygon);
});
My goal is to retrieve all the markers located within the specified polygon
.