Draw.delete programmatically is not removing features from the map
Hi,
I am new to this library. I am trying to remove some features (created programmatically) using Draw.delete(id) but they are not removed from the map, even if they are no more listed in the Draw.getAll() . Any idea?
Is there a way to redraw all the features?
Thanks for your help Giorgio
@ghigio2000 Can you please post a minimal reproducible case as suggested in the new issue template:
- Include a link to a minimal demonstration of the bug. We recommend using https://jsbin.com
@ghigio2000 Can you please post a minimal reproducible case as suggested in the new issue template:
- Include a link to a minimal demonstration of the bug. We recommend using https://jsbin.com
Not OP, but can provide a link to recreate this issue: https://jsfiddle.net/xqpuvb78/19/
Load that, click on the polygon, then click off the polygon so that no geometry is selected. The routine executed checks if selected feature count is nil and, if so, instructs Mapbox Draw to deleteAll. After doing so, the geometry remains. If you try and click on the geometry again, your web browser's console will be lit up red.
Having the same issue, this is definitely a bug, and can be easily reproduced as per @Nicksil 's instructions.
Having the same issue too when using it in React framework.
I found that if I call deleteAll in draw.delete callback, the features are still on the map. But when I call it in click callback of a button, it works !
Finally, I use setTimeout to solve my problem temporarily like below.
map.on('draw.delete', () => {
setTimeout(() => {
draw.deleteAll()
}, 0)
})
But why ? I have no much ideas.