I don't have much experience in Leaflet and I'm trying to learn from my mistakes. I have multiple polygons (just polygons) and some that have a polyline on top of it grouped as a featureGroup
like:
var drawnItems = new L.FeatureGroup();
var mark = L.polygon(otherPoly, { title: 'testSimple', fillColor: 'blue', fillOpacity: 0.5, weight:20, color: 'green', opacity: 0.5, fill: true});
drawnItems.addLayer(mark);
var featureGroup = new L.featureGroup();
L.polygon(poly, { title: 'test', fillColor: '#F16E60', fillOpacity: 0.5, weight:20, color: '#F16E60', opacity: 0.5, fill: true}).addTo(featureGroup);
L.polyline(poly, { color: 'black', weight: '5', opacity: 0.7, dashArray: "10 10", clickable: false }).addTo(featureGroup);
drawnItems.addLayer(featureGroup);
poly = [
[27.409550697482818, -82.4161570071192],
[27.408793809505223, -82.41609048836837],
[27.40876330512483, -82.41643166538779],
[27.409230402899265, -82.41645312305991],
[27.409567856048245, -82.41651105870916]]
I also have the drawControl
:
var drawControl = new L.Control.Draw({
edit: {
featureGroup: drawnItems,
edit: {
selectedPathOptions: {
maintainColor: true,
opacity: 0.3,
}
},
},
draw: {
marker: false,
polyline: false,
rectangle: false,
circle: false,
circlemarker: false,
polygon: {
icon: new L.DivIcon({
iconSize: new L.Point(10, 10),
className: 'leaflet-div-icon leaflet-editing-icon'
}),
shapeOptions: { color: 'white', opacity: 0.3, fillOpacity: 0.5, weight: 20 },
showArea: true,
}
}
});
but the editing is not applying to the polygon
from inside featureGroup
.
Is there a way to edit the polygon from featureGroup? To remove the polyline when edit mode is on, and to allow the user to change polygon shape?