【问题标题】:geoman - how to access the resulting GeoJSON object after a feature has been removed in removalModegeoman - 在removingMode中删除功能后如何访问生成的GeoJSON对象
【发布时间】:2021-01-12 22:25:02
【问题描述】:

我有一个 FeatureCollection 从中删除单个功能。我可以通过添加事件侦听器 pm:remove 来获取已删除的功能,如下所示:

layer.on('pm:remove', e => {
    // do stuff regarding the removed feature
    console.log(e.layer.feature)
});

我还想访问生成的 FeatureCollection(已从中删除该功能)。我怎样才能“console.log()”那个?

【问题讨论】:

    标签: leaflet geojson leaflet-geoman


    【解决方案1】:

    您是否将图层添加到图层组/功能组?然后就可以拨打layergroup.toGeoJSON()

    或者,如果您使用默认设置并将图层添加到地图,您可以致电map.pm.getGeomanLayers(true).toGeoJSON()true 表示它返回 L.FeatureGroup 而不是包含图层的数组。

    【讨论】:

    • map.pm.getGeomanLayers(true).toGeoJSON() 成功了。非常感谢!
    猜你喜欢
    • 2020-08-02
    • 1970-01-01
    • 2019-02-12
    • 1970-01-01
    • 2011-08-07
    • 1970-01-01
    • 2015-04-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多