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

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

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/

相关文章:

.net-core - 带有私钥的证书.Net Core

ios - react-native-maps 为每个区域填充颜色

sql - 使用 create table as select 时避免重复列名

sql - 使用 SQL 查询将 Excel 数据加载到 Azure SQL 中

sql - 错误 : "Connection failed: SQLState: ' 08001'

sql - 如何动态选择非空值列?

spring - 集成测试中的 Autowire JUnit 规则

python - 从 Sphinx autodoc 扩展中的文档中排除静态成员

python - 如何从 YouTube 搜索中抓取视频?

angularjs - headless Chrome : chrome not reachable