Skip to content

Commit

Permalink
fix: allows custom request params
Browse files Browse the repository at this point in the history
  • Loading branch information
mholthausen committed Jul 1, 2022
1 parent 8ea34b5 commit f1bebd0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/model/Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import BaseEntity, { BaseEntityArgs } from './BaseEntity';
import LayerType from './enum/LayerType';

export interface DefaultRequestParams {
transparent?: boolean;
[key: string]: string | number | boolean;
}

export interface DefaultLayerSourceConfig {
Expand Down
15 changes: 4 additions & 11 deletions src/parser/SHOGunApplicationUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class SHOGunApplicationUtil<T extends Application, S extends Layer> {
attribution,
url,
layerNames,
requestParams
requestParams = {'TRANSPARENT': true}
} = layer.sourceConfig || {};

const {
Expand All @@ -216,10 +216,7 @@ class SHOGunApplicationUtil<T extends Application, S extends Layer> {
attributions: attribution,
params: {
'LAYERS': layerNames,
'TRANSPARENT':
requestParams?.transparent !== undefined
? requestParams?.transparent
: true
...requestParams
},
crossOrigin,
imageLoadFunction: this.bearerTokenLoadFunction
Expand All @@ -244,7 +241,7 @@ class SHOGunApplicationUtil<T extends Application, S extends Layer> {
tileSize = 256,
tileOrigin,
resolutions,
requestParams
requestParams = {'TRANSPARENT': true}
} = layer.sourceConfig || {};

const {
Expand All @@ -269,10 +266,7 @@ class SHOGunApplicationUtil<T extends Application, S extends Layer> {
projection,
params: {
'LAYERS': layerNames,
'TRANSPARENT':
requestParams?.transparent !== undefined
? requestParams?.transparent
: true
...requestParams
},
crossOrigin,
tileLoadFunction: this.bearerTokenLoadFunction
Expand Down Expand Up @@ -402,7 +396,6 @@ class SHOGunApplicationUtil<T extends Application, S extends Layer> {
olLayer.set('propertyConfig', layer.clientConfig?.propertyConfig);
olLayer.set('legendUrl', layer.sourceConfig.legendUrl);
olLayer.set('hoverable', layer.clientConfig?.hoverable);
olLayer.set('transparent', layer.sourceConfig?.requestParams?.transparent);
}

private async bearerTokenLoadFunctionVector(opts: {
Expand Down

0 comments on commit f1bebd0

Please sign in to comment.