From 646da6fe40fd124c5f80e079a18eedf19851253e Mon Sep 17 00:00:00 2001 From: AlexNRCan Date: Thu, 5 Dec 2024 09:56:52 -0500 Subject: [PATCH] Hotfix for the LayerApi.layerLoaded event --- packages/geoview-core/src/geo/layer/layer.ts | 29 ++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/geoview-core/src/geo/layer/layer.ts b/packages/geoview-core/src/geo/layer/layer.ts index a6d83cc7751..b0737a2023c 100644 --- a/packages/geoview-core/src/geo/layer/layer.ts +++ b/packages/geoview-core/src/geo/layer/layer.ts @@ -734,7 +734,17 @@ export class LayerApi { // If new layers mode, create the corresponding GVLayer if (LayerApi.LAYERS_HYBRID_MODE) { const gvLayer = this.#createGVLayer(this.getMapId(), geoviewLayer, event.source, event.config, event.extraConfig); - if (gvLayer) return gvLayer.getOLLayer(); + + // If found the GV layer + if (gvLayer) { + // Register a hook when a layer is loaded on the map + gvLayer!.onIndividualLayerLoaded((sender, payload) => { + // Log + logger.logDebug(`${payload.layerPath} loaded on map ${this.getMapId()}`); + this.#emitLayerLoaded({ layer: sender, layerPath: payload.layerPath }); + }); + return gvLayer.getOLLayer(); + } } // Don't provide any layer, working in old mode @@ -766,12 +776,15 @@ export class LayerApi { layerBeingAdded! .createGeoViewLayers() .then(() => { - // Register a hook when a layer is loaded on the map - layerBeingAdded!.onIndividualLayerLoaded((sender, payload) => { - // Log - logger.logDebug(`${payload.layerPath} loaded on map ${this.getMapId()}`); - this.#emitLayerLoaded({ layer: sender, layerPath: payload.layerPath }); - }); + // If not HYBRID MODE + if (!LayerApi.LAYERS_HYBRID_MODE) { + // Register a hook when a layer is loaded on the map + layerBeingAdded!.onIndividualLayerLoaded((sender, payload) => { + // Log + logger.logDebug(`${payload.layerPath} loaded on map ${this.getMapId()}`); + this.#emitLayerLoaded({ layer: sender, layerPath: payload.layerPath }); + }); + } // Add the layer on the map this.#addToMap(layerBeingAdded!); @@ -1861,7 +1874,7 @@ type LayerLoadedDelegate = EventDelegateBase; */ export type LayerLoadedEvent = { // The loaded layer - layer: AbstractGeoViewLayer; + layer: AbstractGeoViewLayer | AbstractGVLayer; layerPath: string; };