I'm working on a project with Mapbox and I want to customize how I draw the polygon, basically I want to allow point delete on button click and keep in drawing mode.I implemented the behavior, but the point does not get deleted.
I appreciate your help!
var description = "<button id='popup'> Button</button>"
function handlePop(coords) {
var feature = { type: 'Point', coordinates: coords };
draw.delete(feature);
}
let point = 0;
map.on('click', () => {
const coords = draw.getAll().features[0].geometry.coordinates[0];
if (point) {
new mapboxgl.Popup({ closeButton: false })
.setLngLat(coords[point])
.setHTML(description)
.addTo(map);
document.getElementById('popup').addEventListener('click', handlePop(coords[point]));
}
point++;
});
