如何在编辑控件中分配多个功能组,
Assume we have two feature groups(It can be multiple),and we want to assign edit control to both groups.
这是组,
var attLayerGroup = new L.FeatureGroup();
var photoLayerGroup = new L.FeatureGroup();
这就是,我如何将控制分配给组,
var drawControl = map.addControl(new L.Control.Draw({
edit: {
featureGroup: photoLayerGroup,attLayerGroup,
poly: {
allowIntersection: true
}
},
draw: {
polygon: {
allowIntersection: false,
showArea: true
}
}
}));
Is it right way to assigning Edit control to FeatureGroup ? If not,How can we do it?
最佳答案
如果您的 2 个初始特征组之间没有具体区别,则只需将每个图层的引用复制到新的父特征组中,并将后者用作 Leaflet.draw featureGroup
选项:
var fg = L.featureGroup();
photoLayerGroup.eachLayer(function (layer) {
if (!layer instanceof L.LayerGroup) {
fg.addLayer(layer);
}
});
// Same for attLayerGroup.
new L.Control.Draw({
edit: {
featureGroup: fg
}
});
https://stackoverflow.com/questions/44901381/