[英]How to reference the deleted layers in Leaflet.draw?
I am trying to delete a Leaflet.draw layer from my database in firestore.我正在尝试从 Firestore 中的数据库中删除 Leaflet.draw 层。 I can easily delete it from the database side, but i struggle with connecting the document name with the layer name.
我可以轻松地从数据库端删除它,但我很难将文档名称与图层名称连接起来。
More specifically, i can't seem to get the id of the layer to be deleted/edited.更具体地说,我似乎无法获得要删除/编辑的图层的 ID。 Once i have that i should be able to connect it to the document id
一旦我有了它,我应该能够将它连接到文档 ID
This is what i got currently:这是我目前得到的:
map.on(L.Draw.Event.DELETED, e => {
this.deleteMarkerAnnotation(this.dummyValue)
console.log(e.propagatedFrom.layers.eachLayer(layer => { console.log(layer) }))
})
I get an error: Cannot read property 'layers' of undefined我收到一个错误:无法读取未定义的属性“层”
propagatedFrom is indeed undefined
.传播的确实是
undefined
。 It is not provided on the event object事件 object 中未提供
just remove propagatedFrom
and use e.layers
instead.只是删除了
propagatedFrom
并改用e.layers
。
map.on(L.Draw.Event.DELETED, e => {
e.layers.eachLayer(layer => {
console.log(layer)
});
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.