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){