diff --git a/packages/geoview-core/src/api/event-processors/event-processor-children/geochart-event-processor.ts b/packages/geoview-core/src/api/event-processors/event-processor-children/geochart-event-processor.ts index 07f5cdcc949..b0d943c8e39 100644 --- a/packages/geoview-core/src/api/event-processors/event-processor-children/geochart-event-processor.ts +++ b/packages/geoview-core/src/api/event-processors/event-processor-children/geochart-event-processor.ts @@ -10,22 +10,6 @@ import { AbstractEventProcessor, BatchedPropagationLayerDataArrayByMap } from '. * Event processor focusing on interacting with the geochart state in the store. */ export class GeochartEventProcessor extends AbstractEventProcessor { - // ********************************************************** - // Static functions for Typescript files to access store actions - // ********************************************************** - //! Typescript MUST always use the defined store actions below to modify store - NEVER use setState! - //! Some action does state modifications AND map actions. - //! ALWAYS use map event processor when an action modify store and IS NOT trap by map state event handler - - // #region - // Holds the list of layer data arrays being buffered in the propagation process for the batch - static batchedPropagationLayerDataArray: BatchedPropagationLayerDataArrayByMap = {}; - - // The time delay between propagations in the batch layer data array. - // The longer the delay, the more the layers will have a chance to get in a loaded state before changing the layerDataArray. - // The longer the delay, the longer it'll take to update the UI. The delay can be bypassed using the layer path bypass method. - static timeDelayBetweenPropagationsForBatch = 2000; - /** * Overrides initialization of the GeoChart Event Processor * @param {GeoviewStoreType} store The store associated with the GeoChart Event Processor @@ -67,6 +51,22 @@ export class GeochartEventProcessor extends AbstractEventProcessor { return [unsubLayerRemoved, layerDataArrayUpdate]; } + // ********************************************************** + // Static functions for Typescript files to access store actions + // ********************************************************** + //! Typescript MUST always use the defined store actions below to modify store - NEVER use setState! + //! Some action does state modifications AND map actions. + //! ALWAYS use map event processor when an action modify store and IS NOT trap by map state event handler + + // #region + // Holds the list of layer data arrays being buffered in the propagation process for the batch + static batchedPropagationLayerDataArray: BatchedPropagationLayerDataArrayByMap = {}; + + // The time delay between propagations in the batch layer data array. + // The longer the delay, the more the layers will have a chance to get in a loaded state before changing the layerDataArray. + // The longer the delay, the longer it'll take to update the UI. The delay can be bypassed using the layer path bypass method. + static timeDelayBetweenPropagationsForBatch = 2000; + /** * Shortcut to get the Geochart state for a given map id * @param {string} mapId The mapId diff --git a/packages/geoview-core/src/api/event-processors/event-processor-children/swiper-event-processor.ts b/packages/geoview-core/src/api/event-processors/event-processor-children/swiper-event-processor.ts index 9cab508e6b6..d38c0091304 100644 --- a/packages/geoview-core/src/api/event-processors/event-processor-children/swiper-event-processor.ts +++ b/packages/geoview-core/src/api/event-processors/event-processor-children/swiper-event-processor.ts @@ -8,13 +8,6 @@ import { AbstractEventProcessor } from '../abstract-event-processor'; * Event processor focusing on interacting with the swiper state in the store. */ export class SwiperEventProcessor extends AbstractEventProcessor { - // ********************************************************** - // Static functions for Typescript files to access store actions - // ********************************************************** - //! Typescript MUST always use the defined store actions below to modify store - NEVER use setState! - //! Some action does state modifications AND map actions. - //! ALWAYS use map event processor when an action modify store and IS NOT trap by map state event handler - /** * Overrides initialization of the Swiper Event Processor * @param {GeoviewStoreType} store The store associated with the Swiper Event Processor @@ -49,6 +42,13 @@ export class SwiperEventProcessor extends AbstractEventProcessor { return [unsubLayerRemoved]; } + // ********************************************************** + // Static functions for Typescript files to access store actions + // ********************************************************** + //! Typescript MUST always use the defined store actions below to modify store - NEVER use setState! + //! Some action does state modifications AND map actions. + //! ALWAYS use map event processor when an action modify store and IS NOT trap by map state event handler + /** * Shortcut to get the Swiper state for a given map id * @param {string} mapId The mapId @@ -78,7 +78,7 @@ export class SwiperEventProcessor extends AbstractEventProcessor { } /** - * Adds a swipe functionality to the specified map id and layer path + * Adds a swiper functionality to the specified map id and layer path * @param {string} mapId The map ID * @param {string} layerPath The layer path */ @@ -108,7 +108,7 @@ export class SwiperEventProcessor extends AbstractEventProcessor { } /** - * Removes a swipe functionality for the specified map id and layer path + * Removes a swiper functionality for the specified map id and layer path * @param {string} mapId The map ID * @param {string} layerPath The layer path */ @@ -141,7 +141,7 @@ export class SwiperEventProcessor extends AbstractEventProcessor { } /** - * Removes the swipe functionality for all layer paths + * Removes the swiper functionality for all layer paths * @param {string} mapId The map ID */ static removeAll(mapId: string) { diff --git a/packages/geoview-core/src/core/components/guide/guide-panel.tsx b/packages/geoview-core/src/core/components/guide/guide-panel.tsx index ef1ec8372b7..b2d46505d26 100644 --- a/packages/geoview-core/src/core/components/guide/guide-panel.tsx +++ b/packages/geoview-core/src/core/components/guide/guide-panel.tsx @@ -61,8 +61,7 @@ export function GuidePanel({ fullWidth }: GuidePanelType): JSX.Element { const allTabs: TypeValidFooterBarTabsCoreProps | undefined = footerBarConfig?.tabs.core; // fetch the content of general guide items with custom hook - let mdFilePath = '/geoview/public/locales/markdown/general-content.md'; - if (process.env.NODE_ENV === 'development') mdFilePath = '/locales/markdown/general-content.md'; + const mdFilePath = './locales/markdown/general-content.md'; useFetchAndParseMarkdown(mapId, mdFilePath, t('guide.errorMessage'), setLeftPanelHelpItems); const leftPanelItemKeys = leftPanelHelpItems && Object.keys(leftPanelHelpItems); diff --git a/packages/geoview-core/src/geo/layer/layer.ts b/packages/geoview-core/src/geo/layer/layer.ts index dd36d89e105..52862d680fe 100644 --- a/packages/geoview-core/src/geo/layer/layer.ts +++ b/packages/geoview-core/src/geo/layer/layer.ts @@ -526,7 +526,7 @@ export class Layer { * * @returns {BaseLayer | LayerGroup} Returns the OpenLayer layer associated to the layer path. */ - getLayerByLayerPath = (layerPath: string): BaseLayer | LayerGroup => { + getOLLayerByLayerPath = (layerPath: string): BaseLayer | LayerGroup => { // Return the olLayer object from the registered layers const olLayer = api.maps[this.mapId].layer.registeredLayers[layerPath]?.olLayer; if (olLayer) return olLayer; @@ -536,12 +536,12 @@ export class Layer { /** * Asynchronously returns the OpenLayer layer associated to a specific layer path. * This function waits the timeout period before abandonning (or uses the default timeout when not provided). - * Note this function uses the 'Async' suffix to differentiate it from 'getLayerByLayerPath'. + * Note this function uses the 'Async' suffix to differentiate it from 'getOLLayerByLayerPath'. * @param {string} layerPath The layer path to the layer's configuration. * * @returns {BaseLayer | LayerGroup} Returns the OpenLayer layer associated to the layer path. */ - getLayerByLayerPathAsync = async (layerPath: string, timeout?: number, checkFrequency?: number): Promise => { + getOLLayerByLayerPathAsync = async (layerPath: string, timeout?: number, checkFrequency?: number): Promise => { // Make sure the open layer has been created, sometimes it can still be in the process of being created const promisedLayer = await whenThisThen( () => { diff --git a/packages/geoview-swiper/src/index.tsx b/packages/geoview-swiper/src/index.tsx index 65909f11223..f1133ef13a5 100644 --- a/packages/geoview-swiper/src/index.tsx +++ b/packages/geoview-swiper/src/index.tsx @@ -67,14 +67,15 @@ class SwiperPlugin extends MapPlugin { * @param {string} layerPath The layer path to activate swiper functionality */ activateForLayer = (layerPath: string) => { - // Check if the layer exists on the map - const layer = this.map().layer.getLayerByLayerPath(layerPath); - if (layer) { + try { + // Check if the layer exists on the map + this.map().layer.getOLLayerByLayerPath(layerPath); + // Add the layer path SwiperEventProcessor.addLayerPath(this.pluginProps.mapId, layerPath); - } else { + } catch (error) { // Log - logger.logError(`Couldn't find the layer with layer path ${layerPath}`); + logger.logError(error); } }; diff --git a/packages/geoview-swiper/src/swiper.tsx b/packages/geoview-swiper/src/swiper.tsx index 029e33910ea..575265c20b6 100644 --- a/packages/geoview-swiper/src/swiper.tsx +++ b/packages/geoview-swiper/src/swiper.tsx @@ -168,7 +168,7 @@ export function Swiper(props: SwiperProps): JSX.Element { async (layerPath: string) => { try { // Get the layer at the layer path - const olLayer = await mapViewer.layer.getLayerByLayerPathAsync(layerPath); + const olLayer = await mapViewer.layer.getOLLayerByLayerPathAsync(layerPath); if (olLayer) { // Set the OL layers setOlLayers((prevArray: BaseLayer[]) => [...prevArray, olLayer]); @@ -209,7 +209,7 @@ export function Swiper(props: SwiperProps): JSX.Element { layerPaths.forEach((layerPath: string) => { try { // Get the layer at the layer path - const olLayer = mapViewer.layer.getLayerByLayerPath(layerPath); + const olLayer = mapViewer.layer.getOLLayerByLayerPath(layerPath); if (olLayer) { // Unwire the events on the layer olLayer.un(['precompose' as EventTypes, 'prerender' as EventTypes], prerender);