Skip to content

Commit

Permalink
fix: only use tile load function if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
hwbllmnn committed May 3, 2023
1 parent 29d461d commit e0a998d
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/parser/SHOGunApplicationUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,19 @@ class SHOGunApplicationUtil<T extends Application, S extends Layer> {
opacity
} = layer.clientConfig || {};

const source = new OlImageWMS({
const sourceConfig: any = {
url,
attributions: attribution,
params: {
LAYERS: layerNames,
...requestParams
},
crossOrigin,
imageLoadFunction: (imageTile, src) => this.bearerTokenLoadFunction(imageTile, src, useBearerToken)
});
crossOrigin
};
if (useBearerToken) {
sourceConfig.imageLoadFunction = (imageTile: any, src: any) => this.bearerTokenLoadFunction(imageTile, src, true);
}
const source = new OlImageWMS(sourceConfig);

const imageLayer = new OlImageLayer({
source,
Expand Down Expand Up @@ -296,7 +299,7 @@ class SHOGunApplicationUtil<T extends Application, S extends Layer> {
});
}

const source = new OlTileWMS({
const sourceConfig: any = {
url,
tileGrid,
attributions: attribution,
Expand All @@ -305,9 +308,13 @@ class SHOGunApplicationUtil<T extends Application, S extends Layer> {
LAYERS: layerNames,
...requestParams
},
crossOrigin,
tileLoadFunction: (imageTile, src) => this.bearerTokenLoadFunction(imageTile, src, useBearerToken)
});
crossOrigin
};
if (useBearerToken) {
sourceConfig.tileLoadFunction = (imageTile: any, src: any) => this.bearerTokenLoadFunction(imageTile, src, true);
}

const source = new OlTileWMS(sourceConfig);

const tileLayer = new OlTileLayer({
source,
Expand Down

0 comments on commit e0a998d

Please sign in to comment.