mapbox-gl-draw
mapbox-gl-draw copied to clipboard
How to add custom code to trash button click?
Hi, this code fires on standard "zoom in/out etc." mapbox controls, but nothing happens on draw trash icon click. Any thoughts how to access "trash" icon click event? Thanks
document.querySelector("#map").addEventListener("click", function (e) {
console.log('', this, e);
//mapbox-gl-draw_ctrl-draw-btn mapbox-gl-draw_trash
})
map.on('draw.delete', function (e) {
console.log('deleted');
});
deleteFeature(){
let _id = this.draw.getSelectedIds();
this.draw.delete(_id)
}
You can bind this function on your custom button
looks like this question was answered
This won't fire if there is nothing to delete