Skip to content

Commit

Permalink
Hotfix for the LayerApi.layerLoaded event
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-NRCan committed Dec 5, 2024
1 parent 7f0d0b4 commit 646da6f
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions packages/geoview-core/src/geo/layer/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!);
Expand Down Expand Up @@ -1861,7 +1874,7 @@ type LayerLoadedDelegate = EventDelegateBase<LayerApi, LayerLoadedEvent, void>;
*/
export type LayerLoadedEvent = {
// The loaded layer
layer: AbstractGeoViewLayer;
layer: AbstractGeoViewLayer | AbstractGVLayer;

layerPath: string;
};
Expand Down

0 comments on commit 646da6f

Please sign in to comment.