gpt4 book ai didi

javascript - 在传单绘制的编辑控件中分配多个功能组

转载 作者:行者123 更新时间:2023-12-05 08:08:56 25 4
gpt4 key购买 nike

如何在编辑控件中分配多个功能组,

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
}
});

关于javascript - 在传单绘制的编辑控件中分配多个功能组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44901381/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com