diff --git a/api/web/src/components/CloudTAK/Map.vue b/api/web/src/components/CloudTAK/Map.vue index fe0901de0..c07471aca 100644 --- a/api/web/src/components/CloudTAK/Map.vue +++ b/api/web/src/components/CloudTAK/Map.vue @@ -372,7 +372,8 @@ export default { const turl = window.stdurl('/api/basemap'); turl.searchParams.append('type', 'raster-dem'); - /* + + /* Disabled for now const terrains = await window.std(turl); if (terrains.items.length > 0) { terrain = terrains.items[0]; @@ -383,7 +384,7 @@ export default { mapStore.init(this.$refs.map, basemap); mapStore.map.once('load', async () => { - mapStore.initLayers(basemap); + await mapStore.initLayers(basemap); const iconsets = await window.std('/api/iconset'); for (const iconset of iconsets.items) { diff --git a/api/web/src/stores/map.js b/api/web/src/stores/map.js index 13f4d5c4e..5c94b1c19 100644 --- a/api/web/src/stores/map.js +++ b/api/web/src/stores/map.js @@ -86,7 +86,7 @@ export const useMapStore = defineStore('cloudtak', { } if (layer.save && !config.initial) { - await overlayStore.saveOverlay({ + layer.overlay = await overlayStore.saveOverlay({ ...layer, url: layer.type === 'vector' ? new URL(layer.url).pathname : layer.url, visible: layer.visible === 'visible' ? true : false @@ -115,13 +115,7 @@ export const useMapStore = defineStore('cloudtak', { if (pos === false) return const layer = this.layers[pos]; - for (const l of layer.layers) { - this.map.removeLayer(l.id); - } - - await this.map.removeSource(source); - - this.layers.splice(pos, 1) + await this.removeLayer(layer.name); }, getLayerPos: function(name, key='name') { for (let i = 0; i < this.layers.length; i++) { @@ -278,7 +272,6 @@ export const useMapStore = defineStore('cloudtak', { type: 'raster', source: layer.id }]); - } }, initLayers: async function(basemap) { @@ -341,20 +334,21 @@ export const useMapStore = defineStore('cloudtak', { }); }, initOverlays: async function() { - for (const layer of (await window.std('/api/profile/overlay')).items) { - if (layer.mode == 'mission') { - layer.overlay = layer.id; - layer.id = `${layer.mode}-${layer.mode_id}-${layer.id}`; - layer.save = true; - await this.addDefaultLayer(layer, true) + await overlayStore.list(); + for (const overlay of overlayStore.overlays) { + if (overlay.mode == 'mission') { + overlay.overlay = overlay.id; + overlay.id = `${overlay.mode}-${overlay.mode_id}-${overlay.id}`; + overlay.save = true; + await this.addDefaultLayer(overlay, true) } else { - const url = window.stdurl(layer.url); + const url = window.stdurl(overlay.url); url.searchParams.append('token', localStorage.token); - layer.url = String(url); - layer.overlay = layer.id; - layer.id = `${layer.mode}-${layer.mode_id}-${layer.id}`; - layer.save = true; - await this.addDefaultLayer(layer, true) + overlay.url = String(url); + overlay.overlay = overlay.id; + overlay.id = `${overlay.mode}-${overlay.mode_id}-${overlay.id}`; + overlay.save = true; + await this.addDefaultLayer(overlay, true) } } }, diff --git a/api/web/src/stores/overlays.js b/api/web/src/stores/overlays.js index a8f5f2aba..1ac1229df 100644 --- a/api/web/src/stores/overlays.js +++ b/api/web/src/stores/overlays.js @@ -8,6 +8,7 @@ export const useOverlayStore = defineStore('overlays', { state: () => { return { initialized: false, + overlays: [], subscriptions: new Map() } }, @@ -30,14 +31,16 @@ export const useOverlayStore = defineStore('overlays', { await this.list() }, list: async function() { - const list = await window.std(`/api/profile/overlay`); + this.overlays = (await window.std(`/api/profile/overlay`)).items; + this.subscriptions.clear(); - for (const sub of list.items) { + for (const sub of this.overlays) { if (sub.mode === 'mission') { // mode_id is GUID for mission type this.subscriptions.set(sub.mode_id, sub); } } + this.initialized = true; } },