@opengeoweb/webmap 2.1.0 → 2.1.4

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.
@@ -44,10 +44,22 @@ function _slicedToArray(arr, i) {
44
44
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
45
45
  }
46
46
 
47
+ function _toConsumableArray(arr) {
48
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
49
+ }
50
+
51
+ function _arrayWithoutHoles(arr) {
52
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
53
+ }
54
+
47
55
  function _arrayWithHoles(arr) {
48
56
  if (Array.isArray(arr)) return arr;
49
57
  }
50
58
 
59
+ function _iterableToArray(iter) {
60
+ if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
61
+ }
62
+
51
63
  function _iterableToArrayLimit(arr, i) {
52
64
  if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
53
65
  var _arr = [];
@@ -92,6 +104,10 @@ function _arrayLikeToArray(arr, len) {
92
104
  return arr2;
93
105
  }
94
106
 
107
+ function _nonIterableSpread() {
108
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
109
+ }
110
+
95
111
  function _nonIterableRest() {
96
112
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
97
113
  }
@@ -428,6 +444,53 @@ var dateToISO8601 = function dateToISO8601(date) {
428
444
  var iso = "".concat(prf(date.getUTCFullYear(), 4), "-").concat(prf(date.getUTCMonth() + 1, 2), "-").concat(prf(date.getUTCDate(), 2), "T").concat(prf(date.getUTCHours(), 2), ":").concat(prf(date.getUTCMinutes(), 2), ":").concat(prf(date.getUTCSeconds(), 2), "Z");
429
445
  return iso;
430
446
  };
447
+ /**
448
+ * Helper function to figure out the styles from the WMS layer object from the WMS GetCapabilties document
449
+ * @param layerObjectFromWMS The layer object from the WMS GetCapabilities JSON document
450
+ * @returns Style[] Array of style objects.
451
+ */
452
+
453
+ var addStylesForLayer = function addStylesForLayer(layerObjectFromWMS) {
454
+ /* Get the Style object */
455
+ if (!layerObjectFromWMS.Style) return [];
456
+ var layerStyles = toArray(layerObjectFromWMS.Style);
457
+ /* Loop through the list of styles from the document, create a default object and try to fill in the object with the props from the WMS GetCapabilities document */
458
+
459
+ return layerStyles.map(function (layerStyle) {
460
+ var style = {
461
+ title: 'default',
462
+ name: 'default',
463
+ legendURL: '',
464
+ "abstract": 'No abstract available'
465
+ };
466
+
467
+ try {
468
+ style.title = layerStyle.Title.value;
469
+ } catch (e) {
470
+ /* Do nothing */
471
+ }
472
+
473
+ try {
474
+ style.name = layerStyle.Name.value;
475
+ } catch (e) {
476
+ /* Do nothing */
477
+ }
478
+
479
+ try {
480
+ style.legendURL = layerStyle.LegendURL.OnlineResource.attr['xlink:href'];
481
+ } catch (e) {
482
+ /* Do nothing */
483
+ }
484
+
485
+ try {
486
+ style["abstract"] = layerStyle.Abstract.value;
487
+ } catch (e) {
488
+ /* Do nothing */
489
+ }
490
+
491
+ return style;
492
+ });
493
+ };
431
494
 
432
495
  /**
433
496
  * WMImage provides an API to the HTML image element. It is used for caching and easier access to images.
@@ -3399,7 +3462,6 @@ var WMJSDimension = /*#__PURE__*/function () {
3399
3462
  * */
3400
3463
  var WMDrawMarker = function WMDrawMarker(context, coordx, coordy) {
3401
3464
  var fillColor = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '#FFF';
3402
- var outlineColor = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '#000';
3403
3465
  var ctx = context;
3404
3466
  var coord = {
3405
3467
  x: parseInt(coordx.toString(), 10),
@@ -3408,8 +3470,8 @@ var WMDrawMarker = function WMDrawMarker(context, coordx, coordy) {
3408
3470
  ctx.fillStyle = fillColor;
3409
3471
  ctx.globalAlpha = 1.0;
3410
3472
  ctx.beginPath();
3411
- var topRadius = 9;
3412
- var topHeight = 2.5 * topRadius;
3473
+ var topRadius = 7;
3474
+ var topHeight = 2 * topRadius;
3413
3475
  ctx.arc(coord.x, coord.y - topHeight, topRadius, Math.PI, Math.PI * 2);
3414
3476
  ctx.bezierCurveTo(coord.x + topRadius, coord.y - topHeight, coord.x + topRadius / 1.6, coord.y - topRadius, coord.x, coord.y);
3415
3477
  ctx.bezierCurveTo(coord.x, coord.y, coord.x - topRadius / 1.6, coord.y - topRadius, coord.x - topRadius, coord.y - topHeight);
@@ -3419,13 +3481,7 @@ var WMDrawMarker = function WMDrawMarker(context, coordx, coordy) {
3419
3481
 
3420
3482
  ctx.fillStyle = '#FFF';
3421
3483
  ctx.beginPath();
3422
- ctx.arc(coord.x, coord.y - topHeight, topRadius / 2, Math.PI * 2, 0);
3423
- ctx.fill();
3424
- /* Fill marker exact location */
3425
-
3426
- ctx.fillStyle = outlineColor;
3427
- ctx.beginPath();
3428
- ctx.arc(coord.x, coord.y, 2, Math.PI * 2, 0);
3484
+ ctx.arc(coord.x, coord.y - topHeight, topRadius / 2.5, Math.PI * 2, 0);
3429
3485
  ctx.fill();
3430
3486
  };
3431
3487
 
@@ -3506,7 +3562,7 @@ var MapPin = /*#__PURE__*/function () {
3506
3562
  key: "drawMarker",
3507
3563
  value: function drawMarker(ctx) {
3508
3564
  if (isDefined(this.x) && isDefined(this.y)) {
3509
- WMDrawMarker(ctx, this.x, this.y, '#9090FF', '#000');
3565
+ WMDrawMarker(ctx, this.x, this.y, '#051039');
3510
3566
  }
3511
3567
  }
3512
3568
  }]);
@@ -3967,7 +4023,6 @@ var WMJSMap = /*#__PURE__*/function () {
3967
4023
  this.previousMouseButtonState = 'up';
3968
4024
  /* Binds */
3969
4025
 
3970
- this.setXML2JSONURL = this.setXML2JSONURL.bind(this);
3971
4026
  this.setWMTileRendererTileSettings = this.setWMTileRendererTileSettings.bind(this);
3972
4027
  this.makeComponentId = this.makeComponentId.bind(this);
3973
4028
  this.setMessage = this.setMessage.bind(this);
@@ -4093,11 +4148,6 @@ var WMJSMap = /*#__PURE__*/function () {
4093
4148
  }
4094
4149
 
4095
4150
  _createClass(WMJSMap, [{
4096
- key: "setXML2JSONURL",
4097
- value: function setXML2JSONURL(_xml2jsonrequest) {
4098
- this.xml2jsonrequest = _xml2jsonrequest;
4099
- }
4100
- }, {
4101
4151
  key: "setWMTileRendererTileSettings",
4102
4152
  value: function setWMTileRendererTileSettings(_WMTileRendererTileSettings) {
4103
4153
  this.tileRenderSettings = _WMTileRendererTileSettings;
@@ -4419,6 +4469,7 @@ var WMJSMap = /*#__PURE__*/function () {
4419
4469
 
4420
4470
  ctx.font = '10px Helvetica';
4421
4471
  ctx.textBaseline = 'middle';
4472
+ ctx.textAlign = 'left';
4422
4473
 
4423
4474
  if (isDefined(this.mouseGeoCoordXY)) {
4424
4475
  var roundingFactor = 1.0 / Math.pow(10, parseInt(Math.log((this.bbox.right - this.bbox.left) / this.width) / Math.log(10), 10) - 2);
@@ -4453,6 +4504,30 @@ var WMJSMap = /*#__PURE__*/function () {
4453
4504
 
4454
4505
  ctx.fillStyle = '#000000';
4455
4506
  ctx.fillText("Map projection: ".concat(this.srs), 5, this.height - 26);
4507
+ /* Show layer metadata */
4508
+
4509
+ if (this.showLayerInfo === true) {
4510
+ var metadataX = 100;
4511
+ var metadataY = 100;
4512
+ var dimStartX = 150;
4513
+ var rowHeight = 26;
4514
+ var rowNumber = 0;
4515
+ drawTextBG(ctx, 'Layer name', metadataX, metadataY + rowNumber * rowHeight, 10);
4516
+ drawTextBG(ctx, 'Dimensions', metadataX + dimStartX, metadataY + rowNumber * rowHeight, 10);
4517
+ rowNumber += 1;
4518
+
4519
+ for (var _j3 = 0; _j3 < this.layers.length; _j3 += 1) {
4520
+ var layer = this.layers[_j3];
4521
+ drawTextBG(ctx, "#".concat(_j3, ":").concat(layer.name), metadataX, metadataY + rowNumber * rowHeight, 10);
4522
+
4523
+ for (var d = 0; d < layer.dimensions.length; d += 1) {
4524
+ var dimension = layer.dimensions[d];
4525
+ drawTextBG(ctx, "".concat(dimension.name, " = ").concat(dimension.currentValue), metadataX + d * 200 + dimStartX, metadataY + rowNumber * rowHeight, 10);
4526
+ }
4527
+
4528
+ rowNumber += 1;
4529
+ }
4530
+ }
4456
4531
  }
4457
4532
  /* Is called when the WebMapJS object is created */
4458
4533
 
@@ -4604,8 +4679,8 @@ var WMJSMap = /*#__PURE__*/function () {
4604
4679
  }
4605
4680
 
4606
4681
  for (var i = 0; i < this.layers.length; i += 1) {
4607
- for (var _j3 = 0; _j3 < this.layers[i].dimensions.length; _j3 += 1) {
4608
- var dim = this.layers[i].dimensions[_j3];
4682
+ for (var _j4 = 0; _j4 < this.layers[i].dimensions.length; _j4 += 1) {
4683
+ var dim = this.layers[i].dimensions[_j4];
4609
4684
  var mapdim = this.getDimension(dim.name);
4610
4685
 
4611
4686
  if (isDefined(mapdim)) {
@@ -4618,10 +4693,10 @@ var WMJSMap = /*#__PURE__*/function () {
4618
4693
  }
4619
4694
  }
4620
4695
 
4621
- for (var _j4 = 0; _j4 < this.mapdimensions.length; _j4 += 1) {
4622
- if (this.mapdimensions[_j4].used === false) {
4623
- this.mapdimensions.splice(_j4, 1);
4624
- _j4 -= 1;
4696
+ for (var _j5 = 0; _j5 < this.mapdimensions.length; _j5 += 1) {
4697
+ if (this.mapdimensions[_j5].used === false) {
4698
+ this.mapdimensions.splice(_j5, 1);
4699
+ _j5 -= 1;
4625
4700
  }
4626
4701
  }
4627
4702
 
@@ -4880,10 +4955,10 @@ var WMJSMap = /*#__PURE__*/function () {
4880
4955
  reject(new Error('layer has no constructor'));
4881
4956
  return;
4882
4957
  }
4958
+ /* Set a reference in the layer to this map */
4883
4959
 
4884
- if (!layer.parentMaps.includes(_this5)) {
4885
- layer.parentMaps.push(_this5);
4886
- }
4960
+
4961
+ layer.parentMap = _this5;
4887
4962
 
4888
4963
  _this5.layers.push(layer);
4889
4964
 
@@ -4895,7 +4970,7 @@ var WMJSMap = /*#__PURE__*/function () {
4895
4970
  resolve(_this5);
4896
4971
  };
4897
4972
 
4898
- layer.parseLayer(done, undefined);
4973
+ layer.parseLayer(done, undefined, 'WMJSMap addLayer');
4899
4974
  });
4900
4975
  }
4901
4976
  }, {
@@ -4920,6 +4995,11 @@ var WMJSMap = /*#__PURE__*/function () {
4920
4995
  }
4921
4996
 
4922
4997
  if (!_srs) _srs = 'EPSG:4326';
4998
+
4999
+ if (this.srs !== _srs) {
5000
+ this.defaultBBOX.setBBOX(_bbox);
5001
+ }
5002
+
4923
5003
  this.srs = _srs;
4924
5004
 
4925
5005
  if (this.proj4.srs !== this.srs || !isDefined(this.proj4.projection)) {
@@ -4933,7 +5013,6 @@ var WMJSMap = /*#__PURE__*/function () {
4933
5013
  }
4934
5014
 
4935
5015
  this.setBBOX(_bbox);
4936
- this.defaultBBOX.setBBOX(_bbox);
4937
5016
  this.updateMouseCursorCoordinates(undefined);
4938
5017
  this.callBack.triggerEvent('onsetprojection', [this.srs, this.bbox]);
4939
5018
  }
@@ -5239,12 +5318,19 @@ var WMJSMap = /*#__PURE__*/function () {
5239
5318
  if (animationList !== undefined) {
5240
5319
  if (_typeof(animationList) === 'object') {
5241
5320
  if (animationList.length > 0) {
5321
+ // Ensure the time dimension has been loaded for the map before starting animation
5322
+ var timeDim = this.getDimension('time');
5323
+
5324
+ if (!timeDim) {
5325
+ return;
5326
+ }
5327
+
5328
+ var selectedTime = timeDim.currentValue;
5242
5329
  this.isAnimating = true;
5243
5330
  this.callBack.triggerEvent('onstartanimation', this);
5244
5331
  this.currentAnimationStep = 0;
5245
5332
  this.animationList = [];
5246
5333
  this.mouseHoverAnimationBox = false;
5247
- var selectedTime = this.getDimension('time').currentValue;
5248
5334
 
5249
5335
  for (var j = 0; j < animationList.length; j += 1) {
5250
5336
  if (selectedTime && animationList[j].value === selectedTime) {
@@ -5422,9 +5508,7 @@ var WMJSMap = /*#__PURE__*/function () {
5422
5508
  this.baseLayers = layer;
5423
5509
 
5424
5510
  for (var j = 0; j < this.baseLayers.length; j += 1) {
5425
- if (!this.baseLayers[j].parentMaps.includes(this)) {
5426
- this.baseLayers[j].parentMaps.push(this);
5427
- }
5511
+ this.baseLayers[j].parentMap = this;
5428
5512
 
5429
5513
  if (this.baseLayers[j].keepOnTop !== true) {
5430
5514
  this.numBaseLayers += 1;
@@ -6648,17 +6732,17 @@ var WMJSMap = /*#__PURE__*/function () {
6648
6732
  this.WMProjectionTempUndo[j] = this.WMProjectionUndo[j];
6649
6733
  }
6650
6734
 
6651
- for (var _j5 = 0; _j5 <= this.UndoPointer; _j5 += 1) {
6652
- this.WMProjectionUndo[_j5] = this.WMProjectionTempUndo[this.UndoPointer - _j5];
6735
+ for (var _j6 = 0; _j6 <= this.UndoPointer; _j6 += 1) {
6736
+ this.WMProjectionUndo[_j6] = this.WMProjectionTempUndo[this.UndoPointer - _j6];
6653
6737
  }
6654
6738
 
6655
6739
  this.UndoPointer = 0;
6656
6740
  }
6657
6741
 
6658
- for (var _j6 = this.MaxUndos - 1; _j6 > 0; _j6 -= 1) {
6659
- this.WMProjectionUndo[_j6].bbox.setBBOX(this.WMProjectionUndo[_j6 - 1].bbox);
6742
+ for (var _j7 = this.MaxUndos - 1; _j7 > 0; _j7 -= 1) {
6743
+ this.WMProjectionUndo[_j7].bbox.setBBOX(this.WMProjectionUndo[_j7 - 1].bbox);
6660
6744
 
6661
- this.WMProjectionUndo[_j6].srs = this.WMProjectionUndo[_j6 - 1].srs;
6745
+ this.WMProjectionUndo[_j7].srs = this.WMProjectionUndo[_j7 - 1].srs;
6662
6746
  }
6663
6747
 
6664
6748
  this.WMProjectionUndo[0].bbox.setBBOX(this.bbox);
@@ -7324,8 +7408,8 @@ var getWMSUrl = function getWMSUrl() {
7324
7408
  * Global getcapabilities function
7325
7409
  */
7326
7410
 
7327
- var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, xml2jsonrequestURL, options) {
7328
- var disableCache = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
7411
+ var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, options) {
7412
+ var disableCache = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
7329
7413
 
7330
7414
  /* Make the getCapabilitiesJSONrequest */
7331
7415
  var headers = [];
@@ -7369,7 +7453,6 @@ var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, xm
7369
7453
  random: Math.random()
7370
7454
  } : {};
7371
7455
  var url = getWMSUrl(service, addParams);
7372
- var newXml2jsonrequestURL = xml2jsonrequestURL;
7373
7456
  WMXMLParser(url, headers).then(function (data) {
7374
7457
  try {
7375
7458
  succes(data);
@@ -7379,7 +7462,7 @@ var WMJSGetCapabilities = function WMJSGetCapabilities(service, succes, fail, xm
7379
7462
  })["catch"](function () {
7380
7463
  loadGetCapabilitiesViaProxy(url, succes, function () {
7381
7464
  fail("Request failed for ".concat(url));
7382
- }, newXml2jsonrequestURL);
7465
+ }, WMServiceStoreXML2JSONRequest.proxy);
7383
7466
  });
7384
7467
  };
7385
7468
  var sortByKey = function sortByKey(array, key) {
@@ -7414,13 +7497,15 @@ rootNode, path) {
7414
7497
  keywords: toArray(layers[j].KeywordList && layers[j].KeywordList.Keyword).map(function (keywords) {
7415
7498
  return keywords.value;
7416
7499
  }),
7417
- "abstract": layers[j].Abstract && layers[j].Abstract.value
7500
+ "abstract": layers[j].Abstract && layers[j].Abstract.value,
7501
+ styles: addStylesForLayer(layers[j])
7418
7502
  };
7419
7503
  } else {
7420
7504
  var nodeText = isNull(layers[j].Title) ? 'Layer' : layers[j].Title.value;
7421
7505
  nodeObject = {
7422
7506
  text: nodeText,
7423
- leaf: isleaf
7507
+ leaf: isleaf,
7508
+ styles: []
7424
7509
  };
7425
7510
  }
7426
7511
 
@@ -7440,7 +7525,6 @@ rootNode, path) {
7440
7525
  *
7441
7526
  * options:
7442
7527
  * service
7443
- * xml2jsonrequestURL
7444
7528
  * title (optional)
7445
7529
  */
7446
7530
 
@@ -7461,7 +7545,6 @@ var WMJSService = /*#__PURE__*/function () {
7461
7545
  if (options) {
7462
7546
  this.service = options.service;
7463
7547
  this.title = options.title;
7464
- this.xml2jsonrequestURL = options.xml2jsonrequestURL;
7465
7548
  }
7466
7549
 
7467
7550
  this.checkVersion111 = this.checkVersion111.bind(this);
@@ -7584,7 +7667,7 @@ var WMJSService = /*#__PURE__*/function () {
7584
7667
 
7585
7668
  }, {
7586
7669
  key: "getCapabilities",
7587
- value: function getCapabilities(succescallback, failcallback, forceReload, xml2jsonrequestURL, options) {
7670
+ value: function getCapabilities(succescallback, failcallback, forceReload, options) {
7588
7671
  var _this = this;
7589
7672
 
7590
7673
  if (options) {
@@ -7669,7 +7752,7 @@ var WMJSService = /*#__PURE__*/function () {
7669
7752
  return null;
7670
7753
  }, function () {
7671
7754
  return null;
7672
- }, false, xml2jsonrequestURL, options);
7755
+ }, false, options);
7673
7756
 
7674
7757
  var current;
7675
7758
 
@@ -7678,14 +7761,9 @@ var WMJSService = /*#__PURE__*/function () {
7678
7761
  }
7679
7762
  };
7680
7763
 
7681
- WMJSGetCapabilities(this.service, succes, fail, xml2jsonrequestURL, options);
7764
+ WMJSGetCapabilities(this.service, succes, fail, options);
7682
7765
  } else {
7683
- /* The callbacks are not allowed to be called in the scope of this object.
7684
- By using window.setTimeOut they are externally called
7685
- */
7686
- window.setTimeout(function () {
7687
- succescallback(_this.getcapabilitiesDoc);
7688
- }, 1);
7766
+ succescallback(this.getcapabilitiesDoc);
7689
7767
  }
7690
7768
  } // eslint-disable-next-line class-methods-use-this
7691
7769
 
@@ -7724,11 +7802,9 @@ var WMJSService = /*#__PURE__*/function () {
7724
7802
 
7725
7803
  }, {
7726
7804
  key: "getNodes",
7727
- value: function getNodes(succes, failure, forceReload) {
7805
+ value: function getNodes(succes, failure, forceReload, options) {
7728
7806
  var _this2 = this;
7729
7807
 
7730
- var xml2jsonrequestURL = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.xml2jsonrequestURL;
7731
- var options = arguments.length > 4 ? arguments[4] : undefined;
7732
7808
  this.nodeCache = undefined;
7733
7809
 
7734
7810
  if (!failure) {
@@ -7777,7 +7853,7 @@ var WMJSService = /*#__PURE__*/function () {
7777
7853
  failure(data);
7778
7854
  };
7779
7855
 
7780
- this.getCapabilities(callback, fail, forceReload, xml2jsonrequestURL, options);
7856
+ this.getCapabilities(callback, fail, forceReload, options);
7781
7857
  }
7782
7858
  /** Calls succes with an array of all layerobjects
7783
7859
  * Calls failure when something goes wrong
@@ -7788,13 +7864,7 @@ var WMJSService = /*#__PURE__*/function () {
7788
7864
  value: function getLayerObjectsFlat(succes, failure, forceReload) {
7789
7865
  var _this3 = this;
7790
7866
 
7791
- var xml2jsonrequestURL = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this.xml2jsonrequestURL;
7792
- var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this._options;
7793
-
7794
- if (!xml2jsonrequestURL) {
7795
- // eslint-disable-next-line no-param-reassign
7796
- xml2jsonrequestURL = this.xml2jsonrequestURL;
7797
- }
7867
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : this._options;
7798
7868
 
7799
7869
  if (isDefined(this._flatLayerObject) && forceReload !== true) {
7800
7870
  succes(this._flatLayerObject);
@@ -7820,7 +7890,7 @@ var WMJSService = /*#__PURE__*/function () {
7820
7890
  succes(_this3._flatLayerObject);
7821
7891
  };
7822
7892
 
7823
- this.getNodes(callback, failure, forceReload, xml2jsonrequestURL, options);
7893
+ this.getNodes(callback, failure, forceReload, options);
7824
7894
  }
7825
7895
  }]);
7826
7896
 
@@ -7844,20 +7914,15 @@ var WMJSService = /*#__PURE__*/function () {
7844
7914
  * Copyright 2020 - Finnish Meteorological Institute (FMI)
7845
7915
  * */
7846
7916
 
7847
- var WMGetServiceFromStore = function WMGetServiceFromStore(serviceName, xml2jsonrequestURL) {
7917
+ var WMGetServiceFromStore = function WMGetServiceFromStore(serviceName) {
7848
7918
  for (var j = 0; j < WMServiceStore.length; j += 1) {
7849
7919
  if (WMServiceStore[j].service === serviceName) {
7850
7920
  return WMServiceStore[j];
7851
7921
  }
7852
7922
  }
7853
7923
 
7854
- if (xml2jsonrequestURL) {
7855
- WMServiceStoreXML2JSONRequest.proxy = xml2jsonrequestURL;
7856
- }
7857
-
7858
7924
  var service = new WMJSService({
7859
- service: serviceName,
7860
- xml2jsonrequestURL: WMServiceStoreXML2JSONRequest.proxy
7925
+ service: serviceName
7861
7926
  });
7862
7927
  WMServiceStore.push(service);
7863
7928
  return service;
@@ -7870,55 +7935,6 @@ var LayerType;
7870
7935
  LayerType["baseLayer"] = "baseLayer";
7871
7936
  LayerType["overLayer"] = "overLayer";
7872
7937
  })(LayerType || (LayerType = {}));
7873
- /**
7874
- * Helper function to figure out the styles from the WMS layer object from the WMS GetCapabilties document
7875
- * @param layerStyles The layer styles object from the WMS GetCapabilities
7876
- * @param layer The WMLayer to configure
7877
- */
7878
-
7879
-
7880
- var addStylesForLayer = function addStylesForLayer(layerObjectFromWMS, layer) {
7881
- /* Get the Style object */
7882
- if (!layerObjectFromWMS.Style) return;
7883
- var layerStyles = toArray(layerObjectFromWMS.Style);
7884
- /* Loop through the list of styles from the document, create a default object and try to fill in the object with the props from the WMS GetCapabilities document */
7885
-
7886
- for (var k = 0; k < layerStyles.length; k += 1) {
7887
- var layerStyle = layerStyles[k];
7888
- var style = {
7889
- title: 'default',
7890
- name: 'default',
7891
- legendURL: '',
7892
- "abstract": 'No abstract available'
7893
- };
7894
-
7895
- try {
7896
- style.title = layerStyle.Title.value;
7897
- } catch (e) {
7898
- /* Do nothing */
7899
- }
7900
-
7901
- try {
7902
- style.name = layerStyle.Name.value;
7903
- } catch (e) {
7904
- /* Do nothing */
7905
- }
7906
-
7907
- try {
7908
- style.legendURL = layerStyle.LegendURL.OnlineResource.attr['xlink:href'];
7909
- } catch (e) {
7910
- /* Do nothing */
7911
- }
7912
-
7913
- try {
7914
- style["abstract"] = layerStyle.Abstract.value;
7915
- } catch (e) {
7916
- /* Do nothing */
7917
- }
7918
-
7919
- layer.styles.push(style);
7920
- }
7921
- };
7922
7938
  /**
7923
7939
  * Helper function to figure out the dimensions from the WMS layer object (From WMS GetCapabilities). Parses both WMS 1.1.1 and WMS 1.3.0.
7924
7940
  * @param layerObjectFromWMS The corresponding layer object from the WMS GetCapabilities.
@@ -7926,6 +7942,7 @@ var addStylesForLayer = function addStylesForLayer(layerObjectFromWMS, layer) {
7926
7942
  * @param layerDimNamesToRemove A set of dimensions names which are flagged for removal, this function removes the dimension from the set if found in the layer.
7927
7943
  */
7928
7944
 
7945
+
7929
7946
  var addDimsForLayer = function addDimsForLayer(layerObjectFromWMS, layer, layerDimNamesToRemove) {
7930
7947
  /* Information from the WMS GetCapabilities document */
7931
7948
  var layerDims = toArray(layerObjectFromWMS.Dimension);
@@ -7999,8 +8016,8 @@ var addDimsForLayer = function addDimsForLayer(layerObjectFromWMS, layer, layerD
7999
8016
  });
8000
8017
  /* Check if the dimension should take the value from the map */
8001
8018
 
8002
- if (layer.parentMaps.length > 0) {
8003
- var mapDim = layer.parentMaps[0].getDimension(layerDim.name);
8019
+ if (layer.parentMap) {
8020
+ var mapDim = layer.parentMap.getDimension(layerDim.name);
8004
8021
 
8005
8022
  if (mapDim && mapDim.linked && isDefined(mapDim.currentValue)) {
8006
8023
  var dimensionCurrentValue = dimension.getClosestValue(mapDim.currentValue);
@@ -8036,7 +8053,10 @@ var configureStyles = function configureStyles(nestedLayerPath, wmLayer) {
8036
8053
  /* Now add the previous parent layer objects style info (inherit) and end with the Style info from this layer */
8037
8054
  try {
8038
8055
  for (var o = 0; o < nestedLayerPath.length; o += 1) {
8039
- addStylesForLayer(nestedLayerPath[o], wmLayer);
8056
+ var _wmLayer$styles;
8057
+
8058
+ // eslint-disable-next-line no-param-reassign
8059
+ (_wmLayer$styles = wmLayer.styles).push.apply(_wmLayer$styles, _toConsumableArray(addStylesForLayer(nestedLayerPath[o])));
8040
8060
  } // eslint-disable-next-line no-empty
8041
8061
 
8042
8062
  } catch (_a) {}
@@ -8105,8 +8125,8 @@ var configureDimensions = function configureDimensions(nestedLayerPath, wmLayer)
8105
8125
  wmLayer.handleReferenceTime('reference_time', refTimeDimension.getValue());
8106
8126
  }
8107
8127
 
8108
- if (wmLayer.parentMaps && wmLayer.parentMaps.length > 0) {
8109
- wmLayer.parentMaps[0].configureMapDimensions(wmLayer);
8128
+ if (wmLayer.parentMap) {
8129
+ wmLayer.parentMap.configureMapDimensions(wmLayer);
8110
8130
  }
8111
8131
  };
8112
8132
 
@@ -8206,8 +8226,8 @@ var WMLayer = /*#__PURE__*/function () {
8206
8226
  this.type = options.type;
8207
8227
  }
8208
8228
 
8209
- if (options.parentMaps) {
8210
- this.parentMaps = options.parentMaps;
8229
+ if (options.parentMap) {
8230
+ this.parentMap = options.parentMap;
8211
8231
  }
8212
8232
 
8213
8233
  if (options.headers) {
@@ -8223,8 +8243,6 @@ var WMLayer = /*#__PURE__*/function () {
8223
8243
  this.timer = undefined;
8224
8244
  this.service = undefined; // URL of the WMS Service
8225
8245
 
8226
- this.WMJSService = undefined; // Corresponding WMJSService
8227
-
8228
8246
  this.getmapURL = undefined;
8229
8247
  this.getfeatureinfoURL = undefined;
8230
8248
  this.getlegendgraphicURL = undefined;
@@ -8255,9 +8273,8 @@ var WMLayer = /*#__PURE__*/function () {
8255
8273
  this.id = '-1';
8256
8274
  this.opacity = 1.0; // Ranges from 0.0-1.0
8257
8275
 
8258
- this.getCapabilitiesDoc = undefined;
8259
8276
  this.serviceTitle = 'not defined';
8260
- this.parentMaps = [];
8277
+ this.parentMap = null;
8261
8278
  this.sldURL = null;
8262
8279
  this.isConfigured = false;
8263
8280
  }
@@ -8276,7 +8293,7 @@ var WMLayer = /*#__PURE__*/function () {
8276
8293
  if (this.autoupdate) {
8277
8294
  var numDeltaMS = 60000;
8278
8295
  this.timer = setInterval(function () {
8279
- _this.parseLayer(undefined, true, undefined);
8296
+ _this.parseLayer(undefined, true, 'WMLayer toggleAutoUpdate');
8280
8297
  }, numDeltaMS);
8281
8298
  } else {
8282
8299
  clearInterval(this.timer);
@@ -8294,7 +8311,7 @@ var WMLayer = /*#__PURE__*/function () {
8294
8311
  clearInterval(this.timer);
8295
8312
  } else {
8296
8313
  this.timer = setInterval(function () {
8297
- _this2.parseLayer(callback, true, undefined);
8314
+ _this2.parseLayer(callback, true, 'WMLayer setAutoUpdate');
8298
8315
  }, interval);
8299
8316
  }
8300
8317
  }
@@ -8303,10 +8320,7 @@ var WMLayer = /*#__PURE__*/function () {
8303
8320
  key: "setOpacity",
8304
8321
  value: function setOpacity(opacityValue) {
8305
8322
  this.opacity = parseFloat(opacityValue);
8306
-
8307
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8308
- this.parentMaps[j].redrawBuffer();
8309
- }
8323
+ this.parentMap && this.parentMap.redrawBuffer();
8310
8324
  }
8311
8325
  }, {
8312
8326
  key: "getOpacity",
@@ -8316,9 +8330,9 @@ var WMLayer = /*#__PURE__*/function () {
8316
8330
  }, {
8317
8331
  key: "remove",
8318
8332
  value: function remove() {
8319
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8320
- this.parentMaps[j].deleteLayer(this);
8321
- this.parentMaps[j].draw('WMLayer::remove');
8333
+ if (this.parentMap) {
8334
+ this.parentMap.deleteLayer(this);
8335
+ this.parentMap.draw('WMLayer::remove');
8322
8336
  }
8323
8337
 
8324
8338
  clearInterval(this.timer);
@@ -8326,31 +8340,31 @@ var WMLayer = /*#__PURE__*/function () {
8326
8340
  }, {
8327
8341
  key: "moveUp",
8328
8342
  value: function moveUp() {
8329
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8330
- this.parentMaps[j].moveLayerUp(this);
8331
- this.parentMaps[j].draw('WMLayer::moveUp');
8343
+ if (this.parentMap) {
8344
+ this.parentMap.moveLayerUp(this);
8345
+ this.parentMap.draw('WMLayer::moveUp');
8332
8346
  }
8333
8347
  }
8334
8348
  }, {
8335
8349
  key: "moveDown",
8336
8350
  value: function moveDown() {
8337
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8338
- this.parentMaps[j].moveLayerDown(this);
8339
- this.parentMaps[j].draw('WMLayer::moveDown');
8351
+ if (this.parentMap) {
8352
+ this.parentMap.moveLayerDown(this);
8353
+ this.parentMap.draw('WMLayer::moveDown');
8340
8354
  }
8341
8355
  }
8342
8356
  }, {
8343
8357
  key: "zoomToLayer",
8344
8358
  value: function zoomToLayer() {
8345
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8346
- this.parentMaps[j].zoomToLayer(this);
8359
+ if (this.parentMap) {
8360
+ this.parentMap.zoomToLayer(this);
8347
8361
  }
8348
8362
  }
8349
8363
  }, {
8350
8364
  key: "draw",
8351
8365
  value: function draw(e) {
8352
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8353
- this.parentMaps[j].draw("WMLayer::draw::".concat(e));
8366
+ if (this.parentMap) {
8367
+ this.parentMap.draw("WMLayer::draw::".concat(e));
8354
8368
  }
8355
8369
  }
8356
8370
  }, {
@@ -8366,9 +8380,9 @@ var WMLayer = /*#__PURE__*/function () {
8366
8380
  timeDim.setTimeValuesForReferenceTime(value, referenceTimeDim);
8367
8381
 
8368
8382
  if (updateMapDimensions) {
8369
- if (this.parentMaps && this.parentMaps.length > 0) {
8383
+ if (this.parentMap) {
8370
8384
  if (this.enabled !== false) {
8371
- this.parentMaps[0].getListener().triggerEvent('ondimchange', 'time');
8385
+ this.parentMap.getListener().triggerEvent('ondimchange', 'time');
8372
8386
  }
8373
8387
  }
8374
8388
  }
@@ -8395,43 +8409,41 @@ var WMLayer = /*#__PURE__*/function () {
8395
8409
 
8396
8410
  if (updateMapDimensions) {
8397
8411
  if (dim.linked === true) {
8398
- for (var j = 0; j < this.parentMaps.length; j += 1) {
8399
- this.parentMaps[j].setDimension(name, dim.getValue());
8412
+ if (this.parentMap) {
8413
+ this.parentMap.setDimension(name, dim.getValue());
8400
8414
  }
8401
8415
  }
8402
8416
  }
8403
8417
  }
8404
8418
  }, {
8405
8419
  key: "__parseGetCapForLayer",
8406
- value: function __parseGetCapForLayer(layer, getcapabilitiesjson, layerDoneCallback, fail) {
8420
+ value: function __parseGetCapForLayer(getcapabilitiesjson, layerDoneCallback, fail) {
8407
8421
  var _this3 = this;
8408
8422
 
8409
- var jsondata = getcapabilitiesjson;
8410
-
8411
- if (!jsondata) {
8423
+ if (!getcapabilitiesjson) {
8412
8424
  this.title = I18n.service_has_error.text;
8413
8425
  this["abstract"] = I18n.not_available_message.text;
8414
- fail(layer, I18n.unable_to_connect_server.text);
8426
+ fail(this, I18n.unable_to_connect_server.text);
8415
8427
  return;
8416
8428
  }
8417
8429
 
8418
- var j = 0; // Get the capability object
8430
+ var wmjsService = WMGetServiceFromStore(this.service); // Get the capability object
8419
8431
 
8420
8432
  var capabilityObject;
8421
8433
 
8422
8434
  try {
8423
- capabilityObject = layer.WMJSService.getCapabilityElement(getcapabilitiesjson);
8435
+ capabilityObject = wmjsService.getCapabilityElement(getcapabilitiesjson);
8424
8436
  } catch (_a) {
8425
- fail(layer, 'No capability element in service');
8437
+ fail(this, 'No capability element in service');
8426
8438
  return;
8427
8439
  }
8428
8440
 
8429
- this.version = layer.WMJSService.version; // Get the rootLayer
8441
+ this.version = wmjsService.version; // Get the rootLayer
8430
8442
 
8431
8443
  var rootLayer = capabilityObject.Layer;
8432
8444
 
8433
8445
  if (!isDefined(rootLayer)) {
8434
- fail(layer, 'No Layer element in service');
8446
+ fail(this, 'No Layer element in service');
8435
8447
  return;
8436
8448
  }
8437
8449
 
@@ -8461,52 +8473,58 @@ var WMLayer = /*#__PURE__*/function () {
8461
8473
  return;
8462
8474
  }
8463
8475
 
8464
- var foundLayer = 0; // Function will be called when the layer with the right name is found in the getcap doc
8476
+ this.getmapURL = undefined;
8465
8477
 
8466
- var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8467
- _this3.getmapURL = undefined;
8478
+ try {
8479
+ this.getmapURL = capabilityObject.Request.GetMap.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8480
+ } catch (e) {
8481
+ /* Do nothing */
8482
+ }
8468
8483
 
8469
- try {
8470
- _this3.getmapURL = capabilityObject.Request.GetMap.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8471
- } catch (e) {
8472
- /* Do nothing */
8473
- }
8484
+ if (!isDefined(this.getmapURL)) {
8485
+ this.getmapURL = this.service;
8486
+ debug(DebugType.Error);
8487
+ }
8474
8488
 
8475
- if (!isDefined(_this3.getmapURL)) {
8476
- _this3.getmapURL = _this3.service;
8477
- debug(DebugType.Error);
8478
- }
8489
+ this.getfeatureinfoURL = undefined;
8479
8490
 
8480
- _this3.getfeatureinfoURL = undefined;
8491
+ try {
8492
+ this.getfeatureinfoURL = capabilityObject.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8493
+ } catch (e) {
8494
+ /* Do nothing */
8495
+ }
8481
8496
 
8482
- try {
8483
- _this3.getfeatureinfoURL = capabilityObject.Request.GetFeatureInfo.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8484
- } catch (e) {
8485
- /* Do nothing */
8486
- }
8497
+ if (!isDefined(this.getfeatureinfoURL)) {
8498
+ this.getfeatureinfoURL = this.service;
8499
+ debug(DebugType.Error);
8500
+ }
8487
8501
 
8488
- if (!isDefined(_this3.getfeatureinfoURL)) {
8489
- _this3.getfeatureinfoURL = _this3.service;
8490
- debug(DebugType.Error);
8491
- }
8502
+ this.getlegendgraphicURL = undefined;
8503
+
8504
+ try {
8505
+ this.getlegendgraphicURL = capabilityObject.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8506
+ } catch (e) {
8507
+ /* Do nothing */
8508
+ }
8492
8509
 
8493
- _this3.getlegendgraphicURL = undefined;
8510
+ if (!isDefined(this.getlegendgraphicURL)) {
8511
+ this.getlegendgraphicURL = this.service;
8512
+ } // TODO Should be arranged also for the other services:
8494
8513
 
8495
- try {
8496
- _this3.getlegendgraphicURL = capabilityObject.Request.GetLegendGraphic.DCPType.HTTP.Get.OnlineResource.attr['xlink:href'];
8497
- } catch (e) {
8498
- /* Do nothing */
8499
- }
8500
8514
 
8501
- if (!isDefined(_this3.getlegendgraphicURL)) {
8502
- _this3.getlegendgraphicURL = _this3.service;
8503
- } // TODO Should be arranged also for the other services:
8515
+ this.getmapURL = WMJScheckURL(this.getmapURL);
8516
+ this.getfeatureinfoURL = WMJScheckURL(this.getfeatureinfoURL);
8517
+ this.getlegendgraphicURL = WMJScheckURL(this.getlegendgraphicURL);
8518
+ this.styles = [];
8519
+ this.projectionProperties = [];
8520
+ /* Set default to layer name, try to find details in next steps */
8504
8521
 
8522
+ this.title = this.name;
8523
+ this["abstract"] = '';
8524
+ this.path = '';
8525
+ var foundLayer = 0; // Function will be called when the layer with the right name is found in the getcap doc
8505
8526
 
8506
- _this3.getmapURL = WMJScheckURL(layer.getmapURL);
8507
- _this3.getfeatureinfoURL = WMJScheckURL(layer.getfeatureinfoURL);
8508
- _this3.getlegendgraphicURL = WMJScheckURL(layer.getlegendgraphicURL);
8509
- _this3.getCapabilitiesDoc = jsondata;
8527
+ var foundLayerFunction = function foundLayerFunction(jsonlayer, path, nestedLayerPath) {
8510
8528
  _this3.title = jsonlayer.Title.value;
8511
8529
 
8512
8530
  try {
@@ -8516,7 +8534,6 @@ var WMLayer = /*#__PURE__*/function () {
8516
8534
  }
8517
8535
 
8518
8536
  _this3.path = path;
8519
- _this3.styles = [];
8520
8537
  /** ***************** Go through styles **************** */
8521
8538
 
8522
8539
  configureStyles(nestedLayerPath, _this3);
@@ -8529,7 +8546,6 @@ var WMLayer = /*#__PURE__*/function () {
8529
8546
  gp = toArray(jsonlayer.CRS);
8530
8547
  }
8531
8548
 
8532
- _this3.projectionProperties = [];
8533
8549
  var tempSRS = [];
8534
8550
 
8535
8551
  var getgpbbox = function getgpbbox(data) {
@@ -8537,7 +8553,7 @@ var WMLayer = /*#__PURE__*/function () {
8537
8553
  // Fill in SRS and BBOX on basis of BoundingBox attribute
8538
8554
  var gpbbox = toArray(data.BoundingBox);
8539
8555
 
8540
- for (j = 0; j < gpbbox.length; j += 1) {
8556
+ for (var j = 0; j < gpbbox.length; j += 1) {
8541
8557
  var srs = void 0;
8542
8558
  srs = gpbbox[j].attr.SRS;
8543
8559
 
@@ -8565,8 +8581,8 @@ var WMLayer = /*#__PURE__*/function () {
8565
8581
  geoProperty.srs = srs;
8566
8582
  var swapBBOX = false;
8567
8583
 
8568
- if (layer.version === WMSVersion.version130) {
8569
- if (geoProperty.srs === 'EPSG:4326' && layer.wms130bboxcompatibilitymode === false) {
8584
+ if (_this3.version === WMSVersion.version130) {
8585
+ if (geoProperty.srs === 'EPSG:4326' && _this3.wms130bboxcompatibilitymode === false) {
8570
8586
  swapBBOX = true;
8571
8587
  }
8572
8588
  }
@@ -8594,7 +8610,7 @@ var WMLayer = /*#__PURE__*/function () {
8594
8610
  getgpbbox(jsonlayer);
8595
8611
  getgpbbox(rootLayer); // Fill in SRS on basis of SRS attribute
8596
8612
 
8597
- for (j = 0; j < gp.length; j += 1) {
8613
+ for (var j = 0; j < gp.length; j += 1) {
8598
8614
  if (tempSRS.indexOf(gp[j].value) === -1) {
8599
8615
  var geoProperty = new WMProjection();
8600
8616
  debug(DebugType.Error, "Warning: BoundingBOX missing for SRS ".concat(gp[j].value));
@@ -8603,7 +8619,8 @@ var WMLayer = /*#__PURE__*/function () {
8603
8619
  geoProperty.bbox.right = 180;
8604
8620
  geoProperty.bbox.top = 90;
8605
8621
  geoProperty.srs = gp[j].value;
8606
- layer.projectionProperties.push(geoProperty);
8622
+
8623
+ _this3.projectionProperties.push(geoProperty);
8607
8624
  }
8608
8625
  }
8609
8626
 
@@ -8615,13 +8632,13 @@ var WMLayer = /*#__PURE__*/function () {
8615
8632
  try {
8616
8633
  if (parseInt(jsonlayer.attr.queryable, 10) === 1) _this3.queryable = true;else _this3.queryable = false;
8617
8634
  } catch (e) {
8618
- debug(DebugType.Error, "Unable to detect whether this layer is queryable (for layer ".concat(layer.title, ")"));
8635
+ debug(DebugType.Error, "Unable to detect whether this layer is queryable (for layer ".concat(_this3.title, ")"));
8619
8636
  }
8620
8637
 
8621
8638
  foundLayer = 1;
8622
8639
  };
8623
8640
 
8624
- function recursivelyFindLayer(JSONLayers, path, _prevNestedLayerPath) {
8641
+ function recursivelyFindLayer(thisLayer, JSONLayers, path, _prevNestedLayerPath) {
8625
8642
  for (var k = 0; k < JSONLayers.length; k += 1) {
8626
8643
  var _nestedLayerPath = [];
8627
8644
 
@@ -8640,9 +8657,9 @@ var WMLayer = /*#__PURE__*/function () {
8640
8657
  /* Do nothing */
8641
8658
  }
8642
8659
 
8643
- recursivelyFindLayer(toArray(JSONLayers[k].Layer), pathnew, _nestedLayerPath);
8660
+ recursivelyFindLayer(thisLayer, toArray(JSONLayers[k].Layer), pathnew, _nestedLayerPath);
8644
8661
  } else if (JSONLayers[k].Name) {
8645
- if (JSONLayers[k].Name.value === layer.name) {
8662
+ if (JSONLayers[k].Name.value === thisLayer.name) {
8646
8663
  foundLayerFunction(JSONLayers[k], path, _nestedLayerPath);
8647
8664
  return;
8648
8665
  }
@@ -8654,13 +8671,13 @@ var WMLayer = /*#__PURE__*/function () {
8654
8671
  var JSONLayers = toArray(rootLayer.Layer);
8655
8672
  var path = '';
8656
8673
  var nestedLayerPath = [rootLayer];
8657
- recursivelyFindLayer(JSONLayers, path, nestedLayerPath);
8674
+ recursivelyFindLayer(this, JSONLayers, path, nestedLayerPath);
8658
8675
 
8659
8676
  if (foundLayer === 0) {
8660
8677
  // Layer was not found...
8661
8678
  var message = '';
8662
8679
 
8663
- if (layer.name) {
8680
+ if (this.name) {
8664
8681
  message = "Unable to find layer '".concat(this.name, "' in service '").concat(this.service, "'");
8665
8682
  } else {
8666
8683
  message = "Unable to find layer '".concat(this.title, "' in service '").concat(this.service, "'");
@@ -8689,7 +8706,8 @@ var WMLayer = /*#__PURE__*/function () {
8689
8706
 
8690
8707
  }, {
8691
8708
  key: "parseLayer",
8692
- value: function parseLayer(_layerDoneCallback, forceReload, xml2jsonrequest) {
8709
+ value: function parseLayer(_layerDoneCallback, forceReload, // eslint-disable-next-line no-unused-vars
8710
+ origin) {
8693
8711
  var _this4 = this;
8694
8712
 
8695
8713
  this.hasError = false;
@@ -8697,7 +8715,10 @@ var WMLayer = /*#__PURE__*/function () {
8697
8715
  var layerDoneCallback = function layerDoneCallback(__layer) {
8698
8716
  if (isDefined(_layerDoneCallback)) {
8699
8717
  try {
8700
- _layerDoneCallback(__layer);
8718
+ /* Enable these two console timings to do performance measurments of parseLayer */
8719
+ // console.time(origin);
8720
+ _layerDoneCallback(__layer); // console.timeEnd(origin);
8721
+
8701
8722
  } catch (e) {
8702
8723
  debug(DebugType.Error);
8703
8724
  }
@@ -8716,20 +8737,13 @@ var WMLayer = /*#__PURE__*/function () {
8716
8737
  };
8717
8738
 
8718
8739
  var callback = function callback(data) {
8719
- _this4.__parseGetCapForLayer(_this4, data, layerDoneCallback, fail);
8740
+ _this4.__parseGetCapForLayer(data, layerDoneCallback, fail);
8720
8741
  };
8721
8742
 
8722
8743
  var requestfail = function requestfail() {
8723
8744
  fail(_this4, I18n.no_capability_element_found.text);
8724
8745
  };
8725
8746
 
8726
- var newXml2jsonrequest = xml2jsonrequest;
8727
-
8728
- if (!xml2jsonrequest) {
8729
- newXml2jsonrequest = this.parentMaps && this.parentMaps.length > 0 ? this.parentMaps[0].xml2jsonrequest : undefined;
8730
- }
8731
-
8732
- this.WMJSService = WMGetServiceFromStore(this.service, newXml2jsonrequest);
8733
8747
  var options = {
8734
8748
  headers: {}
8735
8749
  };
@@ -8738,10 +8752,12 @@ var WMLayer = /*#__PURE__*/function () {
8738
8752
  options.headers = this.headers;
8739
8753
  }
8740
8754
 
8741
- if (this.WMJSService.service !== undefined) {
8742
- this.WMJSService.getCapabilities(function (data) {
8755
+ var wmjsService = WMGetServiceFromStore(this.service);
8756
+
8757
+ if (wmjsService.service !== undefined) {
8758
+ wmjsService.getCapabilities(function (data) {
8743
8759
  callback(data);
8744
- }, requestfail, forceReload, xml2jsonrequest, options);
8760
+ }, requestfail, forceReload, options);
8745
8761
  }
8746
8762
  }
8747
8763
  /**
@@ -8764,7 +8780,7 @@ var WMLayer = /*#__PURE__*/function () {
8764
8780
  } else {
8765
8781
  resolve(layer);
8766
8782
  }
8767
- }, forceReload);
8783
+ }, forceReload, 'WMLayer parseLayerPromise');
8768
8784
  });
8769
8785
  }
8770
8786
  }, {
@@ -8817,7 +8833,8 @@ var WMLayer = /*#__PURE__*/function () {
8817
8833
  success(layerObjects[currentLayerIndex], currentLayerIndex, layerObjects.length);
8818
8834
  };
8819
8835
 
8820
- this.WMJSService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8836
+ var wmjsService = WMGetServiceFromStore(this.service);
8837
+ wmjsService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8821
8838
  }
8822
8839
  }, {
8823
8840
  key: "autoSelectLayer",
@@ -8835,7 +8852,8 @@ var WMLayer = /*#__PURE__*/function () {
8835
8852
  }
8836
8853
  };
8837
8854
 
8838
- this.WMJSService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8855
+ var wmjsService = WMGetServiceFromStore(this.service);
8856
+ wmjsService.getLayerObjectsFlat(getLayerObjectsFinished, failure, undefined);
8839
8857
  }
8840
8858
  }, {
8841
8859
  key: "getNextLayer",
@@ -9011,8 +9029,8 @@ var WMLayer = /*#__PURE__*/function () {
9011
9029
  value: function display(displayornot) {
9012
9030
  this.enabled = displayornot;
9013
9031
 
9014
- for (var j = 0; j < this.parentMaps.length; j += 1) {
9015
- this.parentMaps[j].displayLayer(this, this.enabled);
9032
+ if (this.parentMap) {
9033
+ this.parentMap.displayLayer(this, this.enabled);
9016
9034
  }
9017
9035
  }
9018
9036
  }]);