diff --git a/.github/workflows/type-build.yml b/.github/workflows/type-build.yml
index 9f432753adc..1e04329fe4c 100644
--- a/.github/workflows/type-build.yml
+++ b/.github/workflows/type-build.yml
@@ -4,6 +4,10 @@ on:
schedule:
- cron: "42 21 * * 5"
+env:
+ NODE_VERSION: "20.11.0"
+ PNPM_VERSION: "8.15.0"
+
jobs:
update_types:
runs-on: ubuntu-latest
diff --git a/docs/app/geoview-layer/map-config/draw.io/TypeMapConfig.drawio.svg b/docs/app/geoview-layer/map-config/draw.io/TypeMapConfig.drawio.svg
index a4167d14199..8b549cea01b 100644
--- a/docs/app/geoview-layer/map-config/draw.io/TypeMapConfig.drawio.svg
+++ b/docs/app/geoview-layer/map-config/draw.io/TypeMapConfig.drawio.svg
@@ -1097,7 +1097,7 @@
- TypeGeocoreLayerEntryConfig
+ TypeGeoCoreLayerEntryConfig
@@ -1106,7 +1106,7 @@
- TypeGeocoreLayerEntryConfig
+ TypeGeoCoreLayerEntryConfig
diff --git a/packages/geoview-core/public/locales/en/translation.json b/packages/geoview-core/public/locales/en/translation.json
index d36f888b48d..3a448634f78 100644
--- a/packages/geoview-core/public/locales/en/translation.json
+++ b/packages/geoview-core/public/locales/en/translation.json
@@ -157,7 +157,8 @@
"loadfailed": "Layer [__param__] failed to load on map __param__.",
"notfound": "The sublayer __param__ of the GeoView layer __param__ does not exist on the server",
"createtwice": "Can not execute twice the createGeoViewRasterLayers method for the map __param__",
- "usedtwice": "Duplicate use of geoview layer identifier [__param__] on map __param__"
+ "usedtwice": "Duplicate use of geoview layer identifier [__param__] on map __param__",
+ "multipleUUID": "GeoCore layers may only have one GeoCore UUID per layer"
},
"schema": {
"notFound": "A schema error was found, check the console to see what is wrong.",
@@ -219,4 +220,4 @@
"resizeTooltip": "Resize",
"noTab": "No Tab"
}
-}
\ No newline at end of file
+}
diff --git a/packages/geoview-core/public/locales/fr/translation.json b/packages/geoview-core/public/locales/fr/translation.json
index ec8819a6346..e81975d2d1e 100644
--- a/packages/geoview-core/public/locales/fr/translation.json
+++ b/packages/geoview-core/public/locales/fr/translation.json
@@ -157,7 +157,8 @@
"loadfailed": "Le chargement de la couche [__param__] a échoué sur la carte __param__.",
"notfound": "La sous couche __param__ de la couche GeoView __param__ n'existe pas sur le sereur",
"createtwice": "On ne peut exécuter deux fois la méthode createGeoViewRasterLayers pour la carte __param__",
- "usedtwice": "Utilisation en double de l'identifiant de couche geoview [__param__] sur la carte __param__"
+ "usedtwice": "Utilisation en double de l'identifiant de couche geoview [__param__] sur la carte __param__",
+ "multipleUUID": "Les couches GeoCore ne peuvent avoir qu'un seul UUID GeoCore par couche."
},
"schema": {
"notFound": "Une erreur de schéma a été trouvée, vérifiez la console pour voir ce qui ne va pas.",
@@ -219,4 +220,4 @@
"resizeTooltip": "Redimensionner",
"noTab": "Pas d'onglet"
}
-}
\ No newline at end of file
+}
diff --git a/packages/geoview-core/public/templates/layers/geocore.html b/packages/geoview-core/public/templates/layers/geocore.html
index 2e8aa977e98..2ece0cb1e25 100644
--- a/packages/geoview-core/public/templates/layers/geocore.html
+++ b/packages/geoview-core/public/templates/layers/geocore.html
@@ -76,20 +76,23 @@ 1. Many GeoCore Layers
'listOfGeoviewLayerConfig': [
{
'geoviewLayerType': 'geoCore',
+ 'geoviewLayerId': 'airborneRad',
'listOfLayerEntryConfig': [
{
- 'layerId': '0fe65119-e96e-4a57-8bfe-9d9245fba06b',
- 'geocoreLayerName': { 'en': 'HRDEM Mosaic Hillshade' },
+ 'layerId': '21b821cf-0f1c-40ee-8925-eab12d357668',
+ 'geocoreLayerName': { 'en': 'Airborne Radioactivity' },
'listOfLayerEntryConfig': [
{
- 'layerId': 'dsm-hillshade',
- 'layerName': { 'en': 'Map' },
- 'source': {
- 'style': 'hillshade'
- }
+ 'layerId': '0'
}
]
- },
+ }
+ ]
+ },
+ {
+ 'geoviewLayerType': 'geoCore',
+ 'geoviewLayerId': 'commem',
+ 'listOfLayerEntryConfig': [
{
'layerId': 'ccc75c12-5acc-4a6a-959f-ef6f621147b9',
'geocoreLayerName': { 'en': 'Commemorative Map' },
@@ -98,7 +101,13 @@ 1. Many GeoCore Layers
'layerId': '0'
}
]
- },
+ }
+ ]
+ },
+ {
+ 'geoviewLayerType': 'geoCore',
+ 'geoviewLayerId': 'MWQ',
+ 'listOfLayerEntryConfig': [
{
'layerId': '0fca08b5-e9d0-414b-a3c4-092ff9c5e326',
'geocoreLayerName': { 'en': 'Marine Water Quality' },
@@ -107,8 +116,13 @@ 1. Many GeoCore Layers
'layerId': '6'
}
]
-
- },
+ }
+ ]
+ },
+ {
+ 'geoviewLayerType': 'geoCore',
+ 'geoviewLayerId': 'napl',
+ 'listOfLayerEntryConfig': [
{
'layerId': '03ccfb5c-a06e-43e3-80fd-09d4f8f69703',
'geocoreLayerName': { 'en': 'NAPL Temporal Series' },
@@ -160,65 +174,86 @@ 2. GeoCore Layers - with footer bar
triggerReadyCallback="true"
data-lang="en"
data-config="{
- 'map': {
- 'interaction': 'dynamic',
- 'viewSettings': {
- 'zoom': 4,
- 'center': [-100, 60],
- 'projection': 3978
+ 'map': {
+ 'interaction': 'dynamic',
+ 'viewSettings': {
+ 'zoom': 4,
+ 'center': [-100, 60],
+ 'projection': 3978
+ },
+ 'basemapOptions': {
+ 'basemapId': 'transport',
+ 'shaded': false,
+ 'labeled': true
+ },
+ 'listOfGeoviewLayerConfig': [
+ {
+ 'geoviewLayerType': 'geoCore',
+ 'geoviewLayerId': 'airborneRad',
+ 'listOfLayerEntryConfig': [
+ {
+ 'layerId': '21b821cf-0f1c-40ee-8925-eab12d357668',
+ 'geocoreLayerName': { 'en': 'Airborne Radioactivity' },
+ 'listOfLayerEntryConfig': [
+ {
+ 'layerId': '0'
+ }
+ ]
+ }
+ ]
},
- 'basemapOptions': {
- 'basemapId': 'transport',
- 'shaded': false,
- 'labeled': true
+ {
+ 'geoviewLayerType': 'geoCore',
+ 'geoviewLayerId': 'commem',
+ 'listOfLayerEntryConfig': [
+ {
+ 'layerId': 'ccc75c12-5acc-4a6a-959f-ef6f621147b9',
+ 'geocoreLayerName': { 'en': 'Commemorative Map' },
+ 'listOfLayerEntryConfig': [
+ {
+ 'layerId': '0'
+ }
+ ]
+ }
+ ]
},
- 'listOfGeoviewLayerConfig': [
- {
- 'geoviewLayerType': 'geoCore',
- 'listOfLayerEntryConfig': [
- {
- 'layerId': 'ccc75c12-5acc-4a6a-959f-ef6f621147b9',
- 'geocoreLayerName': { 'en': 'Commemorative Map' },
- 'listOfLayerEntryConfig': [
- {
- 'layerId': '0'
- }
- ]
- },
- {
- 'layerId': '0fca08b5-e9d0-414b-a3c4-092ff9c5e326',
- 'geocoreLayerName': { 'en': 'Marine Water Quality' },
- 'listOfLayerEntryConfig': [
- {
- 'layerId': '6'
- }
- ]
-
- },
- {
- 'layerId': '03ccfb5c-a06e-43e3-80fd-09d4f8f69703',
- 'geocoreLayerName': { 'en': 'NAPL Temporal Series' },
- 'listOfLayerEntryConfig': [
- {
- 'layerId': 'regina',
- 'layerName': { 'en': 'Map of Regina' }
- }
- ]
- }
- ]
- }
- ]
- },
- 'components': ['overview-map'],
- 'footerBar': {
- 'tabs': {
- 'core': ['legend', 'layers', 'details', 'data-table']
+ {
+ 'geoviewLayerType': 'geoCore',
+ 'geoviewLayerId': 'MWQ',
+ 'listOfLayerEntryConfig': [
+ {
+ 'layerId': '0fca08b5-e9d0-414b-a3c4-092ff9c5e326',
+ 'geocoreLayerName': { 'en': 'Marine Water Quality' },
+ 'listOfLayerEntryConfig': [
+ {
+ 'layerId': '6'
+ }
+ ]
+ },
+ {
+ 'layerId': '03ccfb5c-a06e-43e3-80fd-09d4f8f69703',
+ 'geocoreLayerName': { 'en': 'NAPL Temporal Series' },
+ 'listOfLayerEntryConfig': [
+ {
+ 'layerId': 'regina',
+ 'layerName': { 'en': 'Map of Regina' }
+ }
+ ]
+ }
+ ]
}
- },
- 'corePackages': [],
- 'theme': 'geo.ca',
- 'suportedLanguages': ['en']
- }"
+ ]
+ },
+ 'components': ['overview-map'],
+ 'footerBar': {
+ 'tabs': {
+ 'core': ['legend', 'layers', 'details', 'data-table']
+ }
+ },
+ 'corePackages': [],
+ 'theme': 'geo.ca',
+ 'suportedLanguages': ['en']
+ }"
>
diff --git a/packages/geoview-core/schema.json b/packages/geoview-core/schema.json
index a96ecf9408c..86170f9c375 100644
--- a/packages/geoview-core/schema.json
+++ b/packages/geoview-core/schema.json
@@ -1110,7 +1110,7 @@
},
"required": ["schemaTag", "entryType", "layerId"]
},
- "TypeGeocoreLayerEntryConfig": {
+ "TypeGeoCoreLayerEntryConfig": {
"additionalProperties": false,
"type": "object",
"description": "Layer where configration is extracted by a configuration snippet stored on a server. The server configuration will handle bilangual informations.",
@@ -1221,7 +1221,7 @@
"$ref": "#/definitions/TypeTileLayerEntryConfig"
},
{
- "$ref": "#/definitions/TypeGeocoreLayerEntryConfig"
+ "$ref": "#/definitions/TypeGeoCoreLayerEntryConfig"
}
]
},
@@ -1396,7 +1396,7 @@
"$ref": "#/definitions/TypeLayerGroupEntryConfig"
},
{
- "$ref": "#/definitions/TypeGeocoreLayerEntryConfig"
+ "$ref": "#/definitions/TypeGeoCoreLayerEntryConfig"
}
]
}
diff --git a/packages/geoview-core/src/api/event-processors/event-processor-children/map-event-processor.ts b/packages/geoview-core/src/api/event-processors/event-processor-children/map-event-processor.ts
index c1280c151de..56e6a18332c 100644
--- a/packages/geoview-core/src/api/event-processors/event-processor-children/map-event-processor.ts
+++ b/packages/geoview-core/src/api/event-processors/event-processor-children/map-event-processor.ts
@@ -173,6 +173,24 @@ export class MapEventProcessor extends AbstractEventProcessor {
);
// #endregion FEATURE SELECTION
+ const unsubOrderedLayerInfo = store.subscribe(
+ (state) => state.mapState.orderedLayerInfo,
+ (cur) => {
+ // Log
+ logger.logTraceCoreStoreSubscription('MAP EVENT PROCESSOR - orderedLaterInfo', mapId, cur);
+
+ const curVisibleLayers = cur
+ .map((layerInfo) => {
+ if (layerInfo.visible) return layerInfo.layerPath;
+ return undefined;
+ })
+ .filter((layerPath) => layerPath);
+ const prevVisibleLayers = [...store.getState().mapState.visibleLayers];
+ if (JSON.stringify(prevVisibleLayers) !== JSON.stringify(curVisibleLayers))
+ store.getState().mapState.actions.setVisibleLayers(curVisibleLayers as string[]);
+ }
+ );
+
// Return the array of subscriptions so they can be destroyed later
return [
unsubMapHighlightedFeatures,
@@ -181,6 +199,7 @@ export class MapEventProcessor extends AbstractEventProcessor {
unsubMapPointerPosition,
unsubMapProjection,
unsubMapSelectedFeatures,
+ unsubOrderedLayerInfo,
unsubMapZoom,
unsubMapSingleClick,
];
@@ -421,15 +440,20 @@ export class MapEventProcessor extends AbstractEventProcessor {
*
* @param {string} mapId The ID of the map to add the layer to.
* @param {TypeGeoviewLayerConfig} geoviewLayerConfig The config of the layer to add.
+ * @param {string} layerPathToReplace The layerPath of the info to replace.
* @return {void}
*/
- static replaceOrderedLayerInfo(mapId: string, geoviewLayerConfig: TypeGeoviewLayerConfig | TypeLayerEntryConfig): void {
+ static replaceOrderedLayerInfo(
+ mapId: string,
+ geoviewLayerConfig: TypeGeoviewLayerConfig | TypeLayerEntryConfig,
+ layerPathToReplace?: string
+ ): void {
const { orderedLayerInfo } = this.getMapStateProtected(mapId);
const layerPath = (geoviewLayerConfig as TypeGeoviewLayerConfig).geoviewLayerId
? `${(geoviewLayerConfig as TypeGeoviewLayerConfig).geoviewLayerId}/${(geoviewLayerConfig as TypeGeoviewLayerConfig).geoviewLayerId}`
: (geoviewLayerConfig as TypeLayerEntryConfig).layerPath;
- const index = this.getMapIndexFromOrderedLayerInfo(mapId, layerPath);
- const replacedLayers = orderedLayerInfo.filter((layerInfo) => layerInfo.layerPath.startsWith(layerPath));
+ const index = this.getMapIndexFromOrderedLayerInfo(mapId, layerPathToReplace || layerPath);
+ const replacedLayers = orderedLayerInfo.filter((layerInfo) => layerInfo.layerPath.startsWith(layerPathToReplace || layerPath));
const newOrderedLayerInfo = api.maps[mapId].layer.generateArrayOfLayerOrderInfo(geoviewLayerConfig);
orderedLayerInfo.splice(index, replacedLayers.length, ...newOrderedLayerInfo);
this.setMapOrderedLayerInfo(mapId, orderedLayerInfo);
diff --git a/packages/geoview-core/src/core/components/data-table/data-panel.tsx b/packages/geoview-core/src/core/components/data-table/data-panel.tsx
index 7e5aa0bfae8..dec75c673b5 100644
--- a/packages/geoview-core/src/core/components/data-table/data-panel.tsx
+++ b/packages/geoview-core/src/core/components/data-table/data-panel.tsx
@@ -11,8 +11,8 @@ import {
useDetailsStoreActions,
useDetailsStoreAllFeaturesDataArray,
useUIActiveFooterBarTabId,
- useMapOrderedLayerInfo,
useDatatableStoreTableHeight,
+ useMapVisibleLayers,
} from '@/core/stores';
import { LayerListEntry, Layout } from '../common';
import { logger } from '@/core/utils/logger';
@@ -48,7 +48,7 @@ export function Datapanel({ fullWidth }: DataPanelType) {
const { setSelectedLayerPath } = useDataTableStoreActions();
const { triggerGetAllFeatureInfo } = useDetailsStoreActions();
const selectedTab = useUIActiveFooterBarTabId();
- const orderedLayerInfo = useMapOrderedLayerInfo();
+ const visibleLayers = useMapVisibleLayers();
// Create columns for data table.
const mappedLayerData = useFeatureFieldInfos(layerData);
@@ -57,17 +57,10 @@ export function Datapanel({ fullWidth }: DataPanelType) {
* Order the layers by visible layer order.
*/
const orderedLayerData = useMemo(() => {
- const visibleLayers = orderedLayerInfo
- .map((layerInfo) => {
- if (layerInfo.visible) return layerInfo.layerPath;
- return undefined;
- })
- .filter((layerPath) => layerPath !== undefined);
-
return visibleLayers
.map((layerPath) => mappedLayerData.filter((data) => data.layerPath === layerPath)[0])
.filter((layer) => layer !== undefined);
- }, [mappedLayerData, orderedLayerInfo]);
+ }, [mappedLayerData, visibleLayers]);
/**
* Update local states when layer is changed from layer list.
diff --git a/packages/geoview-core/src/core/components/details/details-panel.tsx b/packages/geoview-core/src/core/components/details/details-panel.tsx
index 358d5179f6e..8841fe1ddd4 100644
--- a/packages/geoview-core/src/core/components/details/details-panel.tsx
+++ b/packages/geoview-core/src/core/components/details/details-panel.tsx
@@ -14,7 +14,7 @@ import {
import { TypeFeatureInfoEntry, TypeLayerData, TypeGeometry, TypeArrayOfFeatureInfoEntries } from '@/api/events/payloads';
import {
useMapStoreActions,
- useMapOrderedLayerInfo,
+ useMapVisibleLayers,
useDetailsStoreActions,
useDetailsStoreCheckedFeatures,
useDetailsStoreLayerDataArrayBatch,
@@ -48,7 +48,7 @@ export function DetailsPanel({ fullWidth }: DetailsPanelType): JSX.Element {
const selectedLayerPath = useDetailsStoreSelectedLayerPath();
const arrayOfLayerDataBatch = useDetailsStoreLayerDataArrayBatch();
const checkedFeatures = useDetailsStoreCheckedFeatures();
- const orderedLayerInfo = useMapOrderedLayerInfo();
+ const visibleLayers = useMapVisibleLayers();
const { setSelectedLayerPath, removeCheckedFeature, setLayerDataArrayBatchLayerPathBypass } = useDetailsStoreActions();
const { addSelectedFeature, removeSelectedFeature } = useMapStoreActions();
@@ -122,16 +122,7 @@ export function DetailsPanel({ fullWidth }: DetailsPanelType): JSX.Element {
*/
const memoLayersList = useMemo(() => {
// Log
- logger.logTraceUseMemo('DETAILS-PANEL - memoLayersList', orderedLayerInfo, arrayOfLayerDataBatch);
-
- const visibleLayers = orderedLayerInfo
- .map((layerInfo) => {
- if (layerInfo.visible) return layerInfo.layerPath;
- return undefined;
- })
- .filter((layerPath) => layerPath !== undefined);
-
- if (!visibleLayers.includes(selectedLayerPath)) setSelectedLayerPath('');
+ logger.logTraceUseMemo('DETAILS-PANEL - memoLayersList', visibleLayers, arrayOfLayerDataBatch);
// Set the layers list
const layerListEntries = visibleLayers
@@ -151,7 +142,7 @@ export function DetailsPanel({ fullWidth }: DetailsPanelType): JSX.Element {
);
if (!layerListEntries.length) setSelectedLayerPath('');
return layerListEntries;
- }, [orderedLayerInfo, arrayOfLayerDataBatch, selectedLayerPath, setSelectedLayerPath, getNumFeaturesLabel]);
+ }, [visibleLayers, arrayOfLayerDataBatch, setSelectedLayerPath, getNumFeaturesLabel]);
/**
* Memoizes the selected layer for the LayerList component.
diff --git a/packages/geoview-core/src/core/components/layers/hooks/helpers.ts b/packages/geoview-core/src/core/components/layers/hooks/helpers.ts
index f8a0f21545f..38a87859ecf 100644
--- a/packages/geoview-core/src/core/components/layers/hooks/helpers.ts
+++ b/packages/geoview-core/src/core/components/layers/hooks/helpers.ts
@@ -1,3 +1,4 @@
+// TODO Remove when no longer needed
import _ from 'lodash';
import { TypeVectorLayerStyles } from '@/geo/layer/geoview-layers/abstract-geoview-layers';
import { api } from '@/app';
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 3f754ed4361..1f5bd4a93f2 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
@@ -415,11 +415,11 @@ export function AddNewLayer(): JSX.Element {
const geoCoreGeoviewLayerInstance = new GeoCore(mapId);
const layers = await geoCoreGeoviewLayerInstance.createLayersFromUUID(layerURL);
if (layers.length === 1) {
- if (layers[0].length === 1) {
- setLayerName(layers[0][0].geoviewLayerName!.en! as string);
- setLayerEntries(layers[0]);
+ if (layers.length === 1) {
+ setLayerName(layers[0].geoviewLayerName!.en! as string);
+ setLayerEntries(layers);
} else {
- setLayerList(layers[0]);
+ setLayerList(layers);
}
}
} catch (err) {
diff --git a/packages/geoview-core/src/core/components/legend/legend.tsx b/packages/geoview-core/src/core/components/legend/legend.tsx
index ee46eda8e12..5761a6e5a7b 100644
--- a/packages/geoview-core/src/core/components/legend/legend.tsx
+++ b/packages/geoview-core/src/core/components/legend/legend.tsx
@@ -2,7 +2,7 @@ import { useTheme } from '@mui/material';
import { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Box, Paper, Typography } from '@/ui';
-import { useLayerLegendLayers, useMapOrderedLayerInfo, useLayerStoreActions } from '@/core/stores/';
+import { useLayerLegendLayers, useMapVisibleLayers, useLayerStoreActions } from '@/core/stores/';
import { logger } from '@/core/utils/logger';
import { getSxClasses } from './legend-styles';
@@ -28,7 +28,7 @@ export function Legend({ fullWidth }: LegendType): JSX.Element {
const [formattedLegendLayerList, setFormattedLegendLayersList] = useState([]);
// store state
- const orderedLayerInfo = useMapOrderedLayerInfo();
+ const visibleLayers = useMapVisibleLayers();
const layersList = useLayerLegendLayers();
const { getLayer } = useLayerStoreActions();
@@ -73,15 +73,7 @@ export function Legend({ fullWidth }: LegendType): JSX.Element {
useEffect(() => {
// Log
- logger.logTraceUseEffect('LEGEND - orderedLayerInfo', orderedLayerInfo.length, orderedLayerInfo);
-
- const visibleLayers = orderedLayerInfo
- .map((layerInfo) => {
- if (layerInfo.visible) return layerInfo.layerPath;
- return undefined;
- })
- .filter((layerPath) => layerPath !== undefined);
-
+ logger.logTraceUseEffect('LEGEND - visibleLayers', visibleLayers.length, visibleLayers);
// Loop on the visible layers to retrieve the valid TypeLegendLayer objects
const parentPaths: string[] = [];
@@ -100,7 +92,7 @@ export function Legend({ fullWidth }: LegendType): JSX.Element {
updateLegendLayerListByWindowSize(layers);
// eslint-disable-next-line react-hooks/exhaustive-deps
- }, [orderedLayerInfo, layersList]);
+ }, [visibleLayers, layersList]);
useEffect(() => {
// Log
diff --git a/packages/geoview-core/src/core/stores/store-interface-and-intial-values/map-state.ts b/packages/geoview-core/src/core/stores/store-interface-and-intial-values/map-state.ts
index e10d48c5348..ca7689de54c 100644
--- a/packages/geoview-core/src/core/stores/store-interface-and-intial-values/map-state.ts
+++ b/packages/geoview-core/src/core/stores/store-interface-and-intial-values/map-state.ts
@@ -65,6 +65,7 @@ export interface IMapState {
scale: TypeScaleInfo;
selectedFeatures: Array;
size: [number, number];
+ visibleLayers: string[];
zoom: number;
setDefaultConfigValues: (config: TypeMapFeaturesConfig) => void;
@@ -109,6 +110,7 @@ export interface IMapState {
setProjection: (projectionCode: TypeValidMapProjectionCodes, view: View) => void;
setQueryable: (layerPath: string, queryable: boolean) => void;
setRotation: (degree: number) => void;
+ setVisibleLayers: (newOrder: string[]) => void;
setZoom: (zoom: number, duration?: number) => void;
showClickMarker: (marker: TypeClickMarker) => void;
transformPoints: (coords: Coordinate[], outputProjection: number) => Coordinate[];
@@ -151,6 +153,7 @@ export function initializeMapState(set: TypeSetStore, get: TypeGetStore): IMapSt
scale: { lineWidth: '', labelGraphic: '', labelNumeric: '' } as TypeScaleInfo,
selectedFeatures: [],
size: [0, 0] as [number, number],
+ visibleLayers: [],
zoom: 0,
// initialize default stores section from config information when store receive configuration file
@@ -548,6 +551,14 @@ export function initializeMapState(set: TypeSetStore, get: TypeGetStore): IMapSt
// State is set by the map state store event 'onMapRotation'
get().mapState.mapElement!.getView().animate({ rotation: degree });
},
+ setVisibleLayers: (newOrder: string[]) => {
+ set({
+ mapState: {
+ ...get().mapState,
+ visibleLayers: newOrder,
+ },
+ });
+ },
setZoom: (zoom: number, duration?: number) => {
// set ol map zoom
// State is set by the map state store event 'onMapZoomEnd'
@@ -627,6 +638,7 @@ export const useMapRotation = () => useStore(useGeoViewStore(), (state) => state
export const useMapSelectedFeatures = () => useStore(useGeoViewStore(), (state) => state.mapState.selectedFeatures);
export const useMapScale = () => useStore(useGeoViewStore(), (state) => state.mapState.scale);
export const useMapSize = () => useStore(useGeoViewStore(), (state) => state.mapState.size);
+export const useMapVisibleLayers = () => useStore(useGeoViewStore(), (state) => state.mapState.visibleLayers);
export const useMapZoom = () => useStore(useGeoViewStore(), (state) => state.mapState.zoom);
export const useMapStoreActions = () => useStore(useGeoViewStore(), (state) => state.mapState.actions);
diff --git a/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts b/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts
index 3ab7fae7055..84e1901aea9 100644
--- a/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts
+++ b/packages/geoview-core/src/geo/layer/geoview-layers/abstract-geoview-layers.ts
@@ -249,7 +249,7 @@ export const CONST_GEOVIEW_SCHEMA_BY_TYPE: Record
esriFeature: 'TypeVectorLayerEntryConfig',
esriImage: 'TypeEsriImageLayerEntryConfig',
GeoJSON: 'TypeVectorLayerEntryConfig',
- geoCore: 'TypeGeocoreLayerEntryConfig',
+ geoCore: 'TypeGeoCoreLayerEntryConfig',
GeoPackage: 'TypeVectorLayerEntryConfig',
xyzTiles: 'TypeTileLayerEntryConfig',
vectorTiles: 'TypeTileLayerEntryConfig',
diff --git a/packages/geoview-core/src/geo/layer/layer.ts b/packages/geoview-core/src/geo/layer/layer.ts
index 55af110a905..8a26908e49a 100644
--- a/packages/geoview-core/src/geo/layer/layer.ts
+++ b/packages/geoview-core/src/geo/layer/layer.ts
@@ -9,7 +9,7 @@ import { EVENT_NAMES } from '@/api/events/event-types';
import { MapEventProcessor } from '@/api/event-processors/event-processor-children/map-event-processor';
import { Config } from '@/core/utils/config/config';
-import { generateId, showError, replaceParams, getLocalizedMessage, whenThisThen } from '@/core/utils/utilities';
+import { generateId, showError, replaceParams, getLocalizedMessage, whenThisThen, addNotificationError } from '@/core/utils/utilities';
import {
layerConfigPayload,
payloadIsALayerConfig,
@@ -21,6 +21,7 @@ import { AbstractGeoViewLayer } from '@/geo/layer/geoview-layers/abstract-geovie
import {
TypeGeoviewLayerConfig,
TypeLayerEntryConfig,
+ TypeListOfGeoviewLayerConfig,
TypeListOfLocalizedLanguages,
layerEntryIsGroupLayer,
} from '@/geo/map/map-schema-types';
@@ -100,11 +101,9 @@ export class Layer {
if (layerConfigIsGeoCore(layerConfig)) {
const geoCore = new GeoCore(this.mapId);
- geoCore.createLayers(layerConfig).then((arrayOfListOfGeoviewLayerConfig) => {
- arrayOfListOfGeoviewLayerConfig.forEach((listOfGeoviewLayerConfig) => {
- listOfGeoviewLayerConfig.forEach((geoviewLayerConfig) => {
- this.addGeoviewLayer(geoviewLayerConfig);
- });
+ geoCore.createLayers(layerConfig).then((listOfGeoviewLayerConfig: TypeListOfGeoviewLayerConfig) => {
+ listOfGeoviewLayerConfig.forEach((geoviewLayerConfig) => {
+ this.addGeoviewLayer(geoviewLayerConfig);
});
});
} else if (layerConfigIsGeoJSON(layerConfig)) {
@@ -202,9 +201,23 @@ export class Layer {
* @returns {TypeOrderedLayerInfo[]} The array of ordered layer info.
*/
generateArrayOfLayerOrderInfo(geoviewLayerConfig: TypeGeoviewLayerConfig | TypeLayerEntryConfig): TypeOrderedLayerInfo[] {
- // TODO Add placeholder for geocore and the replacement when the layer is created in geocore.ts
- if ((geoviewLayerConfig as TypeGeoviewLayerConfig).geoviewLayerType === 'geoCore') return [];
- const newOrderedLayerInfos = [];
+ const newOrderedLayerInfos: TypeOrderedLayerInfo[] = [];
+
+ if ((geoviewLayerConfig as TypeGeoviewLayerConfig).geoviewLayerType === 'geoCore') {
+ geoviewLayerConfig.listOfLayerEntryConfig?.forEach((layerEntryConfig) => {
+ const layerInfo: TypeOrderedLayerInfo = {
+ layerPath: layerEntryConfig.layerId,
+ alwaysVisible: false,
+ visible: true,
+ removable: true,
+ queryable: true,
+ hoverable: true,
+ };
+ newOrderedLayerInfos.push(layerInfo);
+ });
+ return newOrderedLayerInfos;
+ }
+
const addSubLayerPathToLayerOrder = (layerEntryConfig: TypeLayerEntryConfig, layerPath: string): void => {
const subLayerPath = layerPath.endsWith(layerEntryConfig.layerId) ? layerPath : `${layerPath}/${layerEntryConfig.layerId}`;
const layerInfo: TypeOrderedLayerInfo = {
@@ -222,6 +235,7 @@ export class Layer {
});
}
};
+
if ((geoviewLayerConfig as TypeGeoviewLayerConfig).geoviewLayerId) {
if ((geoviewLayerConfig as TypeGeoviewLayerConfig).listOfLayerEntryConfig.length > 1) {
const layerPath = `${(geoviewLayerConfig as TypeGeoviewLayerConfig).geoviewLayerId}/${
@@ -252,7 +266,7 @@ export class Layer {
* @param {TypeGeoviewLayerConfig[]} geoviewLayerConfigs an optional array containing layers passed within the map config
*/
loadListOfGeoviewLayer(geoviewLayerConfigs?: TypeGeoviewLayerConfig[]) {
- const validGeoviewLayerConfigs = this.deleteDuplicatGeoviewLayerConfig(geoviewLayerConfigs);
+ const validGeoviewLayerConfigs = this.deleteDuplicatAndMultipleUuidGeoviewLayerConfig(geoviewLayerConfigs);
// set order for layers to appear on the map according to config
const orderedLayerInfos: TypeOrderedLayerInfo[] = [];
@@ -271,18 +285,24 @@ export class Layer {
*
* @returns {TypeGeoviewLayerConfig} The new configuration with duplicate entries eliminated.
*/
- private deleteDuplicatGeoviewLayerConfig(geoviewLayerConfigs?: TypeGeoviewLayerConfig[]): TypeGeoviewLayerConfig[] {
+ private deleteDuplicatAndMultipleUuidGeoviewLayerConfig(geoviewLayerConfigs?: TypeGeoviewLayerConfig[]): TypeGeoviewLayerConfig[] {
if (geoviewLayerConfigs && geoviewLayerConfigs.length > 0) {
const validGeoviewLayerConfigs = geoviewLayerConfigs.filter((geoviewLayerConfigToCreate, configToCreateIndex) => {
- for (let configToTestIndex = 0; configToTestIndex < geoviewLayerConfigs.length; configToTestIndex++)
+ for (let configToTestIndex = 0; configToTestIndex < geoviewLayerConfigs.length; configToTestIndex++) {
+ if (layerConfigIsGeoCore(geoviewLayerConfigToCreate) && geoviewLayerConfigToCreate.listOfLayerEntryConfig.length > 1) {
+ logger.logError('GeoCore layers may only have one GeoCore UUID per layer');
+ addNotificationError(this.mapId, getLocalizedMessage(this.mapId, 'validation.layer.multipleUUID'));
+ return false;
+ }
if (
geoviewLayerConfigToCreate.geoviewLayerId === geoviewLayerConfigs[configToTestIndex].geoviewLayerId &&
- // We keep the first instance of the duplicat entry.
+ // We keep the first instance of the duplicate entry.
configToCreateIndex > configToTestIndex
) {
this.printDuplicateGeoviewLayerConfigError(geoviewLayerConfigToCreate);
return false;
}
+ }
return true;
});
return validGeoviewLayerConfigs;
@@ -441,7 +461,7 @@ export class Layer {
addGeoviewLayerByGeoCoreUUID = async (uuid: string): Promise => {
const geoCoreGeoviewLayerInstance = new GeoCore(this.mapId);
const layers = await geoCoreGeoviewLayerInstance.createLayersFromUUID(uuid);
- layers[0].forEach((geoviewLayerConfig) => {
+ layers.forEach((geoviewLayerConfig) => {
api.maps[this.mapId].layer.addGeoviewLayer(geoviewLayerConfig);
});
};
diff --git a/packages/geoview-core/src/geo/layer/other/geocore.ts b/packages/geoview-core/src/geo/layer/other/geocore.ts
index 78046d5483a..96d49c4f9c8 100644
--- a/packages/geoview-core/src/geo/layer/other/geocore.ts
+++ b/packages/geoview-core/src/geo/layer/other/geocore.ts
@@ -10,7 +10,7 @@ import { MapEventProcessor } from '@/api/event-processors/event-processor-childr
import {
TypeLayerEntryConfig,
TypeGeoviewLayerConfig,
- TypeGeocoreLayerEntryConfig,
+ TypeGeoCoreLayerEntryConfig,
TypeListOfGeoviewLayerConfig,
TypeLocalizedString,
layerEntryIsGroupLayer,
@@ -21,11 +21,11 @@ import { CONST_LAYER_TYPES, TypeGeoviewLayerType } from '../geoview-layers/abstr
export interface TypeGeoCoreLayerConfig extends Omit {
geoviewLayerType: 'geoCore';
- listOfLayerEntryConfig: TypeGeocoreLayerEntryConfig[];
+ listOfLayerEntryConfig: TypeGeoCoreLayerEntryConfig[];
}
/** *****************************************************************************************************************************
- * type guard function that redefines a TypeLayerEntryConfig as a TypeGeocoreLayerEntryConfig if the geoviewLayerType attribute of
+ * type guard function that redefines a TypeLayerEntryConfig as a TypeGeoCoreLayerEntryConfig if the geoviewLayerType attribute of
* the verifyIfGeoViewEntry.geoviewLayerConfig attribute is GEOCORE. The type ascention applies only to the true block of the if
* clause that use this function.
*
@@ -34,7 +34,7 @@ export interface TypeGeoCoreLayerConfig extends Omit {
+export const geoviewEntryIsGeoCore = (verifyIfGeoViewEntry: TypeLayerEntryConfig): verifyIfGeoViewEntry is TypeGeoCoreLayerEntryConfig => {
return verifyIfGeoViewEntry?.geoviewLayerConfig?.geoviewLayerType === CONST_LAYER_TYPES.GEOCORE;
};
@@ -81,12 +81,12 @@ export class GeoCore {
geoviewLayerId: generateId(),
geoviewLayerType: 'geoCore',
listOfLayerEntryConfig: [
- new TypeGeocoreLayerEntryConfig({
+ new TypeGeoCoreLayerEntryConfig({
schemaTag: 'geoCore' as TypeGeoviewLayerType,
entryType: 'geoCore' as TypeLayerEntryType,
layerId: uuid,
- } as TypeGeocoreLayerEntryConfig),
- ] as TypeGeocoreLayerEntryConfig[],
+ } as TypeGeoCoreLayerEntryConfig),
+ ] as TypeGeoCoreLayerEntryConfig[],
} as TypeGeoCoreLayerConfig;
}
@@ -96,7 +96,7 @@ export class GeoCore {
* @param {string} uuid the given uuid to build the Geocore Layer Config with
* @returns {Promise} the GeoCore Layer Config promise
*/
- createLayersFromUUID(uuid: string): Promise {
+ createLayersFromUUID(uuid: string): Promise {
// Create the config
const geocoreConfig = GeoCore.buildGeocoreLayerConfigFromUUID(uuid);
@@ -107,65 +107,58 @@ export class GeoCore {
/**
* Gets GeoView layer configurations list from the UUIDs of the list of layer entry configurations.
*
- * @param {TypeGeocoreLayerEntryConfig} geocoreLayerConfig the layer configuration
+ * @param {TypeGeoCoreLayerEntryConfig} geocoreLayerConfig the layer configuration
* @returns {Promise} list of layer configurations to add to the map
*/
- async createLayers(geocoreLayerConfig: TypeGeoCoreLayerConfig): Promise {
+ async createLayers(geocoreLayerConfig: TypeGeoCoreLayerConfig): Promise {
// Get the map config
const mapConfig = MapEventProcessor.getGeoViewMapConfig(this.mapId);
- // For each layer entry config in the list
- const listOfLayerCreated: TypeListOfGeoviewLayerConfig[] = [];
- for (let i = 0; i < geocoreLayerConfig.listOfLayerEntryConfig.length; i++) {
- // Get the config
- const layerConfig = geocoreLayerConfig.listOfLayerEntryConfig[i];
-
- // Get the language
- const lang = api.maps[this.mapId].getDisplayLanguage();
-
- // Generate the url using metadataAccessPath when specified or using the geocore url
- const url = geocoreLayerConfig.metadataAccessPath?.[lang] || `${mapConfig!.serviceUrls.geocoreUrl}`;
- const uuid = layerConfig.layerId;
-
- try {
- // Get the GV config from UUID and await even if within loop
- // eslint-disable-next-line no-await-in-loop
- const response = await UUIDmapConfigReader.getGVConfigFromUUIDs(url, lang, [uuid]);
-
- // Cumulate
- listOfLayerCreated.push(response.layers);
-
- // For each found layer associated with the Geocore UUIDs
- response.layers.forEach((geoviewLayerConfig) => {
- this.copyConfigSettingsOverGeocoreSettings(layerConfig, geoviewLayerConfig);
- });
- this.configValidation.validateListOfGeoviewLayerConfig(AppEventProcessor.getSupportedLanguages(this.mapId), response.layers);
-
- // For each found geochart associated with the Geocore UUIDs
- response.geocharts?.forEach((geochartConfig) => {
- // Add a GeoChart
- GeochartEventProcessor.addGeochartChart(this.mapId, geochartConfig.layers[0].layerId as string, geochartConfig);
- });
- } catch (error) {
- // Log
- logger.logError(`Failed to get the GeoView layer from UUI ${uuid}`, error);
- const message = replaceParams([error as TypeJsonValue, this.mapId], getLocalizedMessage(this.mapId, 'validation.layer.loadfailed'));
- showError(this.mapId, message);
- }
+ // Get the config
+ const layerConfig = geocoreLayerConfig.listOfLayerEntryConfig[0];
+
+ // Get the language
+ const lang = api.maps[this.mapId].getDisplayLanguage();
+
+ // Generate the url using metadataAccessPath when specified or using the geocore url
+ const url = geocoreLayerConfig.metadataAccessPath?.[lang] || `${mapConfig!.serviceUrls.geocoreUrl}`;
+ const uuid = layerConfig.layerId;
+
+ try {
+ // Get the GV config from UUID and await even if within loop
+ // eslint-disable-next-line no-await-in-loop
+ const response = await UUIDmapConfigReader.getGVConfigFromUUIDs(url, lang, [uuid]);
+
+ // For each found layer associated with the Geocore UUIDs
+ response.layers.forEach((geoviewLayerConfig) => {
+ this.copyConfigSettingsOverGeocoreSettings(layerConfig, geoviewLayerConfig);
+ });
+ this.configValidation.validateListOfGeoviewLayerConfig(AppEventProcessor.getSupportedLanguages(this.mapId), response.layers);
+
+ // For each found geochart associated with the Geocore UUIDs
+ response.geocharts?.forEach((geochartConfig) => {
+ // Add a GeoChart
+ GeochartEventProcessor.addGeochartChart(this.mapId, geochartConfig.layers[0].layerId as string, geochartConfig);
+ });
+
+ return response.layers;
+ } catch (error) {
+ // Log
+ logger.logError(`Failed to get the GeoView layer from UUI ${uuid}`, error);
+ const message = replaceParams([error as TypeJsonValue, this.mapId], getLocalizedMessage(this.mapId, 'validation.layer.loadfailed'));
+ showError(this.mapId, message);
}
-
- // Return the created layers
- return listOfLayerCreated;
+ return Promise.resolve([]);
}
/**
* Copies the config settings over the geocore values (config values have priority).
*
- * @param {TypeGeocoreLayerEntryConfig} geocoreLayerEntryConfig The config file settings
+ * @param {TypeGeoCoreLayerEntryConfig} geocoreLayerEntryConfig The config file settings
* @param {TypeGeoviewLayerConfig} geoviewLayerConfig The settings returned by the geocore service
*/
private copyConfigSettingsOverGeocoreSettings(
- geocoreLayerEntryConfig: TypeGeocoreLayerEntryConfig,
+ geocoreLayerEntryConfig: TypeGeoCoreLayerEntryConfig,
geoviewLayerConfig: TypeGeoviewLayerConfig
) {
if (geocoreLayerEntryConfig.geocoreLayerName)
diff --git a/packages/geoview-core/src/geo/map/map-schema-types.ts b/packages/geoview-core/src/geo/map/map-schema-types.ts
index da09feaeb07..961d14d71f9 100644
--- a/packages/geoview-core/src/geo/map/map-schema-types.ts
+++ b/packages/geoview-core/src/geo/map/map-schema-types.ts
@@ -611,7 +611,7 @@ export const layerEntryIsRasterTile = (verifyIfLayer: TypeLayerEntryConfig): ver
};
/** ******************************************************************************************************************************
- * type guard function that redefines a TypeLayerEntryConfig as a TypeGeocoreLayerEntryConfig if the entryType attribute of
+ * type guard function that redefines a TypeLayerEntryConfig as a TypeGeoCoreLayerEntryConfig if the entryType attribute of
* the verifyIfLayer parameter is 'geocore'. The type ascention applies only to the true block of the if clause that use
* this function.
*
@@ -619,7 +619,7 @@ export const layerEntryIsRasterTile = (verifyIfLayer: TypeLayerEntryConfig): ver
*
* @returns {boolean} true if the type ascention is valid.
*/
-export const layerEntryIsGeocore = (verifyIfLayer: TypeLayerEntryConfig): verifyIfLayer is TypeGeocoreLayerEntryConfig => {
+export const layerEntryIsGeocore = (verifyIfLayer: TypeLayerEntryConfig): verifyIfLayer is TypeGeoCoreLayerEntryConfig => {
return verifyIfLayer?.entryType === ('geoCore' as TypeLayerEntryType);
};
@@ -1385,7 +1385,7 @@ export class TypeTileLayerEntryConfig extends TypeBaseLayerEntryConfig {
* Type used to define a GeoView layer where configration is extracted by a configuration snippet stored on a server. The server
* configuration will handle bilangual informations.
*/
-export class TypeGeocoreLayerEntryConfig extends ConfigBaseClass {
+export class TypeGeoCoreLayerEntryConfig extends ConfigBaseClass {
/** This attribute from ConfigBaseClass is not used by groups. */
declare isMetadataLayerGroup: never;
@@ -1418,9 +1418,9 @@ export class TypeGeocoreLayerEntryConfig extends ConfigBaseClass {
/**
* The class constructor.
- * @param {TypeGeocoreLayerEntryConfig} layerConfig The layer configuration we want to instanciate.
+ * @param {TypeGeoCoreLayerEntryConfig} layerConfig The layer configuration we want to instanciate.
*/
- constructor(layerConfig: TypeGeocoreLayerEntryConfig) {
+ constructor(layerConfig: TypeGeoCoreLayerEntryConfig) {
super(layerConfig);
Object.assign(this, layerConfig);
}
@@ -1531,7 +1531,7 @@ export type TypeLayerEntryConfig =
| TypeImageStaticLayerEntryConfig
| TypeTileLayerEntryConfig
| TypeLayerGroupEntryConfig
- | TypeGeocoreLayerEntryConfig;
+ | TypeGeoCoreLayerEntryConfig;
/** ******************************************************************************************************************************
* List of layers. Corresponds to the layerList defined in the schema.
diff --git a/packages/geoview-core/src/geo/utils/layer-set.ts b/packages/geoview-core/src/geo/utils/layer-set.ts
index ff0109f2682..4890a25ee02 100644
--- a/packages/geoview-core/src/geo/utils/layer-set.ts
+++ b/packages/geoview-core/src/geo/utils/layer-set.ts
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
+import { MapEventProcessor } from '@/api/event-processors/event-processor-children/map-event-processor';
import { EVENT_NAMES } from '@/api/events/event-types';
import {
LayerSetPayload,
@@ -144,6 +145,7 @@ export class LayerSet {
};
if (this.registrationUserInitialisation) this.registrationUserInitialisation(layerPath);
} else if (action === 'remove' && layerPath in this.resultSet) {
+ MapEventProcessor.removeOrderedLayerInfo(this.mapId, layerPath);
delete this.resultSet[layerPath];
}
api.event.emit(LayerSetPayload.createLayerSetUpdatedPayload(this.layerSetId, this.resultSet, layerPath));
diff --git a/packages/geoview-core/src/geo/utils/legends-layer-set.ts b/packages/geoview-core/src/geo/utils/legends-layer-set.ts
index 160fb825ef4..0f49a5d39ae 100644
--- a/packages/geoview-core/src/geo/utils/legends-layer-set.ts
+++ b/packages/geoview-core/src/geo/utils/legends-layer-set.ts
@@ -125,7 +125,9 @@ export class LegendsLayerSet extends LayerSet {
const { layerPath } = payload;
if (MapEventProcessor.getMapIndexFromOrderedLayerInfo(this.mapId, layerPath) === -1) {
const layerConfig = api.maps[this.mapId].layer.registeredLayers[layerPath];
- if (layerConfig.parentLayerConfig) {
+ if (MapEventProcessor.getMapIndexFromOrderedLayerInfo(this.mapId, layerPath.split('.')[1]) !== -1) {
+ MapEventProcessor.replaceOrderedLayerInfo(this.mapId, layerConfig, layerPath.split('.')[1]);
+ } else if (layerConfig.parentLayerConfig) {
const parentLayerPathArray = layerPath.split('/');
parentLayerPathArray.pop();
const parentLayerPath = parentLayerPathArray.join('/');
diff --git a/packages/geoview-geochart/src/geochart-panel.tsx b/packages/geoview-geochart/src/geochart-panel.tsx
index b667a11b80c..258c00eb4fc 100644
--- a/packages/geoview-geochart/src/geochart-panel.tsx
+++ b/packages/geoview-geochart/src/geochart-panel.tsx
@@ -1,12 +1,12 @@
import { useTheme } from '@mui/material/styles';
-import { TypeOrderedLayerInfo, TypeWindow, getLocalizedMessage } from 'geoview-core';
+import { TypeWindow, getLocalizedMessage } from 'geoview-core';
import { ChartType, SchemaValidator } from 'geochart';
import { LayerListEntry, Layout } from 'geoview-core/src/core/components/common';
import { TypeLayerData, TypeArrayOfLayerData } from 'geoview-core/src/api/events/payloads/get-feature-info-payload';
import { Typography } from 'geoview-core/src/ui/typography/typography';
import { Paper } from 'geoview-core/src/ui';
import {
- useMapOrderedLayerInfo,
+ useMapVisibleLayers,
useGeochartConfigs,
useGeochartStoreActions,
useGeochartStoreLayerDataArrayBatch,
@@ -42,7 +42,7 @@ export function GeoChartPanel(props: GeoChartPanelProps): JSX.Element {
// Get states and actions from store
const configObj = useGeochartConfigs();
- const orderedLayerInfo = useMapOrderedLayerInfo() as TypeOrderedLayerInfo[];
+ const visibleLayers = useMapVisibleLayers() as string[];
const storeArrayOfLayerData = useGeochartStoreLayerDataArrayBatch() as TypeArrayOfLayerData;
const selectedLayerPath = useGeochartStoreSelectedLayerPath() as string;
const { setSelectedLayerPath, setLayerDataArrayBatchLayerPathBypass } = useGeochartStoreActions();
@@ -102,13 +102,6 @@ export function GeoChartPanel(props: GeoChartPanelProps): JSX.Element {
// Log
logger.logTraceUseMemo('GEOCHART-PANEL - memoLayersList', storeArrayOfLayerData);
- const visibleLayers = orderedLayerInfo
- .map((layerInfo) => {
- if (layerInfo.visible) return layerInfo.layerPath;
- return undefined;
- })
- .filter((layerPath) => layerPath !== undefined);
-
// Set the layers list
return visibleLayers
.map((layerPath) => storeArrayOfLayerData.find((layerData) => layerData.layerPath === layerPath))
@@ -125,7 +118,7 @@ export function GeoChartPanel(props: GeoChartPanelProps): JSX.Element {
tooltip: `${layer!.layerName}, ${getNumFeaturesLabel(layer!)}`,
} as LayerListEntry)
);
- }, [orderedLayerInfo, storeArrayOfLayerData, configObj, getNumFeaturesLabel]);
+ }, [visibleLayers, storeArrayOfLayerData, configObj, getNumFeaturesLabel]);
/**
* Memoizes the selected layer for the LayerList component.
diff --git a/packages/geoview-time-slider/src/time-slider-panel.tsx b/packages/geoview-time-slider/src/time-slider-panel.tsx
index 17190b56a0b..15a6b35771a 100644
--- a/packages/geoview-time-slider/src/time-slider-panel.tsx
+++ b/packages/geoview-time-slider/src/time-slider-panel.tsx
@@ -1,7 +1,7 @@
import { useTheme } from '@mui/material/styles';
-import { TypeOrderedLayerInfo, TypeWindow, getLocalizedMessage } from 'geoview-core';
+import { TypeWindow, getLocalizedMessage } from 'geoview-core';
import { LayerListEntry, Layout } from 'geoview-core/src/core/components/common';
-import { useMapOrderedLayerInfo, useTimeSliderLayers } from 'geoview-core/src/core/stores';
+import { useMapVisibleLayers, useTimeSliderLayers } from 'geoview-core/src/core/stores';
import { Paper, Typography } from 'geoview-core/src/ui';
import { logger } from 'geoview-core/src/core/utils/logger';
@@ -33,7 +33,7 @@ export function TimeSliderPanel(props: TypeTimeSliderProps): JSX.Element {
const [selectedLayerPath, setSelectedLayerPath] = useState();
// get values from store
- const orderedLayerInfo = useMapOrderedLayerInfo() as TypeOrderedLayerInfo[];
+ const visibleLayers = useMapVisibleLayers() as string[];
const timeSliderLayers = useTimeSliderLayers();
/**
@@ -53,13 +53,6 @@ export function TimeSliderPanel(props: TypeTimeSliderProps): JSX.Element {
// Log
logger.logTraceUseMemo('TIME-SLIDER-PANEL - memoLayersList', timeSliderLayers);
- const visibleLayers = orderedLayerInfo
- .map((layerInfo) => {
- if (layerInfo.visible) return layerInfo.layerPath;
- return undefined;
- })
- .filter((layerPath) => layerPath !== undefined);
-
// Return the layers
return visibleLayers
.map((layerPath) => {
@@ -75,7 +68,7 @@ export function TimeSliderPanel(props: TypeTimeSliderProps): JSX.Element {
queryStatus: 'processed',
} as LayerListEntry;
});
- }, [orderedLayerInfo, timeSliderLayers]);
+ }, [visibleLayers, timeSliderLayers]);
useEffect(() => {
// Log