diff --git a/app.js b/app.js index 617b8b3..a9f338e 100644 --- a/app.js +++ b/app.js @@ -27,6 +27,7 @@ import { taimkateWorkaround, getVisibleLayers, compareVisibleLayers, + setNoBasemap, } from "./modules/layers.js"; import { setupWebScene, setupWebView } from "./modules/scene.js"; import { @@ -172,6 +173,8 @@ view.when(() => { loadWMStile(basemaps, view); + setNoBasemap(basemaps, view); + /************************************** * Geology layer group **************************************/ @@ -231,7 +234,6 @@ view.when(() => { * Measurement 3D **************************************/ - setupMeasurement(view); /************************************** @@ -271,22 +273,6 @@ view.when(() => { **************************************/ const initVisibleLayers = getVisibleLayers(view); - const basemapSwitch = document.getElementById("basemapSwitch"); - basemapSwitch.addEventListener("calciteCheckboxChange", () => { - basemaps.disabled = !basemaps.disabled; - - view.map.allLayers.forEach((layer) => { - - // TODO kuidagi peab määrama orto wms ka - if (layer.type === "web-tile") { - layer.visible = !layer.visible - } - - }) - - }); - - /************************************** * Calcite CSS/JS **************************************/ diff --git a/modules/elevation.js b/modules/elevation.js index 69075cc..869b079 100644 --- a/modules/elevation.js +++ b/modules/elevation.js @@ -49,4 +49,6 @@ const setupElevationLayer = (url, title) => { }); }; + + export { elevationManipulation, setupElevationLayer }; diff --git a/modules/layerList.js b/modules/layerList.js index 426cddd..d04b48a 100644 --- a/modules/layerList.js +++ b/modules/layerList.js @@ -202,7 +202,7 @@ const setupBasemapGallery = (view) => { }; const loadWMStile = (basemaps, view) => { - console.log(basemaps) + basemaps.watch("activeBasemap", () => { const isOrtofoto = basemaps.activeBasemap.title === "Ortofoto"; diff --git a/modules/layers.js b/modules/layers.js index 3713944..f988065 100644 --- a/modules/layers.js +++ b/modules/layers.js @@ -113,6 +113,24 @@ const compareVisibleLayers = (initVisibleLayers, visibleLayersCurrently) => { return [regularLayers, elevationChanged]; }; +const setNoBasemap = (basemaps, view) => { + const basemapSwitch = document.getElementById("basemapSwitch"); + let currentBasemap; + basemapSwitch.addEventListener("calciteCheckboxChange", () => { + if (basemaps.activeBasemap.title !== "Basemap") { + currentBasemap = basemaps.activeBasemap; + } + + if (basemapSwitch.checked) { + view.map.basemap = {}; + } else { + view.map.basemap = currentBasemap; + } + + basemaps.disabled = !basemaps.disabled; + }); +}; + export { setupGraphicsLayer, setupInternalLayer, @@ -122,4 +140,5 @@ export { getGeologyLayers, getVisibleLayers, compareVisibleLayers, + setNoBasemap };