From 6607a85f0ddd6d4f20f128e9da42cdec5da80f82 Mon Sep 17 00:00:00 2001 From: MatthewMuehlhauserNRCan Date: Wed, 11 Dec 2024 11:46:06 -0500 Subject: [PATCH] Set initial geocore layer name 793 --- .../left-panel/add-new-layer/add-new-layer.tsx | 13 ++++++++++--- .../geoview-core/src/geo/layer/other/geocore.ts | 3 +++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx b/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx index 10389f713cd..20f0616a8ff 100644 --- a/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx +++ b/packages/geoview-core/src/core/components/layers/left-panel/add-new-layer/add-new-layer.tsx @@ -429,7 +429,7 @@ export function AddNewLayer(): JSX.Element { const geoCoreGeoviewLayerInstance = new GeoCore(mapId, api.maps[mapId].getDisplayLanguage()); const layers = await geoCoreGeoviewLayerInstance.createLayersFromUUID(layerURL); - if (layers.length === 1) { + if (layers.length >= 1) { if (layers.length === 1) { setLayerName(layers[0].geoviewLayerName!); setLayerEntries(layers); @@ -883,8 +883,15 @@ export function AddNewLayer(): JSX.Element { }); } else if (layerEntries.length > 0) { (layerEntries as TypeGeoviewLayerConfig[]).forEach((geoviewLayerConfig) => { - const addedLayer = api.maps[mapId].layer.addGeoviewLayer(geoviewLayerConfig); - if (addedLayer) addedLayers.push(addedLayer); + if (layerName !== geoviewLayerConfig.geoviewLayerName) { + const tempConfig = geoviewLayerConfig; + tempConfig.listOfLayerEntryConfig[0].layerName = layerName; + const addedLayer = api.maps[mapId].layer.addGeoviewLayer(tempConfig); + if (addedLayer) addedLayers.push(addedLayer); + } else { + const addedLayer = api.maps[mapId].layer.addGeoviewLayer(geoviewLayerConfig); + if (addedLayer) addedLayers.push(addedLayer); + } }); } diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts index c6d19448e16..83fa53f9e32 100644 --- a/packages/geoview-core/src/geo/layer/other/geocore.ts +++ b/packages/geoview-core/src/geo/layer/other/geocore.ts @@ -50,6 +50,9 @@ export class GeoCore { // Validate the generated Geoview Layer Config ConfigValidation.validateListOfGeoviewLayerConfig(this.#displayLanguage, response.layers); + // Set the Layer Name for the main layer + if (layerConfig?.geoviewLayerName) response.layers[0].listOfLayerEntryConfig[0].layerName = layerConfig.geoviewLayerName; + // Set the initialSettings parameter if present if (layerConfig?.initialSettings) { for (let i = 0; i < response.layers.length; i++) {