@opengeoweb/webmap 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
1
  import { WMJSService } from './WMJSService';
2
- declare const WMGetServiceFromStore: (serviceName: string, xml2jsonrequestURL?: string) => WMJSService;
2
+ declare const WMGetServiceFromStore: (serviceName: string) => WMJSService;
3
3
  export default WMGetServiceFromStore;
@@ -109,13 +109,11 @@ export default class WMJSMap {
109
109
  private proj4;
110
110
  private previousMouseButtonState;
111
111
  private longlat;
112
- xml2jsonrequest: string;
113
112
  private tileRenderSettings;
114
113
  private drawPending;
115
114
  private needsRedraw;
116
115
  private buildLayerDimsBusy;
117
116
  constructor(_element: HTMLElement);
118
- setXML2JSONURL(_xml2jsonrequest: string): void;
119
117
  setWMTileRendererTileSettings(_WMTileRendererTileSettings: unknown): void;
120
118
  /**
121
119
  * Function which make a component ID which is unique over several WebMapJS instances
@@ -13,7 +13,7 @@ export declare const getWMSUrl: (service?: string, additionalParams?: {}) => str
13
13
  /**
14
14
  * Global getcapabilities function
15
15
  */
16
- export declare const WMJSGetCapabilities: (service: string, succes: (param: any) => void, fail: (param: string) => void, xml2jsonrequestURL: string, options: {
16
+ export declare const WMJSGetCapabilities: (service: string, succes: (param: any) => void, fail: (param: string) => void, options: {
17
17
  headers?: any;
18
18
  }, disableCache?: boolean) => void;
19
19
  interface NodeObject {
@@ -32,7 +32,6 @@ export declare const recursivelyFindLayer: (layers: any[], rootNode: any[], path
32
32
  *
33
33
  * options:
34
34
  * service
35
- * xml2jsonrequestURL
36
35
  * title (optional)
37
36
  */
38
37
  export declare class WMJSService {
@@ -44,13 +43,11 @@ export declare class WMJSService {
44
43
  getcapabilitiesDoc: GetCapabilitiesJson;
45
44
  busy: boolean;
46
45
  _flatLayerObject: any[];
47
- xml2jsonrequestURL: string;
48
46
  functionCallbackList: any[];
49
47
  _options: any;
50
48
  nodeCache: any;
51
49
  constructor(options: {
52
50
  service: string;
53
- xml2jsonrequestURL: string;
54
51
  title?: string;
55
52
  });
56
53
  checkVersion111(jsonData: GetCapabilitiesJson): void;
@@ -64,16 +61,16 @@ export declare class WMJSService {
64
61
  * @param succescallback Function called upon succes, cannot be left blank
65
62
  * @param failcallback Function called upon failure, cannot be left blank
66
63
  */
67
- getCapabilities(succescallback: (param: GetCapabilitiesJson) => void, failcallback: (param: unknown) => void, forceReload: boolean, xml2jsonrequestURL: string, options: unknown): void;
64
+ getCapabilities(succescallback: (param: GetCapabilitiesJson) => void, failcallback: (param: unknown) => void, forceReload: boolean, options: unknown): void;
68
65
  checkException(jsonData: GetCapabilitiesJson): string | undefined;
69
66
  /**
70
67
  * Calls succes with a hierarchical node structure
71
68
  * Calls failure with a string when someting goes wrong
72
69
  */
73
- getNodes(succes: (param: unknown) => void, failure: (param: unknown) => void, forceReload: boolean, xml2jsonrequestURL?: string, options?: unknown): void;
70
+ getNodes(succes: (param: unknown) => void, failure: (param: unknown) => void, forceReload: boolean, options?: unknown): void;
74
71
  /** Calls succes with an array of all layerobjects
75
72
  * Calls failure when something goes wrong
76
73
  */
77
- getLayerObjectsFlat(succes: (param: unknown) => void, failure: (param: unknown) => void, forceReload: boolean, xml2jsonrequestURL?: string, options?: any): void;
74
+ getLayerObjectsFlat(succes: (param: unknown) => void, failure: (param: unknown) => void, forceReload: boolean, options?: any): void;
78
75
  }
79
76
  export {};
@@ -1,10 +1,8 @@
1
- /// <reference types="react" />
2
1
  /// <reference types="node" />
3
2
  import type WMJSMap from './WMJSMap';
4
3
  import WMJSDimension from './WMJSDimension';
5
4
  import WMProjection from './WMProjection';
6
- import WMImage from './WMImage';
7
- import { GetCapabilitiesJson, WMJSService } from './WMJSService';
5
+ import { GetCapabilitiesJson } from './WMJSService';
8
6
  import { Style, Dimension } from './types';
9
7
  export declare enum LayerType {
10
8
  mapLayer = "mapLayer",
@@ -29,7 +27,7 @@ export interface LayerOptions {
29
27
  transparent?: boolean;
30
28
  onReady?: (param: any) => void;
31
29
  type?: string;
32
- parentMaps?: WMJSMap[];
30
+ parentMap?: WMJSMap;
33
31
  dimensions?: Dimension[];
34
32
  headers?: Headers[];
35
33
  failure?: (layer: WMLayer, message: string) => void;
@@ -73,7 +71,6 @@ export default class WMLayer {
73
71
  id: string;
74
72
  name?: string;
75
73
  ReactWMJSLayerId?: string;
76
- reactWebMapJSLayer?: React.ReactElement;
77
74
  hasError?: boolean;
78
75
  enabled?: boolean;
79
76
  lastError?: string;
@@ -83,7 +80,6 @@ export default class WMLayer {
83
80
  service: string;
84
81
  layerType: LayerType;
85
82
  currentStyle?: string;
86
- image?: WMImage;
87
83
  linkedInfo: {
88
84
  layer: string;
89
85
  message: string;
@@ -91,7 +87,6 @@ export default class WMLayer {
91
87
  headers: Headers[];
92
88
  autoupdate: boolean;
93
89
  timer: NodeJS.Timeout;
94
- WMJSService: WMJSService;
95
90
  getmapURL: string;
96
91
  getfeatureinfoURL: string;
97
92
  getlegendgraphicURL: string;
@@ -107,9 +102,8 @@ export default class WMLayer {
107
102
  projectionProperties: WMProjection[];
108
103
  queryable: boolean;
109
104
  styles: Style[];
110
- getCapabilitiesDoc: GetCapabilitiesJson;
111
105
  serviceTitle: string;
112
- parentMaps: WMJSMap[];
106
+ parentMap: WMJSMap;
113
107
  sldURL: string;
114
108
  active: boolean;
115
109
  getgraphinfoURL: string;
@@ -121,7 +115,6 @@ export default class WMLayer {
121
115
  url: string;
122
116
  colorscalerange: Record<string, unknown>[];
123
117
  };
124
- jsonlayer: this;
125
118
  isConfigured: boolean;
126
119
  init(): void;
127
120
  constructor(options?: LayerOptions);
@@ -138,13 +131,13 @@ export default class WMLayer {
138
131
  handleReferenceTime(name: string, value: string, updateMapDimensions?: boolean): void;
139
132
  getDimensions(): WMJSDimension[];
140
133
  setDimension(name: string, value: string, updateMapDimensions?: boolean): void;
141
- __parseGetCapForLayer(layer: WMLayer, getcapabilitiesjson: GetCapabilitiesJson, layerDoneCallback: (layer: WMLayer) => void, fail: (layer: WMLayer, message: string) => void): void;
134
+ __parseGetCapForLayer(getcapabilitiesjson: GetCapabilitiesJson, layerDoneCallback: (layer: WMLayer) => void, fail: (layer: WMLayer, message: string) => void): void;
142
135
  /**
143
136
  * Calls success with a configured layer object
144
137
  * Calls options.failure with error message.
145
138
  * Throws string exceptions when someting goes wrong
146
139
  */
147
- parseLayer(_layerDoneCallback: (layer: WMLayer) => void, forceReload: boolean, xml2jsonrequest?: string): void;
140
+ parseLayer(_layerDoneCallback: (layer: WMLayer) => void, forceReload: boolean): void;
148
141
  /**
149
142
  * A Promise to parse the layer, it will fetch the WMS GetCapabilities document, configure the layer and resolve to a WMLayer object
150
143
  * @param forceReload Do not use the cache of the WMS GetCapabilties document, but instead fetch new data from the server
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/webmap",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "GeoWeb webmap library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/webmap.esm.js CHANGED
@@ -3960,7 +3960,6 @@ var WMJSMap = /*#__PURE__*/function () {
3960
3960
  this.previousMouseButtonState = 'up';
3961
3961
  /* Binds */
3962
3962
 
3963
- this.setXML2JSONURL = this.setXML2JSONURL.bind(this);
3964
3963
  this.setWMTileRendererTileSettings = this.setWMTileRendererTileSettings.bind(this);
3965
3964
  this.makeComponentId = this.makeComponentId.bind(this);
3966
3965
  this.setMessage = this.setMessage.bind(this);
@@ -4086,11 +4085,6 @@ var WMJSMap = /*#__PURE__*/function () {
4086
4085
  }
4087
4086
 
4088
4087
  _createClass(WMJSMap, [{
4089
- key: "setXML2JSONURL",
4090
- value: function setXML2JSONURL(_xml2jsonrequest) {
4091
- this.xml2jsonrequest = _xml2jsonrequest;
4092
- }
4093
- }, {
4094
4088
  key: "setWMTileRendererTileSettings",
4095
4089
  value: function setWMTileRendererTileSettings(_WMTileRendererTileSettings) {
4096
4090
  this.tileRenderSettings = _WMTileRendererTileSettings;
@@ -4898,10 +4892,10 @@ var WMJSMap = /*#__PURE__*/function () {
4898
4892
  reject(new Error('layer has no constructor'));
4899
4893
  return;
4900
4894
  }
4895
+ /* Set a reference in the layer to this map */
4901
4896
 
4902
- if (!layer.parentMaps.includes(_this5)) {
4903
- layer.parentMaps.push(_this5);
4904
- }
4897
+
4898
+ layer.parentMap = _this5;
4905
4899
 
4906
4900
  _this5.layers.push(layer);
4907
4901
 
@@ -5451,9 +5445,7 @@ var WMJSMap = /*#__PURE__*/function () {
5451
5445
  this.baseLayers = layer;
5452
5446
 
5453
5447
  for (var j = 0; j < this.baseLayers.length; j += 1) {
5454
- if (!this.baseLayers[j].parentMaps.includes(this)) {
5455
- this.baseLayers[j].parentMaps.push(this);
5456
- }
5448
+ this.baseLayers[j].parentMap = this;
5457
5449
 
5458
5450
  if (this.baseLayers[j].keepOnTop !== true) {
5459
5451
  this.numBaseLayers += 1;
@@ -7353,8 +7345,8 @@ var getWMSUrl = function getWMSUrl() {
7353
7345
  * Global getcapabilities function
7354
7346
  */
7355
7347
 
7356
- var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, xml2jsonrequestURL, options) {
7357
- var disableCache = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
7348
+ var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, options) {
7349
+ var disableCache = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
7358
7350
 
7359
7351
  /* Make the getCapabilitiesJSONrequest */
7360
7352
  var headers = [];
@@ -7398,7 +7390,6 @@ var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, xm
7398
7390
  random: Math.random()
7399
7391
  } : {};
7400
7392
  var url = getWMSUrl(service, addParams);
7401
- var newXml2jsonrequestURL = xml2jsonrequestURL;
7402
7393
  WMXMLParser(url, headers).then(function (data) {
7403
7394
  try {
7404
7395
  succes(data);
@@ -7408,7 +7399,7 @@ var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, xm
7408
7399
  })["catch"](function () {
7409
7400
  loadGetCapabilitiesViaProxy(url, succes, function () {
7410
7401
  fail("Request failed for ".concat(url));
7411
- }, newXml2jsonrequestURL);
7402
+ }, WMServiceStoreXML2JSONRequest.proxy);
7412
7403
  });
7413
7404
  };
7414
7405
  var sortByKey = function sortByKey(array, key) {
@@ -7469,7 +7460,6 @@ rootNode, path) {
7469
7460
  *
7470
7461
  * options:
7471
7462
  * service
7472
- * xml2jsonrequestURL
7473
7463
  * title (optional)
7474
7464
  */
7475
7465
 
@@ -7490,7 +7480,6 @@ var WMJSService = /*#__PURE__*/function () {
7490
7480
  if (options) {
7491
7481
  this.service = options.service;
7492
7482
  this.title = options.title;
7493
- this.xml2jsonrequestURL = options.xml2jsonrequestURL;
7494
7483
  }
7495
7484
 
7496
7485
  this.checkVersion111 = this.checkVersion111.bind(this);
@@ -7613,7 +7602,7 @@ var WMJSService = /*#__PURE__*/function () {
7613
7602
 
7614
7603
  }, {
7615
7604
  key: "getCapabilities",
7616
- value: function getCapabilities(succescallback, failcallback, forceReload, xml2jsonrequestURL, options) {
7605
+ value: function getCapabilities(succescallback, failcallback, forceReload, options) {
7617
7606
  var _this = this;
7618
7607
 
7619
7608
  if (options) {
@@ -7698,7 +7687,7 @@ var WMJSService = /*#__PURE__*/function () {
7698
7687
  return null;
7699
7688
  }, function () {
7700
7689
  return null;
7701
- }, false, xml2jsonrequestURL, options);
7690
+ }, false, options);
7702
7691
 
7703
7692
  var current;
7704
7693
 
@@ -7707,7 +7696,7 @@ var WMJSService = /*#__PURE__*/function () {
7707
7696
  }
7708
7697
  };
7709
7698
 
7710
- WMJSGetCapabilities(this.service, succes, fail, xml2jsonrequestURL, options);
7699
+ WMJSGetCapabilities(this.service, succes, fail, options);
7711
7700
  } else {
7712
7701
  /* The callbacks are not allowed to be called in the scope of this object.
7713
7702
  By using window.setTimeOut they are externally called
@@ -7753,11 +7742,9 @@ var WMJSService = /*#__PURE__*/function () {
7753
7742
 
7754
7743
  }, {
7755
7744
  key: "getNodes",
7756
- value: function getNodes(succes, failure, forceReload) {
7745
+ value: function getNodes(succes, failure, forceReload, options) {
7757
7746
  var _this2 = this;
7758
7747
 
7759
- var xml2jsonrequestURL = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.xml2jsonrequestURL;
7760
- var options = arguments.length > 4 ? arguments[4] : undefined;
7761
7748
  this.nodeCache = undefined;
7762
7749
 
7763
7750
  if (!failure) {
@@ -7806,7 +7793,7 @@ var WMJSService = /*#__PURE__*/function () {
7806
7793
  failure(data);
7807
7794
  };
7808
7795
 
7809
- this.getCapabilities(callback, fail, forceReload, xml2jsonrequestURL, options);
7796
+ this.getCapabilities(callback, fail, forceReload, options);
7810
7797
  }
7811
7798
  /** Calls succes with an array of all layerobjects
7812
7799
  * Calls failure when something goes wrong
@@ -7817,13 +7804,7 @@ var WMJSService = /*#__PURE__*/function () {
7817
7804
  value: function getLayerObjectsFlat(succes, failure, forceReload) {
7818
7805
  var _this3 = this;
7819
7806
 
7820
- var xml2jsonrequestURL = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.xml2jsonrequestURL;
7821
- var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this._options;
7822
-
7823
- if (!xml2jsonrequestURL) {
7824
- // eslint-disable-next-line no-param-reassign
7825
- xml2jsonrequestURL = this.xml2jsonrequestURL;
7826
- }
7807
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this._options;
7827
7808
 
7828
7809
  if (isDefined(this._flatLayerObject) && forceReload !== true) {
7829
7810
  succes(this._flatLayerObject);
@@ -7849,7 +7830,7 @@ var WMJSService = /*#__PURE__*/function () {
7849
7830
  succes(_this3._flatLayerObject);
7850
7831
  };
7851
7832
 
7852
- this.getNodes(callback, failure, forceReload, xml2jsonrequestURL, options);
7833
+ this.getNodes(callback, failure, forceReload, options);
7853
7834
  }
7854
7835
  }]);
7855
7836
 
@@ -7873,20 +7854,15 @@ var WMJSService = /*#__PURE__*/function () {
7873
7854
  * Copyright 2020 - Finnish Meteorological Institute (FMI)
7874
7855
  * */
7875
7856
 
7876
- var WMGetServiceFromStore = function WMGetServiceFromStore(serviceName, xml2jsonrequestURL) {
7857
+ var WMGetServiceFromStore = function WMGetServiceFromStore(serviceName) {
7877
7858
  for (var j = 0; j < WMServiceStore.length; j += 1) {
7878
7859
  if (WMServiceStore[j].service === serviceName) {
7879
7860
  return WMServiceStore[j];
7880
7861
  }
7881
7862
  }
7882
7863
 
7883
- if (xml2jsonrequestURL) {
7884
- WMServiceStoreXML2JSONRequest.proxy = xml2jsonrequestURL;
7885
- }
7886
-
7887
7864
  var service = new WMJSService({
7888
- service: serviceName,
7889
- xml2jsonrequestURL: WMServiceStoreXML2JSONRequest.proxy
7865
+ service: serviceName
7890
7866
  });
7891
7867
  WMServiceStore.push(service);
7892
7868
  return service;
@@ -8028,8 +8004,8 @@ var addDimsForLayer = function addDimsForLayer(layerObjectFromWMS, layer, layerD
8028
8004
  });
8029
8005
  /* Check if the dimension should take the value from the map */
8030
8006
 
8031
- if (layer.parentMaps.length > 0) {
8032
- var mapDim = layer.parentMaps[0].getDimension(layerDim.name);
8007
+ if (layer.parentMap) {
8008
+ var mapDim = layer.parentMap.getDimension(layerDim.name);
8033
8009
 
8034
8010
  if (mapDim && mapDim.linked && isDefined(mapDim.currentValue)) {
8035
8011
  var dimensionCurrentValue = dimension.getClosestValue(mapDim.currentValue);
@@ -8134,8 +8110,8 @@ var configureDimensions = function configureDimensions(nestedLayerPath, wmLayer)
8134
8110
  wmLayer.handleReferenceTime('reference_time', refTimeDimension.getValue());
8135
8111
  }
8136
8112
 
8137
- if (wmLayer.parentMaps && wmLayer.parentMaps.length > 0) {
8138
- wmLayer.parentMaps[0].configureMapDimensions(wmLayer);
8113
+ if (wmLayer.parentMap) {
8114
+ wmLayer.parentMap.configureMapDimensions(wmLayer);
8139
8115
  }
8140
8116
  };
8141
8117
 
@@ -8235,8 +8211,8 @@ var WMLayer = /*#__PURE__*/function () {
8235
8211
  this.type = options.type;
8236
8212
  }
8237
8213
 
8238
- if (options.parentMaps) {
8239
- this.parentMaps = options.parentMaps;
8214
+ if (options.parentMap) {
8215
+ this.parentMap = options.parentMap;
8240
8216
  }
8241
8217
 
8242
8218
  if (options.headers) {
@@ -8252,8 +8228,6 @@ var WMLayer = /*#__PURE__*/function () {
8252
8228
  this.timer = undefined;
8253
8229
  this.service = undefined; // URL of the WMS Service
8254
8230
 
8255
- this.WMJSService = undefined; // Corresponding WMJSService
8256
-
8257
8231
  this.getmapURL = undefined;
8258
8232
  this.getfeatureinfoURL = undefined;
8259
8233
  this.getlegendgraphicURL = undefined;
@@ -8284,9 +8258,8 @@ var WMLayer = /*#__PURE__*/function () {
8284
8258
  this.id = '-1';
8285
8259
  this.opacity = 1.0; // Ranges from 0.0-1.0
8286
8260
 
8287
- this.getCapabilitiesDoc = undefined;
8288
8261
  this.serviceTitle = 'not defined';
8289
- this.parentMaps = [];
8262
+ this.parentMap = null;
8290
8263
  this.sldURL = null;
8291
8264
  this.isConfigured = false;
8292
8265
  }
@@ -8305,7 +8278,7 @@ var WMLayer = /*#__PURE__*/function () {
8305
8278
  if (this.autoupdate) {
8306
8279
  var numDeltaMS = 60000;
8307
8280
  this.timer = setInterval(function () {
8308
- _this.parseLayer(undefined, true, undefined);
8281
+ _this.parseLayer(undefined, true);
8309
8282
  }, numDeltaMS);
8310
8283
  } else {
8311
8284
  clearInterval(this.timer);
@@ -8323,7 +8296,7 @@ var WMLayer = /*#__PURE__*/function () {
8323
8296
  clearInterval(this.timer);
8324
8297
  } else {
8325
8298
  this.timer = setInterval(function () {
8326
- _this2.parseLayer(callback, true, undefined);
8299
+ _this2.parseLayer(callback, true);
8327
8300
  }, interval);
8328
8301
  }
8329
8302
  }
@@ -8332,10 +8305,7 @@ var WMLayer = /*#__PURE__*/function () {
8332
8305
  key: "setOpacity",
8333
8306
  value: function setOpacity(opacityValue) {
8334
8307
  this.opacity = parseFloat(opacityValue);
8335
-
8336
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8337
- this.parentMaps[j].redrawBuffer();
8338
- }
8308
+ this.parentMap && this.parentMap.redrawBuffer();
8339
8309
  }
8340
8310
  }, {
8341
8311
  key: "getOpacity",
@@ -8345,9 +8315,9 @@ var WMLayer = /*#__PURE__*/function () {
8345
8315
  }, {
8346
8316
  key: "remove",
8347
8317
  value: function remove() {
8348
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8349
- this.parentMaps[j].deleteLayer(this);
8350
- this.parentMaps[j].draw('WMLayer::remove');
8318
+ if (this.parentMap) {
8319
+ this.parentMap.deleteLayer(this);
8320
+ this.parentMap.draw('WMLayer::remove');
8351
8321
  }
8352
8322
 
8353
8323
  clearInterval(this.timer);
@@ -8355,31 +8325,31 @@ var WMLayer = /*#__PURE__*/function () {
8355
8325
  }, {
8356
8326
  key: "moveUp",
8357
8327
  value: function moveUp() {
8358
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8359
- this.parentMaps[j].moveLayerUp(this);
8360
- this.parentMaps[j].draw('WMLayer::moveUp');
8328
+ if (this.parentMap) {
8329
+ this.parentMap.moveLayerUp(this);
8330
+ this.parentMap.draw('WMLayer::moveUp');
8361
8331
  }
8362
8332
  }
8363
8333
  }, {
8364
8334
  key: "moveDown",
8365
8335
  value: function moveDown() {
8366
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8367
- this.parentMaps[j].moveLayerDown(this);
8368
- this.parentMaps[j].draw('WMLayer::moveDown');
8336
+ if (this.parentMap) {
8337
+ this.parentMap.moveLayerDown(this);
8338
+ this.parentMap.draw('WMLayer::moveDown');
8369
8339
  }
8370
8340
  }
8371
8341
  }, {
8372
8342
  key: "zoomToLayer",
8373
8343
  value: function zoomToLayer() {
8374
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8375
- this.parentMaps[j].zoomToLayer(this);
8344
+ if (this.parentMap) {
8345
+ this.parentMap.zoomToLayer(this);
8376
8346
  }
8377
8347
  }
8378
8348
  }, {
8379
8349
  key: "draw",
8380
8350
  value: function draw(e) {
8381
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8382
- this.parentMaps[j].draw("WMLayer::draw::".concat(e));
8351
+ if (this.parentMap) {
8352
+ this.parentMap.draw("WMLayer::draw::".concat(e));
8383
8353
  }
8384
8354
  }
8385
8355
  }, {
@@ -8395,9 +8365,9 @@ var WMLayer = /*#__PURE__*/function () {
8395
8365
  timeDim.setTimeValuesForReferenceTime(value, referenceTimeDim);
8396
8366
 
8397
8367
  if (updateMapDimensions) {
8398
- if (this.parentMaps && this.parentMaps.length > 0) {
8368
+ if (this.parentMap) {
8399
8369
  if (this.enabled !== false) {
8400
- this.parentMaps[0].getListener().triggerEvent('ondimchange', 'time');
8370
+ this.parentMap.getListener().triggerEvent('ondimchange', 'time');
8401
8371
  }
8402
8372
  }
8403
8373
  }
@@ -8424,43 +8394,41 @@ var WMLayer = /*#__PURE__*/function () {
8424
8394
 
8425
8395
  if (updateMapDimensions) {
8426
8396
  if (dim.linked === true) {
8427
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8428
- this.parentMaps[j].setDimension(name, dim.getValue());
8397
+ if (this.parentMap) {
8398
+ this.parentMap.setDimension(name, dim.getValue());
8429
8399
  }
8430
8400
  }
8431
8401
  }
8432
8402
  }
8433
8403
  }, {
8434
8404
  key: "__parseGetCapForLayer",
8435
- value: function __parseGetCapForLayer(layer, getcapabilitiesjson, layerDoneCallback, fail) {
8405
+ value: function __parseGetCapForLayer(getcapabilitiesjson, layerDoneCallback, fail) {
8436
8406
  var _this3 = this;
8437
8407
 
8438
- var jsondata = getcapabilitiesjson;
8439
-
8440
- if (!jsondata) {
8408
+ if (!getcapabilitiesjson) {
8441
8409
  this.title = I18n.service_has_error.text;
8442
8410
  this["abstract"] = I18n.not_available_message.text;
8443
- fail(layer, I18n.unable_to_connect_server.text);
8411
+ fail(this, I18n.unable_to_connect_server.text);
8444
8412
  return;
8445
8413
  }
8446
8414
 
8447
- var j = 0; // Get the capability object
8415
+ var wmjsService = WMGetServiceFromStore(this.service); // Get the capability object
8448
8416
 
8449
8417
  var capabilityObject;
8450
8418
 
8451
8419
  try {
8452
- capabilityObject = layer.WMJSService.getCapabilityElement(getcapabilitiesjson);
8420
+ capabilityObject = wmjsService.getCapabilityElement(getcapabilitiesjson);
8453
8421
  } catch (_a) {
8454
- fail(layer, 'No capability element in service');
8422
+ fail(this, 'No capability element in service');
8455
8423
  return;
8456
8424
  }
8457
8425
 
8458
- this.version = layer.WMJSService.version; // Get the rootLayer
8426
+ this.version = wmjsService.version; // Get the rootLayer
8459
8427
 
8460
8428
  var rootLayer = capabilityObject.Layer;
8461
8429
 
8462
8430
  if (!isDefined(rootLayer)) {
8463
- fail(layer, 'No Layer element in service');
8431
+ fail(this, 'No Layer element in service');
8464
8432
  return;
8465
8433
  }
8466
8434
 
@@ -8532,10 +8500,9 @@ var WMLayer = /*#__PURE__*/function () {
8532
8500
  } // TODO Should be arranged also for the other services:
8533
8501
 
8534
8502
 
8535
- _this3.getmapURL = WMJScheckURL(layer.getmapURL);
8536
- _this3.getfeatureinfoURL = WMJScheckURL(layer.getfeatureinfoURL);
8537
- _this3.getlegendgraphicURL = WMJScheckURL(layer.getlegendgraphicURL);
8538
- _this3.getCapabilitiesDoc = jsondata;
8503
+ _this3.getmapURL = WMJScheckURL(_this3.getmapURL);
8504
+ _this3.getfeatureinfoURL = WMJScheckURL(_this3.getfeatureinfoURL);
8505
+ _this3.getlegendgraphicURL = WMJScheckURL(_this3.getlegendgraphicURL);
8539
8506
  _this3.title = jsonlayer.Title.value;
8540
8507
 
8541
8508
  try {
@@ -8566,7 +8533,7 @@ var WMLayer = /*#__PURE__*/function () {
8566
8533
  // Fill in SRS and BBOX on basis of BoundingBox attribute
8567
8534
  var gpbbox = toArray(data.BoundingBox);
8568
8535
 
8569
- for (j = 0; j < gpbbox.length; j += 1) {
8536
+ for (var j = 0; j < gpbbox.length; j += 1) {
8570
8537
  var srs = void 0;
8571
8538
  srs = gpbbox[j].attr.SRS;
8572
8539
 
@@ -8594,8 +8561,8 @@ var WMLayer = /*#__PURE__*/function () {
8594
8561
  geoProperty.srs = srs;
8595
8562
  var swapBBOX = false;
8596
8563
 
8597
- if (layer.version === WMSVersion.version130) {
8598
- if (geoProperty.srs === 'EPSG:4326' && layer.wms130bboxcompatibilitymode === false) {
8564
+ if (_this3.version === WMSVersion.version130) {
8565
+ if (geoProperty.srs === 'EPSG:4326' && _this3.wms130bboxcompatibilitymode === false) {
8599
8566
  swapBBOX = true;
8600
8567
  }
8601
8568
  }
@@ -8623,7 +8590,7 @@ var WMLayer = /*#__PURE__*/function () {
8623
8590
  getgpbbox(jsonlayer);
8624
8591
  getgpbbox(rootLayer); // Fill in SRS on basis of SRS attribute
8625
8592
 
8626
- for (j = 0; j < gp.length; j += 1) {
8593
+ for (var j = 0; j < gp.length; j += 1) {
8627
8594
  if (tempSRS.indexOf(gp[j].value) === -1) {
8628
8595
  var geoProperty = new WMProjection();
8629
8596
  debug(DebugType.Error, "Warning: BoundingBOX missing for SRS ".concat(gp[j].value));
@@ -8632,7 +8599,8 @@ var WMLayer = /*#__PURE__*/function () {
8632
8599
  geoProperty.bbox.right = 180;
8633
8600
  geoProperty.bbox.top = 90;
8634
8601
  geoProperty.srs = gp[j].value;
8635
- layer.projectionProperties.push(geoProperty);
8602
+
8603
+ _this3.projectionProperties.push(geoProperty);
8636
8604
  }
8637
8605
  }
8638
8606
 
@@ -8644,13 +8612,13 @@ var WMLayer = /*#__PURE__*/function () {
8644
8612
  try {
8645
8613
  if (parseInt(jsonlayer.attr.queryable, 10) === 1) _this3.queryable = true;else _this3.queryable = false;
8646
8614
  } catch (e) {
8647
- debug(DebugType.Error, "Unable to detect whether this layer is queryable (for layer ".concat(layer.title, ")"));
8615
+ debug(DebugType.Error, "Unable to detect whether this layer is queryable (for layer ".concat(_this3.title, ")"));
8648
8616
  }
8649
8617
 
8650
8618
  foundLayer = 1;
8651
8619
  };
8652
8620
 
8653
- function recursivelyFindLayer(JSONLayers, path, _prevNestedLayerPath) {
8621
+ function recursivelyFindLayer(thisLayer, JSONLayers, path, _prevNestedLayerPath) {
8654
8622
  for (var k = 0; k < JSONLayers.length; k += 1) {
8655
8623
  var _nestedLayerPath = [];
8656
8624
 
@@ -8669,9 +8637,9 @@ var WMLayer = /*#__PURE__*/function () {
8669
8637
  /* Do nothing */
8670
8638
  }
8671
8639
 
8672
- recursivelyFindLayer(toArray(JSONLayers[k].Layer), pathnew, _nestedLayerPath);
8640
+ recursivelyFindLayer(thisLayer, toArray(JSONLayers[k].Layer), pathnew, _nestedLayerPath);
8673
8641
  } else if (JSONLayers[k].Name) {
8674
- if (JSONLayers[k].Name.value === layer.name) {
8642
+ if (JSONLayers[k].Name.value === thisLayer.name) {
8675
8643
  foundLayerFunction(JSONLayers[k], path, _nestedLayerPath);
8676
8644
  return;
8677
8645
  }
@@ -8683,13 +8651,13 @@ var WMLayer = /*#__PURE__*/function () {
8683
8651
  var JSONLayers = toArray(rootLayer.Layer);
8684
8652
  var path = '';
8685
8653
  var nestedLayerPath = [rootLayer];
8686
- recursivelyFindLayer(JSONLayers, path, nestedLayerPath);
8654
+ recursivelyFindLayer(this, JSONLayers, path, nestedLayerPath);
8687
8655
 
8688
8656
  if (foundLayer === 0) {
8689
8657
  // Layer was not found...
8690
8658
  var message = '';
8691
8659
 
8692
- if (layer.name) {
8660
+ if (this.name) {
8693
8661
  message = "Unable to find layer '".concat(this.name, "' in service '").concat(this.service, "'");
8694
8662
  } else {
8695
8663
  message = "Unable to find layer '".concat(this.title, "' in service '").concat(this.service, "'");
@@ -8718,7 +8686,7 @@ var WMLayer = /*#__PURE__*/function () {
8718
8686
 
8719
8687
  }, {
8720
8688
  key: "parseLayer",
8721
- value: function parseLayer(_layerDoneCallback, forceReload, xml2jsonrequest) {
8689
+ value: function parseLayer(_layerDoneCallback, forceReload) {
8722
8690
  var _this4 = this;
8723
8691
 
8724
8692
  this.hasError = false;
@@ -8745,20 +8713,14 @@ var WMLayer = /*#__PURE__*/function () {
8745
8713
  };
8746
8714
 
8747
8715
  var callback = function callback(data) {
8748
- _this4.__parseGetCapForLayer(_this4, data, layerDoneCallback, fail);
8716
+ _this4.__parseGetCapForLayer(data, layerDoneCallback, fail);
8749
8717
  };
8750
8718
 
8751
8719
  var requestfail = function requestfail() {
8752
8720
  fail(_this4, I18n.no_capability_element_found.text);
8753
8721
  };
8754
8722
 
8755
- var newXml2jsonrequest = xml2jsonrequest;
8756
-
8757
- if (!xml2jsonrequest) {
8758
- newXml2jsonrequest = this.parentMaps && this.parentMaps.length > 0 ? this.parentMaps[0].xml2jsonrequest : undefined;
8759
- }
8760
-
8761
- this.WMJSService = WMGetServiceFromStore(this.service, newXml2jsonrequest);
8723
+ var wmjsService = WMGetServiceFromStore(this.service);
8762
8724
  var options = {
8763
8725
  headers: {}
8764
8726
  };
@@ -8767,10 +8729,10 @@ var WMLayer = /*#__PURE__*/function () {
8767
8729
  options.headers = this.headers;
8768
8730
  }
8769
8731
 
8770
- if (this.WMJSService.service !== undefined) {
8771
- this.WMJSService.getCapabilities(function (data) {
8732
+ if (wmjsService.service !== undefined) {
8733
+ wmjsService.getCapabilities(function (data) {
8772
8734
  callback(data);
8773
- }, requestfail, forceReload, xml2jsonrequest, options);
8735
+ }, requestfail, forceReload, options);
8774
8736
  }
8775
8737
  }
8776
8738
  /**
@@ -8846,7 +8808,8 @@ var WMLayer = /*#__PURE__*/function () {
8846
8808
  success(layerObjects[currentLayerIndex], currentLayerIndex, layerObjects.length);
8847
8809
  };
8848
8810
 
8849
- this.WMJSService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8811
+ var wmjsService = WMGetServiceFromStore(this.service);
8812
+ wmjsService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8850
8813
  }
8851
8814
  }, {
8852
8815
  key: "autoSelectLayer",
@@ -8864,7 +8827,8 @@ var WMLayer = /*#__PURE__*/function () {
8864
8827
  }
8865
8828
  };
8866
8829
 
8867
- this.WMJSService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8830
+ var wmjsService = WMGetServiceFromStore(this.service);
8831
+ wmjsService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8868
8832
  }
8869
8833
  }, {
8870
8834
  key: "getNextLayer",
@@ -9040,8 +9004,8 @@ var WMLayer = /*#__PURE__*/function () {
9040
9004
  value: function display(displayornot) {
9041
9005
  this.enabled = displayornot;
9042
9006
 
9043
- for (var j = 0; j < this.parentMaps.length; j += 1) {
9044
- this.parentMaps[j].displayLayer(this, this.enabled);
9007
+ if (this.parentMap) {
9008
+ this.parentMap.displayLayer(this, this.enabled);
9045
9009
  }
9046
9010
  }
9047
9011
  }]);
package/webmap.umd.js CHANGED
@@ -4027,7 +4027,6 @@
4027
4027
  this.previousMouseButtonState = 'up';
4028
4028
  /* Binds */
4029
4029
 
4030
- this.setXML2JSONURL = this.setXML2JSONURL.bind(this);
4031
4030
  this.setWMTileRendererTileSettings = this.setWMTileRendererTileSettings.bind(this);
4032
4031
  this.makeComponentId = this.makeComponentId.bind(this);
4033
4032
  this.setMessage = this.setMessage.bind(this);
@@ -4152,10 +4151,6 @@
4152
4151
  this.init();
4153
4152
  }
4154
4153
 
4155
- WMJSMap.prototype.setXML2JSONURL = function (_xml2jsonrequest) {
4156
- this.xml2jsonrequest = _xml2jsonrequest;
4157
- };
4158
-
4159
4154
  WMJSMap.prototype.setWMTileRendererTileSettings = function (_WMTileRendererTileSettings) {
4160
4155
  this.tileRenderSettings = _WMTileRendererTileSettings;
4161
4156
  };
@@ -4927,10 +4922,10 @@
4927
4922
  reject(new Error('layer has no constructor'));
4928
4923
  return;
4929
4924
  }
4925
+ /* Set a reference in the layer to this map */
4930
4926
 
4931
- if (!layer.parentMaps.includes(_this)) {
4932
- layer.parentMaps.push(_this);
4933
- }
4927
+
4928
+ layer.parentMap = _this;
4934
4929
 
4935
4930
  _this.layers.push(layer);
4936
4931
 
@@ -5453,9 +5448,7 @@
5453
5448
  this.baseLayers = layer;
5454
5449
 
5455
5450
  for (var j = 0; j < this.baseLayers.length; j += 1) {
5456
- if (!this.baseLayers[j].parentMaps.includes(this)) {
5457
- this.baseLayers[j].parentMaps.push(this);
5458
- }
5451
+ this.baseLayers[j].parentMap = this;
5459
5452
 
5460
5453
  if (this.baseLayers[j].keepOnTop !== true) {
5461
5454
  this.numBaseLayers += 1;
@@ -7327,7 +7320,7 @@
7327
7320
  * Global getcapabilities function
7328
7321
  */
7329
7322
 
7330
- var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, xml2jsonrequestURL, options, disableCache) {
7323
+ var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, options, disableCache) {
7331
7324
  if (disableCache === void 0) {
7332
7325
  disableCache = false;
7333
7326
  }
@@ -7375,7 +7368,6 @@
7375
7368
  random: Math.random()
7376
7369
  } : {};
7377
7370
  var url = getWMSUrl(service, addParams);
7378
- var newXml2jsonrequestURL = xml2jsonrequestURL;
7379
7371
  WMXMLParser(url, headers).then(function (data) {
7380
7372
  try {
7381
7373
  succes(data);
@@ -7385,7 +7377,7 @@
7385
7377
  })["catch"](function () {
7386
7378
  loadGetCapabilitiesViaProxy(url, succes, function () {
7387
7379
  fail("Request failed for " + url);
7388
- }, newXml2jsonrequestURL);
7380
+ }, WMServiceStoreXML2JSONRequest.proxy);
7389
7381
  });
7390
7382
  };
7391
7383
  var sortByKey = function sortByKey(array, key) {
@@ -7446,7 +7438,6 @@
7446
7438
  *
7447
7439
  * options:
7448
7440
  * service
7449
- * xml2jsonrequestURL
7450
7441
  * title (optional)
7451
7442
  */
7452
7443
 
@@ -7467,7 +7458,6 @@
7467
7458
  if (options) {
7468
7459
  this.service = options.service;
7469
7460
  this.title = options.title;
7470
- this.xml2jsonrequestURL = options.xml2jsonrequestURL;
7471
7461
  }
7472
7462
 
7473
7463
  this.checkVersion111 = this.checkVersion111.bind(this);
@@ -7584,7 +7574,7 @@
7584
7574
  */
7585
7575
 
7586
7576
 
7587
- WMJSService.prototype.getCapabilities = function (succescallback, failcallback, forceReload, xml2jsonrequestURL, options) {
7577
+ WMJSService.prototype.getCapabilities = function (succescallback, failcallback, forceReload, options) {
7588
7578
  var _this = this;
7589
7579
 
7590
7580
  if (options) {
@@ -7669,7 +7659,7 @@
7669
7659
  return null;
7670
7660
  }, function () {
7671
7661
  return null;
7672
- }, false, xml2jsonrequestURL, options);
7662
+ }, false, options);
7673
7663
 
7674
7664
  var current;
7675
7665
 
@@ -7678,7 +7668,7 @@
7678
7668
  }
7679
7669
  };
7680
7670
 
7681
- WMJSGetCapabilities(this.service, succes, fail_1, xml2jsonrequestURL, options);
7671
+ WMJSGetCapabilities(this.service, succes, fail_1, options);
7682
7672
  } else {
7683
7673
  /* The callbacks are not allowed to be called in the scope of this object.
7684
7674
  By using window.setTimeOut they are externally called
@@ -7722,13 +7712,9 @@
7722
7712
  */
7723
7713
 
7724
7714
 
7725
- WMJSService.prototype.getNodes = function (succes, failure, forceReload, xml2jsonrequestURL, options) {
7715
+ WMJSService.prototype.getNodes = function (succes, failure, forceReload, options) {
7726
7716
  var _this = this;
7727
7717
 
7728
- if (xml2jsonrequestURL === void 0) {
7729
- xml2jsonrequestURL = this.xml2jsonrequestURL;
7730
- }
7731
-
7732
7718
  this.nodeCache = undefined;
7733
7719
 
7734
7720
  if (!failure) {
@@ -7777,29 +7763,20 @@
7777
7763
  failure(data);
7778
7764
  };
7779
7765
 
7780
- this.getCapabilities(callback, fail, forceReload, xml2jsonrequestURL, options);
7766
+ this.getCapabilities(callback, fail, forceReload, options);
7781
7767
  };
7782
7768
  /** Calls succes with an array of all layerobjects
7783
7769
  * Calls failure when something goes wrong
7784
7770
  */
7785
7771
 
7786
7772
 
7787
- WMJSService.prototype.getLayerObjectsFlat = function (succes, failure, forceReload, xml2jsonrequestURL, options) {
7773
+ WMJSService.prototype.getLayerObjectsFlat = function (succes, failure, forceReload, options) {
7788
7774
  var _this = this;
7789
7775
 
7790
- if (xml2jsonrequestURL === void 0) {
7791
- xml2jsonrequestURL = this.xml2jsonrequestURL;
7792
- }
7793
-
7794
7776
  if (options === void 0) {
7795
7777
  options = this._options;
7796
7778
  }
7797
7779
 
7798
- if (!xml2jsonrequestURL) {
7799
- // eslint-disable-next-line no-param-reassign
7800
- xml2jsonrequestURL = this.xml2jsonrequestURL;
7801
- }
7802
-
7803
7780
  if (isDefined(this._flatLayerObject) && forceReload !== true) {
7804
7781
  succes(this._flatLayerObject);
7805
7782
  return;
@@ -7824,7 +7801,7 @@
7824
7801
  succes(_this._flatLayerObject);
7825
7802
  };
7826
7803
 
7827
- this.getNodes(callback, failure, forceReload, xml2jsonrequestURL, options);
7804
+ this.getNodes(callback, failure, forceReload, options);
7828
7805
  };
7829
7806
 
7830
7807
  return WMJSService;
@@ -7847,20 +7824,15 @@
7847
7824
  * Copyright 2020 - Finnish Meteorological Institute (FMI)
7848
7825
  * */
7849
7826
 
7850
- var WMGetServiceFromStore = function WMGetServiceFromStore(serviceName, xml2jsonrequestURL) {
7827
+ var WMGetServiceFromStore = function WMGetServiceFromStore(serviceName) {
7851
7828
  for (var j = 0; j < WMServiceStore.length; j += 1) {
7852
7829
  if (WMServiceStore[j].service === serviceName) {
7853
7830
  return WMServiceStore[j];
7854
7831
  }
7855
7832
  }
7856
7833
 
7857
- if (xml2jsonrequestURL) {
7858
- WMServiceStoreXML2JSONRequest.proxy = xml2jsonrequestURL;
7859
- }
7860
-
7861
7834
  var service = new WMJSService({
7862
- service: serviceName,
7863
- xml2jsonrequestURL: WMServiceStoreXML2JSONRequest.proxy
7835
+ service: serviceName
7864
7836
  });
7865
7837
  WMServiceStore.push(service);
7866
7838
  return service;
@@ -8017,8 +7989,8 @@
8017
7989
  });
8018
7990
  /* Check if the dimension should take the value from the map */
8019
7991
 
8020
- if (layer.parentMaps.length > 0) {
8021
- var mapDim = layer.parentMaps[0].getDimension(layerDim.name);
7992
+ if (layer.parentMap) {
7993
+ var mapDim = layer.parentMap.getDimension(layerDim.name);
8022
7994
 
8023
7995
  if (mapDim && mapDim.linked && isDefined(mapDim.currentValue)) {
8024
7996
  var dimensionCurrentValue = dimension.getClosestValue(mapDim.currentValue);
@@ -8125,8 +8097,8 @@
8125
8097
  wmLayer.handleReferenceTime('reference_time', refTimeDimension.getValue());
8126
8098
  }
8127
8099
 
8128
- if (wmLayer.parentMaps && wmLayer.parentMaps.length > 0) {
8129
- wmLayer.parentMaps[0].configureMapDimensions(wmLayer);
8100
+ if (wmLayer.parentMap) {
8101
+ wmLayer.parentMap.configureMapDimensions(wmLayer);
8130
8102
  }
8131
8103
  };
8132
8104
 
@@ -8226,8 +8198,8 @@
8226
8198
  this.type = options.type;
8227
8199
  }
8228
8200
 
8229
- if (options.parentMaps) {
8230
- this.parentMaps = options.parentMaps;
8201
+ if (options.parentMap) {
8202
+ this.parentMap = options.parentMap;
8231
8203
  }
8232
8204
 
8233
8205
  if (options.headers) {
@@ -8241,8 +8213,6 @@
8241
8213
  this.timer = undefined;
8242
8214
  this.service = undefined; // URL of the WMS Service
8243
8215
 
8244
- this.WMJSService = undefined; // Corresponding WMJSService
8245
-
8246
8216
  this.getmapURL = undefined;
8247
8217
  this.getfeatureinfoURL = undefined;
8248
8218
  this.getlegendgraphicURL = undefined;
@@ -8273,9 +8243,8 @@
8273
8243
  this.id = '-1';
8274
8244
  this.opacity = 1.0; // Ranges from 0.0-1.0
8275
8245
 
8276
- this.getCapabilitiesDoc = undefined;
8277
8246
  this.serviceTitle = 'not defined';
8278
- this.parentMaps = [];
8247
+ this.parentMap = null;
8279
8248
  this.sldURL = null;
8280
8249
  this.isConfigured = false;
8281
8250
  };
@@ -8292,7 +8261,7 @@
8292
8261
  if (this.autoupdate) {
8293
8262
  var numDeltaMS = 60000;
8294
8263
  this.timer = setInterval(function () {
8295
- _this.parseLayer(undefined, true, undefined);
8264
+ _this.parseLayer(undefined, true);
8296
8265
  }, numDeltaMS);
8297
8266
  } else {
8298
8267
  clearInterval(this.timer);
@@ -8309,7 +8278,7 @@
8309
8278
  clearInterval(this.timer);
8310
8279
  } else {
8311
8280
  this.timer = setInterval(function () {
8312
- _this.parseLayer(callback, true, undefined);
8281
+ _this.parseLayer(callback, true);
8313
8282
  }, interval);
8314
8283
  }
8315
8284
  }
@@ -8317,10 +8286,7 @@
8317
8286
 
8318
8287
  WMLayer.prototype.setOpacity = function (opacityValue) {
8319
8288
  this.opacity = parseFloat(opacityValue);
8320
-
8321
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8322
- this.parentMaps[j].redrawBuffer();
8323
- }
8289
+ this.parentMap && this.parentMap.redrawBuffer();
8324
8290
  };
8325
8291
 
8326
8292
  WMLayer.prototype.getOpacity = function () {
@@ -8328,37 +8294,37 @@
8328
8294
  };
8329
8295
 
8330
8296
  WMLayer.prototype.remove = function () {
8331
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8332
- this.parentMaps[j].deleteLayer(this);
8333
- this.parentMaps[j].draw('WMLayer::remove');
8297
+ if (this.parentMap) {
8298
+ this.parentMap.deleteLayer(this);
8299
+ this.parentMap.draw('WMLayer::remove');
8334
8300
  }
8335
8301
 
8336
8302
  clearInterval(this.timer);
8337
8303
  };
8338
8304
 
8339
8305
  WMLayer.prototype.moveUp = function () {
8340
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8341
- this.parentMaps[j].moveLayerUp(this);
8342
- this.parentMaps[j].draw('WMLayer::moveUp');
8306
+ if (this.parentMap) {
8307
+ this.parentMap.moveLayerUp(this);
8308
+ this.parentMap.draw('WMLayer::moveUp');
8343
8309
  }
8344
8310
  };
8345
8311
 
8346
8312
  WMLayer.prototype.moveDown = function () {
8347
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8348
- this.parentMaps[j].moveLayerDown(this);
8349
- this.parentMaps[j].draw('WMLayer::moveDown');
8313
+ if (this.parentMap) {
8314
+ this.parentMap.moveLayerDown(this);
8315
+ this.parentMap.draw('WMLayer::moveDown');
8350
8316
  }
8351
8317
  };
8352
8318
 
8353
8319
  WMLayer.prototype.zoomToLayer = function () {
8354
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8355
- this.parentMaps[j].zoomToLayer(this);
8320
+ if (this.parentMap) {
8321
+ this.parentMap.zoomToLayer(this);
8356
8322
  }
8357
8323
  };
8358
8324
 
8359
8325
  WMLayer.prototype.draw = function (e) {
8360
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8361
- this.parentMaps[j].draw("WMLayer::draw::" + e);
8326
+ if (this.parentMap) {
8327
+ this.parentMap.draw("WMLayer::draw::" + e);
8362
8328
  }
8363
8329
  };
8364
8330
 
@@ -8375,9 +8341,9 @@
8375
8341
  timeDim.setTimeValuesForReferenceTime(value, referenceTimeDim);
8376
8342
 
8377
8343
  if (updateMapDimensions) {
8378
- if (this.parentMaps && this.parentMaps.length > 0) {
8344
+ if (this.parentMap) {
8379
8345
  if (this.enabled !== false) {
8380
- this.parentMaps[0].getListener().triggerEvent('ondimchange', 'time');
8346
+ this.parentMap.getListener().triggerEvent('ondimchange', 'time');
8381
8347
  }
8382
8348
  }
8383
8349
  }
@@ -8405,42 +8371,40 @@
8405
8371
 
8406
8372
  if (updateMapDimensions) {
8407
8373
  if (dim.linked === true) {
8408
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8409
- this.parentMaps[j].setDimension(name, dim.getValue());
8374
+ if (this.parentMap) {
8375
+ this.parentMap.setDimension(name, dim.getValue());
8410
8376
  }
8411
8377
  }
8412
8378
  }
8413
8379
  };
8414
8380
 
8415
- WMLayer.prototype.__parseGetCapForLayer = function (layer, getcapabilitiesjson, layerDoneCallback, fail) {
8381
+ WMLayer.prototype.__parseGetCapForLayer = function (getcapabilitiesjson, layerDoneCallback, fail) {
8416
8382
  var _this = this;
8417
8383
 
8418
- var jsondata = getcapabilitiesjson;
8419
-
8420
- if (!jsondata) {
8384
+ if (!getcapabilitiesjson) {
8421
8385
  this.title = I18n.service_has_error.text;
8422
8386
  this["abstract"] = I18n.not_available_message.text;
8423
- fail(layer, I18n.unable_to_connect_server.text);
8387
+ fail(this, I18n.unable_to_connect_server.text);
8424
8388
  return;
8425
8389
  }
8426
8390
 
8427
- var j = 0; // Get the capability object
8391
+ var wmjsService = WMGetServiceFromStore(this.service); // Get the capability object
8428
8392
 
8429
8393
  var capabilityObject;
8430
8394
 
8431
8395
  try {
8432
- capabilityObject = layer.WMJSService.getCapabilityElement(getcapabilitiesjson);
8396
+ capabilityObject = wmjsService.getCapabilityElement(getcapabilitiesjson);
8433
8397
  } catch (_a) {
8434
- fail(layer, 'No capability element in service');
8398
+ fail(this, 'No capability element in service');
8435
8399
  return;
8436
8400
  }
8437
8401
 
8438
- this.version = layer.WMJSService.version; // Get the rootLayer
8402
+ this.version = wmjsService.version; // Get the rootLayer
8439
8403
 
8440
8404
  var rootLayer = capabilityObject.Layer;
8441
8405
 
8442
8406
  if (!isDefined(rootLayer)) {
8443
- fail(layer, 'No Layer element in service');
8407
+ fail(this, 'No Layer element in service');
8444
8408
  return;
8445
8409
  }
8446
8410
 
@@ -8512,10 +8476,9 @@
8512
8476
  } // TODO Should be arranged also for the other services:
8513
8477
 
8514
8478
 
8515
- _this.getmapURL = WMJScheckURL(layer.getmapURL);
8516
- _this.getfeatureinfoURL = WMJScheckURL(layer.getfeatureinfoURL);
8517
- _this.getlegendgraphicURL = WMJScheckURL(layer.getlegendgraphicURL);
8518
- _this.getCapabilitiesDoc = jsondata;
8479
+ _this.getmapURL = WMJScheckURL(_this.getmapURL);
8480
+ _this.getfeatureinfoURL = WMJScheckURL(_this.getfeatureinfoURL);
8481
+ _this.getlegendgraphicURL = WMJScheckURL(_this.getlegendgraphicURL);
8519
8482
  _this.title = jsonlayer.Title.value;
8520
8483
 
8521
8484
  try {
@@ -8546,7 +8509,7 @@
8546
8509
  // Fill in SRS and BBOX on basis of BoundingBox attribute
8547
8510
  var gpbbox = toArray(data.BoundingBox);
8548
8511
 
8549
- for (j = 0; j < gpbbox.length; j += 1) {
8512
+ for (var j = 0; j < gpbbox.length; j += 1) {
8550
8513
  var srs = void 0;
8551
8514
  srs = gpbbox[j].attr.SRS;
8552
8515
 
@@ -8574,8 +8537,8 @@
8574
8537
  geoProperty.srs = srs;
8575
8538
  var swapBBOX = false;
8576
8539
 
8577
- if (layer.version === WMSVersion.version130) {
8578
- if (geoProperty.srs === 'EPSG:4326' && layer.wms130bboxcompatibilitymode === false) {
8540
+ if (_this.version === WMSVersion.version130) {
8541
+ if (geoProperty.srs === 'EPSG:4326' && _this.wms130bboxcompatibilitymode === false) {
8579
8542
  swapBBOX = true;
8580
8543
  }
8581
8544
  }
@@ -8603,7 +8566,7 @@
8603
8566
  getgpbbox(jsonlayer);
8604
8567
  getgpbbox(rootLayer); // Fill in SRS on basis of SRS attribute
8605
8568
 
8606
- for (j = 0; j < gp.length; j += 1) {
8569
+ for (var j = 0; j < gp.length; j += 1) {
8607
8570
  if (tempSRS.indexOf(gp[j].value) === -1) {
8608
8571
  var geoProperty = new WMProjection();
8609
8572
  debug(exports.DebugType.Error, "Warning: BoundingBOX missing for SRS " + gp[j].value);
@@ -8612,7 +8575,8 @@
8612
8575
  geoProperty.bbox.right = 180;
8613
8576
  geoProperty.bbox.top = 90;
8614
8577
  geoProperty.srs = gp[j].value;
8615
- layer.projectionProperties.push(geoProperty);
8578
+
8579
+ _this.projectionProperties.push(geoProperty);
8616
8580
  }
8617
8581
  }
8618
8582
 
@@ -8624,13 +8588,13 @@
8624
8588
  try {
8625
8589
  if (parseInt(jsonlayer.attr.queryable, 10) === 1) _this.queryable = true;else _this.queryable = false;
8626
8590
  } catch (e) {
8627
- debug(exports.DebugType.Error, "Unable to detect whether this layer is queryable (for layer " + layer.title + ")");
8591
+ debug(exports.DebugType.Error, "Unable to detect whether this layer is queryable (for layer " + _this.title + ")");
8628
8592
  }
8629
8593
 
8630
8594
  foundLayer = 1;
8631
8595
  };
8632
8596
 
8633
- function recursivelyFindLayer(JSONLayers, path, _prevNestedLayerPath) {
8597
+ function recursivelyFindLayer(thisLayer, JSONLayers, path, _prevNestedLayerPath) {
8634
8598
  for (var k = 0; k < JSONLayers.length; k += 1) {
8635
8599
  var nestedLayerPath_1 = [];
8636
8600
 
@@ -8649,9 +8613,9 @@
8649
8613
  /* Do nothing */
8650
8614
  }
8651
8615
 
8652
- recursivelyFindLayer(toArray(JSONLayers[k].Layer), pathnew, nestedLayerPath_1);
8616
+ recursivelyFindLayer(thisLayer, toArray(JSONLayers[k].Layer), pathnew, nestedLayerPath_1);
8653
8617
  } else if (JSONLayers[k].Name) {
8654
- if (JSONLayers[k].Name.value === layer.name) {
8618
+ if (JSONLayers[k].Name.value === thisLayer.name) {
8655
8619
  foundLayerFunction(JSONLayers[k], path, nestedLayerPath_1);
8656
8620
  return;
8657
8621
  }
@@ -8663,13 +8627,13 @@
8663
8627
  var JSONLayers = toArray(rootLayer.Layer);
8664
8628
  var path = '';
8665
8629
  var nestedLayerPath = [rootLayer];
8666
- recursivelyFindLayer(JSONLayers, path, nestedLayerPath);
8630
+ recursivelyFindLayer(this, JSONLayers, path, nestedLayerPath);
8667
8631
 
8668
8632
  if (foundLayer === 0) {
8669
8633
  // Layer was not found...
8670
8634
  var message = '';
8671
8635
 
8672
- if (layer.name) {
8636
+ if (this.name) {
8673
8637
  message = "Unable to find layer '" + this.name + "' in service '" + this.service + "'";
8674
8638
  } else {
8675
8639
  message = "Unable to find layer '" + this.title + "' in service '" + this.service + "'";
@@ -8697,7 +8661,7 @@
8697
8661
  */
8698
8662
 
8699
8663
 
8700
- WMLayer.prototype.parseLayer = function (_layerDoneCallback, forceReload, xml2jsonrequest) {
8664
+ WMLayer.prototype.parseLayer = function (_layerDoneCallback, forceReload) {
8701
8665
  var _this = this;
8702
8666
 
8703
8667
  this.hasError = false;
@@ -8724,20 +8688,14 @@
8724
8688
  };
8725
8689
 
8726
8690
  var callback = function callback(data) {
8727
- _this.__parseGetCapForLayer(_this, data, layerDoneCallback, fail);
8691
+ _this.__parseGetCapForLayer(data, layerDoneCallback, fail);
8728
8692
  };
8729
8693
 
8730
8694
  var requestfail = function requestfail() {
8731
8695
  fail(_this, I18n.no_capability_element_found.text);
8732
8696
  };
8733
8697
 
8734
- var newXml2jsonrequest = xml2jsonrequest;
8735
-
8736
- if (!xml2jsonrequest) {
8737
- newXml2jsonrequest = this.parentMaps && this.parentMaps.length > 0 ? this.parentMaps[0].xml2jsonrequest : undefined;
8738
- }
8739
-
8740
- this.WMJSService = WMGetServiceFromStore(this.service, newXml2jsonrequest);
8698
+ var wmjsService = WMGetServiceFromStore(this.service);
8741
8699
  var options = {
8742
8700
  headers: {}
8743
8701
  };
@@ -8746,10 +8704,10 @@
8746
8704
  options.headers = this.headers;
8747
8705
  }
8748
8706
 
8749
- if (this.WMJSService.service !== undefined) {
8750
- this.WMJSService.getCapabilities(function (data) {
8707
+ if (wmjsService.service !== undefined) {
8708
+ wmjsService.getCapabilities(function (data) {
8751
8709
  callback(data);
8752
- }, requestfail, forceReload, xml2jsonrequest, options);
8710
+ }, requestfail, forceReload, options);
8753
8711
  }
8754
8712
  };
8755
8713
  /**
@@ -8824,7 +8782,8 @@
8824
8782
  success(layerObjects[currentLayerIndex], currentLayerIndex, layerObjects.length);
8825
8783
  };
8826
8784
 
8827
- this.WMJSService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8785
+ var wmjsService = WMGetServiceFromStore(this.service);
8786
+ wmjsService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8828
8787
  };
8829
8788
 
8830
8789
  WMLayer.prototype.autoSelectLayer = function (success, failure) {
@@ -8841,7 +8800,8 @@
8841
8800
  }
8842
8801
  };
8843
8802
 
8844
- this.WMJSService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8803
+ var wmjsService = WMGetServiceFromStore(this.service);
8804
+ wmjsService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8845
8805
  };
8846
8806
 
8847
8807
  WMLayer.prototype.getNextLayer = function (success, failure) {
@@ -9005,8 +8965,8 @@
9005
8965
  WMLayer.prototype.display = function (displayornot) {
9006
8966
  this.enabled = displayornot;
9007
8967
 
9008
- for (var j = 0; j < this.parentMaps.length; j += 1) {
9009
- this.parentMaps[j].displayLayer(this, this.enabled);
8968
+ if (this.parentMap) {
8969
+ this.parentMap.displayLayer(this, this.enabled);
9010
8970
  }
9011
8971
  };
9012
8972