Skip to content

Commit

Permalink
Merge pull request origo-map#1728 from origo-map/cql-filter-wms
Browse files Browse the repository at this point in the history
feature: filter on wms layer
  • Loading branch information
johnnyblasta committed Apr 4, 2023
2 parents e899204 + 0f37048 commit 25f2e9d
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/layer/wms.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import maputils from '../maputils';
import image from './image';

function createTileSource(options) {
return new TileWMSSource(({
const sourceOptions = {
attributions: options.attribution,
url: options.url,
gutter: options.gutter,
Expand All @@ -19,11 +19,17 @@ function createTileSource(options) {
FORMAT: options.format,
STYLES: options.style
}
}));
};
if (options.params) {
Object.keys(options.params).forEach((element) => {
sourceOptions.params[element] = options.params[element];
});
}
return new TileWMSSource((sourceOptions));
}

function createImageSource(options) {
return new ImageWMSSource(({
const sourceOptions = {
attributions: options.attribution,
url: options.url,
crossOrigin: 'anonymous',
Expand All @@ -34,7 +40,13 @@ function createImageSource(options) {
FORMAT: options.format,
STYLES: options.style
}
}));
};
if (options.params) {
Object.keys(options.params).forEach((element) => {
sourceOptions.params[element] = options.params[element];
});
}
return new ImageWMSSource((sourceOptions));
}

function createWmsStyle({ wmsOptions, source, viewer, initialStyle = false }) {
Expand Down Expand Up @@ -137,6 +149,9 @@ const wms = function wms(layerOptions, viewer) {
sourceOptions.crossOrigin = wmsOptions.crossOrigin ? wmsOptions.crossOrigin : sourceOptions.crossOrigin;
sourceOptions.projection = viewer.getProjection();
sourceOptions.id = wmsOptions.id;
sourceOptions.filter = wmsOptions.filter;
sourceOptions.filterType = wmsOptions.filterType;
sourceOptions.params = wmsOptions.sourceParams;
sourceOptions.format = wmsOptions.format ? wmsOptions.format : sourceOptions.format;
if (!wmsOptions.stylePicker) {
const styleSettings = viewer.getStyle(wmsOptions.styleName);
Expand Down

0 comments on commit 25f2e9d

Please sign in to comment.