diff --git a/src/controls/draganddrop.js b/src/controls/draganddrop.js index 919cb25f7..f7836bfd4 100644 --- a/src/controls/draganddrop.js +++ b/src/controls/draganddrop.js @@ -71,6 +71,7 @@ const DragAndDrop = function DragAndDrop(options = {}) { const groupName = options.groupName || 'egna-lager'; const groupTitle = options.groupTitle || 'Egna lager'; const draggable = options.draggable || true; + const promptlessRemoval = options.promptlessRemoval !== false; const styleByAttribute = options.styleByAttribute || false; const featureStyles = options.featureStyles || { Point: [{ @@ -153,6 +154,7 @@ const DragAndDrop = function DragAndDrop(options = {}) { styleByAttribute, queryable: true, removable: true, + promptlessRemoval, visible: true, source: 'none', type: 'GEOJSON', diff --git a/src/controls/legend/overlay.js b/src/controls/legend/overlay.js index 2c4b0e23f..c8bd15414 100644 --- a/src/controls/legend/overlay.js +++ b/src/controls/legend/overlay.js @@ -222,10 +222,11 @@ const OverlayLayer = function OverlayLayer(options) { onRender() { const labelEl = document.getElementById(this.getId()); labelEl.addEventListener('click', (e) => { - if (window.confirm('Vill du radera lagret?')) { + const doRemove = (layer.get('promptlessRemoval') === true) || window.confirm('Vill du radera lagret?'); + if (doRemove) { viewer.getMap().removeLayer(layer); + e.preventDefault(); } - e.preventDefault(); }); }, render() {