Skip to content

Commit db13a21

Browse files
committed
Changes layer- elements to reflect change in controls
1 parent 5e1655f commit db13a21

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

src/layer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export class MapLayer extends HTMLElement {
7171
// this is moved up here so that the layer control doesn't respond
7272
// to the layer being removed with the _onLayerChange execution
7373
// that is set up in _attached:
74+
if(this.hasAttribute("moving")) return;
7475
this._removeEvents();
7576
if (this._layer._map) {
7677
this._layer._map.removeLayer(this._layer);
@@ -83,6 +84,7 @@ export class MapLayer extends HTMLElement {
8384
connectedCallback() {
8485
//creates listener that waits for createmap event, this allows for delayed builds of maps
8586
//this allows a safeguard for the case where loading a custom TCRS takes longer than loading mapml-viewer.js/web-map.js
87+
if(this.hasAttribute("moving")) return;
8688
this.parentNode.addEventListener('createmap', ()=>{
8789
this._ready();
8890
// if the map has been attached, set this layer up wrt Leaflet map

src/mapml.css

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
border: none;
139139
margin: 0;
140140
padding: 0;
141+
cursor: grab;
141142
}
142143

143144
.leaflet-control-layers-overlays > fieldset > .mapml-control-layers > summary,
@@ -278,12 +279,6 @@
278279
* User interaction.
279280
*/
280281

281-
/* Disable dragging of controls. */
282-
.leaflet-control :not([draggable="true"]),
283-
.mapml-contextmenu :not([draggable="true"]) {
284-
-webkit-user-drag: none;
285-
}
286-
287282
/* Disable text selection in controls. */
288283
.leaflet-control,
289284
.mapml-contextmenu,

src/mapml/layers/MapLayer.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ export var MapMLLayer = L.Layer.extend({
488488
opacityControl = document.createElement('details'),
489489
opacityControlSummary = document.createElement('summary'),
490490
opacityControlSummaryLabel = document.createElement('label'),
491-
root = this._layerEl.parentElement.shadowRoot, map = this._map;
491+
root = this._layerEl.parentElement.shadowRoot, map = this._map, viewer = this._layerEl.parentNode;
492492

493493
input.defaultChecked = this._map ? true: false;
494494
input.type = 'checkbox';
@@ -554,6 +554,11 @@ export var MapMLLayer = L.Layer.extend({
554554
layers = map.getPane("overlayPane").children,
555555
zIndex = 1;
556556
for(let control of controls){
557+
let layerEl = control.querySelector("span").layer._layerEl;
558+
layerEl.setAttribute("moving","");
559+
viewer.insertAdjacentElement("beforeend", layerEl);
560+
layerEl.removeAttribute("moving");
561+
557562
for (let layer of layers){
558563
if(control.querySelector("span").layer._container == layer){
559564
layer.style["z-index"] = zIndex;
@@ -564,19 +569,6 @@ export var MapMLLayer = L.Layer.extend({
564569
};
565570

566571
L.DomEvent.on(opacity,'change', this._changeOpacity, this);
567-
/* L.DomEvent.on(details,'ondrag', function(event) {
568-
console.log("HERE2");
569-
// will have to figure out how to drag and drop a whole element
570-
// with its contents in the case where the <layer->content</layer->
571-
// has no src but does have inline content.
572-
// Should be do-able, I think.
573-
if (this._href) {
574-
event.dataTransfer.setData("text/uri-list",this._href);
575-
// Why use a second .setData("text/plain"...) ? This is very important:
576-
// See https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#link
577-
event.dataTransfer.setData("text/plain", this._href);
578-
}
579-
}, this); */
580572

581573
fieldset.appendChild(details);
582574
details.appendChild(summary);

0 commit comments

Comments
 (0)