Disable dragging on the legend
This commit is contained in:
parent
d91e0bd8ad
commit
6041378e44
1 changed files with 10 additions and 9 deletions
|
@ -2,6 +2,14 @@ function layer_legend(layer) {
|
||||||
return '<span class="dot" style="background: ' + layer["color"] + '" ></span>' + layer["name"];
|
return '<span class="dot" style="background: ' + layer["color"] + '" ></span>' + layer["name"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function disable_events(element) {
|
||||||
|
L.DomEvent.disableClickPropagation(element);
|
||||||
|
element.addEventListener('mouseover', L.DomEvent.stopPropagation);
|
||||||
|
element.addEventListener('click', L.DomEvent.preventDefault)
|
||||||
|
element.addEventListener('click', L.DomEvent.stopPropagation)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const rules = new Array;
|
const rules = new Array;
|
||||||
const l = new Array;
|
const l = new Array;
|
||||||
const legend = L.control({position: 'bottomleft'});
|
const legend = L.control({position: 'bottomleft'});
|
||||||
|
@ -10,6 +18,7 @@ legend.onAdd = function (map) {
|
||||||
for (let i = 0; i < l.length; i++) {
|
for (let i = 0; i < l.length; i++) {
|
||||||
div.innerHTML += layer_legend(l[i]) + "<br>";
|
div.innerHTML += layer_legend(l[i]) + "<br>";
|
||||||
}
|
}
|
||||||
|
disable_events(div);
|
||||||
return div;
|
return div;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -313,15 +322,7 @@ if (edit) {
|
||||||
customButton.onAdd = () => {
|
customButton.onAdd = () => {
|
||||||
const buttonDiv = L.DomUtil.create('div', 'legend');
|
const buttonDiv = L.DomUtil.create('div', 'legend');
|
||||||
if ("showDirectoryPicker" in window) {
|
if ("showDirectoryPicker" in window) {
|
||||||
// const button = L.DomUtil.create('button');
|
disable_events(buttonDiv)
|
||||||
// button.id = 'edit-mode';
|
|
||||||
// button.innerHTML = 'Edit';
|
|
||||||
// buttonDiv.appendChild(button)
|
|
||||||
// button.addEventListener('click', pickDirectory, this)
|
|
||||||
L.DomEvent.disableClickPropagation(buttonDiv);
|
|
||||||
buttonDiv.addEventListener('mouseover', L.DomEvent.stopPropagation);
|
|
||||||
buttonDiv.addEventListener('click', L.DomEvent.preventDefault)
|
|
||||||
buttonDiv.addEventListener('click', L.DomEvent.stopPropagation)
|
|
||||||
buttonDiv.innerHTML = `<button id="edit-mode" onClick="pickDirectory(event)" >Edit</button>
|
buttonDiv.innerHTML = `<button id="edit-mode" onClick="pickDirectory(event)" >Edit</button>
|
||||||
<div class="edit-ui">
|
<div class="edit-ui">
|
||||||
<div id="layername" ></div>
|
<div id="layername" ></div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue