From 017f6451eaa6da59ae29a2e74262473f878f5ed1 Mon Sep 17 00:00:00 2001 From: Ahmad Ayubi Date: Thu, 25 Feb 2021 09:24:41 -0500 Subject: [PATCH] Check disabled on layer remove, fix readding of controls overlay --- src/mapml-viewer.js | 2 +- src/mapml/layers/MapLayer.js | 1 + src/web-map.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mapml-viewer.js b/src/mapml-viewer.js index dc22fb5b5..59daddc35 100644 --- a/src/mapml-viewer.js +++ b/src/mapml-viewer.js @@ -254,7 +254,7 @@ export class MapViewer extends HTMLElement { } } - if (!this.controlslist.toLowerCase().includes("nolayer") && !this._layerControl){ + if (!this.controlslist.toLowerCase().includes("nolayer") && !this._layerControl && this.layers.length > 0){ this._layerControl = M.mapMlLayerControl(null,{"collapsed": true, mapEl: this}).addTo(this._map); //if this is the initial setup the layers dont need to be readded, causes issues if they are if(!setup){ diff --git a/src/mapml/layers/MapLayer.js b/src/mapml/layers/MapLayer.js index ecd1fc790..f7ba56411 100644 --- a/src/mapml/layers/MapLayer.js +++ b/src/mapml/layers/MapLayer.js @@ -296,6 +296,7 @@ export var MapMLLayer = L.Layer.extend({ if (this._templatedLayer) { map.removeLayer(this._templatedLayer); } + map.fire("checkdisabled"); map.off("popupopen", this._attachSkipButtons); }, getZoomBounds: function () { diff --git a/src/web-map.js b/src/web-map.js index 0e9c414b3..95fec7064 100644 --- a/src/web-map.js +++ b/src/web-map.js @@ -288,7 +288,7 @@ export class WebMap extends HTMLMapElement { } } - if (!this.controlslist.toLowerCase().includes("nolayer") && !this._layerControl){ + if (!this.controlslist.toLowerCase().includes("nolayer") && !this._layerControl && this.layers.length > 0){ this._layerControl = M.mapMlLayerControl(null,{"collapsed": true, mapEl: this}).addTo(this._map); //if this is the initial setup the layers dont need to be readded, causes issues if they are if(!setup){