Skip to content

Commit

Permalink
Set initial geocore layer name 793
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewMuehlhauserNRCan committed Dec 11, 2024
1 parent d405979 commit 6607a85
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
});
}

Expand Down
3 changes: 3 additions & 0 deletions packages/geoview-core/src/geo/layer/other/geocore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit 6607a85

Please sign in to comment.