在leaft.draw中,使用事件draw:deletestop,如何获取要删除的特定图层

In leaft.draw, using the event draw:deletestop, how can I get the specific layer that I want to delete

map.on('draw:deletestop',function(){
  //Here, I want to get the deleted layer
})

我使用了 leaflet(v1.3.3) 和 leaflet.draw(v0.4.2) 我可以吗?

根据 docs,您可以使用 draw:deleted 事件实现。

为了检索您删除的特定图层,您应执行以下操作:

map.on('draw:deleted', function (e) {
    // console.log(e.layers._layers);
    var deletedLayers = e.layers._layers;
    for (var layer in deletedLayers) {
       console.log(deletedLayers[layer]);
    }
})

演示:https://jsfiddle.net/6k4arymt/