Merge pull request #14048 from mike-000/wms-params
Clone the WMS params option
This commit is contained in:
@@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
Future versions will no longer throw `ol/AssertionError` with an error `code`. Instead, they will throw `Error` with just the error message.
|
Future versions will no longer throw `ol/AssertionError` with an error `code`. Instead, they will throw `Error` with just the error message.
|
||||||
|
|
||||||
|
#### Updating parameters in `ol/source/ImageWMS` and `ol/source/TileWMS`
|
||||||
|
|
||||||
|
The `updateParams()` method will be the only way to update parameters. Changes made directly to the `params` object passed as a constructor option will have no effect.
|
||||||
|
|
||||||
### 7.0.0
|
### 7.0.0
|
||||||
|
|
||||||
#### Removal of deprecated properties and methods
|
#### Removal of deprecated properties and methods
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class ImageWMS extends ImageSource {
|
|||||||
* @private
|
* @private
|
||||||
* @type {!Object}
|
* @type {!Object}
|
||||||
*/
|
*/
|
||||||
this.params_ = options.params || {};
|
this.params_ = Object.assign({}, options.params);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class TileWMS extends TileImage {
|
|||||||
constructor(options) {
|
constructor(options) {
|
||||||
options = options ? options : /** @type {Options} */ ({});
|
options = options ? options : /** @type {Options} */ ({});
|
||||||
|
|
||||||
const params = options.params || {};
|
const params = Object.assign({}, options.params);
|
||||||
|
|
||||||
const transparent = 'TRANSPARENT' in params ? params['TRANSPARENT'] : true;
|
const transparent = 'TRANSPARENT' in params ? params['TRANSPARENT'] : true;
|
||||||
|
|
||||||
|
|||||||
@@ -206,8 +206,8 @@ describe('ol/source/ImageWMS', function () {
|
|||||||
|
|
||||||
it('extends FORMAT_OPTIONS if it is already present', function () {
|
it('extends FORMAT_OPTIONS if it is already present', function () {
|
||||||
options.serverType = 'geoserver';
|
options.serverType = 'geoserver';
|
||||||
const source = new ImageWMS(options);
|
|
||||||
options.params.FORMAT_OPTIONS = 'param1:value1';
|
options.params.FORMAT_OPTIONS = 'param1:value1';
|
||||||
|
const source = new ImageWMS(options);
|
||||||
pixelRatio = 2;
|
pixelRatio = 2;
|
||||||
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
const image = source.getImage(extent, resolution, pixelRatio, projection);
|
||||||
const uri = new URL(image.src_);
|
const uri = new URL(image.src_);
|
||||||
|
|||||||
@@ -150,8 +150,8 @@ describe('ol/source/TileWMS', function () {
|
|||||||
|
|
||||||
it('extends FORMAT_OPTIONS if it is already present', function () {
|
it('extends FORMAT_OPTIONS if it is already present', function () {
|
||||||
options.serverType = 'geoserver';
|
options.serverType = 'geoserver';
|
||||||
const source = new TileWMS(options);
|
|
||||||
options.params.FORMAT_OPTIONS = 'param1:value1';
|
options.params.FORMAT_OPTIONS = 'param1:value1';
|
||||||
|
const source = new TileWMS(options);
|
||||||
const tile = source.getTile(3, 2, 2, 2, getProjection('CRS:84'));
|
const tile = source.getTile(3, 2, 2, 2, getProjection('CRS:84'));
|
||||||
const uri = new URL(tile.src_);
|
const uri = new URL(tile.src_);
|
||||||
const queryData = uri.searchParams;
|
const queryData = uri.searchParams;
|
||||||
|
|||||||
Reference in New Issue
Block a user