@eeacms/volto-arcgis-block 0.1.74 → 0.1.75

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,29 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [0.1.75](https://github.com/eea/volto-arcgis-block/compare/0.1.74...0.1.75) - 22 November 2022
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat: show zoom in message for snow and ice product when zoom level is below 7 - CLMS-1528 [joewdavies - [`7ac9d04`](https://github.com/eea/volto-arcgis-block/commit/7ac9d04ab96b44b22ea8520e7c8677e286df525e)]
12
+ - feat: show zoom in message for snow and ice product when zoom level is below 7 - CLMS-1528 [joewdavies - [`e803695`](https://github.com/eea/volto-arcgis-block/commit/e803695e46fba76a48186ebdf25c7a74f02e3a08)]
13
+ - feat: show zoom in message for snow and ice product when zoom level is below 7 - CLMS-1528 [joewdavies - [`1734f89`](https://github.com/eea/volto-arcgis-block/commit/1734f89ee8bc16dc1bc18d5d76b3131b044796c5)]
14
+ - feat: show zoom in message for snow and ice product when zoom level is below 7 - CLMS-1528 [joewdavies - [`5f12f70`](https://github.com/eea/volto-arcgis-block/commit/5f12f702061b34421302d6037a87e131c19f3b56)]
15
+ - feat: show zoom in message for snow and ice product when zoom level is below 7 - CLMS-1528 [joewdavies - [`d6e4dea`](https://github.com/eea/volto-arcgis-block/commit/d6e4dea9b5030217ca5faad8c33959e65b9d179b)]
16
+ - feat: load TMS layers JSON asynchronosly [joewdavies - [`a36ac9b`](https://github.com/eea/volto-arcgis-block/commit/a36ac9b99deaa1b5ed344fd869589ea0f053aabb)]
17
+
18
+ #### :hammer_and_wrench: Others
19
+
20
+ - prettier fix [joewdavies - [`3855674`](https://github.com/eea/volto-arcgis-block/commit/3855674ce363b58387dc818bf4a86ce50ff7ee38)]
21
+ - prettier fix [joewdavies - [`a900320`](https://github.com/eea/volto-arcgis-block/commit/a9003201ed25be8636c59ca5e075e98f15086b7d)]
22
+ - prettier fix [joewdavies - [`8b4f2d2`](https://github.com/eea/volto-arcgis-block/commit/8b4f2d24815d96c3be14a2455a6a2af844aa16ba)]
23
+ - prettier fix [joewdavies - [`d578f5a`](https://github.com/eea/volto-arcgis-block/commit/d578f5a6fbc54ed3cf24ae2fe9c439daa3b82961)]
24
+ - add default TMS layer if none specified [joewdavies - [`ffbdc0e`](https://github.com/eea/volto-arcgis-block/commit/ffbdc0e4d1e27d0fd886200a9bba29cc5763698c)]
25
+ - ESLint fix [joewdavies - [`a22c35f`](https://github.com/eea/volto-arcgis-block/commit/a22c35f4568c69b654dc414c61b80257d6932430)]
26
+ - attempt to get TMS layer to work with legend widget [joewdavies - [`4271bdd`](https://github.com/eea/volto-arcgis-block/commit/4271bddff97667c7f1a466b53df568b7cb3a3a14)]
27
+ - remove TMS layer correctly [joewdavies - [`9fb63f1`](https://github.com/eea/volto-arcgis-block/commit/9fb63f1983f82fe9452a9830eff640bc136f7137)]
28
+ - remove superfluous logs [joewdavies - [`9b0717b`](https://github.com/eea/volto-arcgis-block/commit/9b0717bed39113b448e10c9ad4e1fecf2d83bb09)]
29
+ - TMS json progress [joewdavies - [`f24c7c7`](https://github.com/eea/volto-arcgis-block/commit/f24c7c7da483221c15a705bf6972075e1f9bc7a6)]
7
30
  ### [0.1.74](https://github.com/eea/volto-arcgis-block/compare/0.1.73...0.1.74) - 27 October 2022
8
31
 
9
32
  ### [0.1.73](https://github.com/eea/volto-arcgis-block/compare/0.1.72...0.1.73) - 26 October 2022
@@ -201,13 +224,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
201
224
  #### :hammer_and_wrench: Others
202
225
 
203
226
  - Merge pull request #148 from eea/develop [KCarpinteroBM - [`24266fb`](https://github.com/eea/volto-arcgis-block/commit/24266fb3a0c1662d22ae0529dc1d5a25c711cf97)]
204
- - Revert "[JENKINS] Use eeacms/plone-backend and Volto alpha version- Refs #151967" [Mikel Larreategi - [`f751f69`](https://github.com/eea/volto-arcgis-block/commit/f751f69f652f0340ae55af6a4dab89d6bdc80906)]
205
227
  - Revert "Revert "Mapviewer menu and map viewer options persistence"" [Mikel Larreategi - [`ad6e440`](https://github.com/eea/volto-arcgis-block/commit/ad6e440cdc160cffb1e86e1b26e501dbe648476c)]
206
228
  - Revert "code coverage removal" [Mikel Larreategi - [`376f2d1`](https://github.com/eea/volto-arcgis-block/commit/376f2d1cd6e4e5110b3b63d5114af1bcfebe094b)]
207
229
  - Revert "Update cypress.json" [Mikel Larreategi - [`43d01a0`](https://github.com/eea/volto-arcgis-block/commit/43d01a0a95a58ef5215c6cbf18223ca30a11b9cc)]
208
230
  - Revert "Update cypress.json" [Mikel Larreategi - [`054c4ae`](https://github.com/eea/volto-arcgis-block/commit/054c4ae1767e1f26e6ec7e96a0e26a9711f29f04)]
209
- - Revert "revert [JENKINS] Use eeacms/plone-backend and Volto alpha version- Refs #151967" [Mikel Larreategi - [`64ab56e`](https://github.com/eea/volto-arcgis-block/commit/64ab56e0f1f8dddc26f26039509a028e34653e64)]
210
- - revert [JENKINS] Use eeacms/plone-backend and Volto alpha version- Refs #151967 [Mikel Larreategi - [`85ee194`](https://github.com/eea/volto-arcgis-block/commit/85ee1941e029df2b7dc910bf75231c75ffeca8c2)]
211
231
  - Update cypress.json [KCarpinteroBM - [`be285ff`](https://github.com/eea/volto-arcgis-block/commit/be285fff0c53e06a0180d5318cce81195eabcf80)]
212
232
  - Update cypress.json [KCarpinteroBM - [`a7f2118`](https://github.com/eea/volto-arcgis-block/commit/a7f2118acb7b048b4cef85aa9663c2244a1c9ca0)]
213
233
  - linting fix [KCarpinteroBM - [`27e969a`](https://github.com/eea/volto-arcgis-block/commit/27e969a7a411fd4646e0e742ce846efc0d79703e)]
@@ -267,7 +287,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
267
287
  - UX improvements [rodriama - [`151dc4b`](https://github.com/eea/volto-arcgis-block/commit/151dc4b02d0a73fdd66de9d594620ac0fa5f1dbf)]
268
288
  - deleted failing tests [KCarpinteroBM - [`ddaa9e6`](https://github.com/eea/volto-arcgis-block/commit/ddaa9e6f06db6960a4c214d3be2420c48b26715d)]
269
289
  - cleaning unnecessary files [KCarpinteroBM - [`2c02199`](https://github.com/eea/volto-arcgis-block/commit/2c021990912beb02b603a1de89aecd62e0063769)]
270
- - Reverting to Automated release 0.1.39 [KCarpinteroBM - [`fb9f317`](https://github.com/eea/volto-arcgis-block/commit/fb9f3176ccdea18fceb329eaac13ced0566ee648)]
271
290
  - commands added [KCarpinteroBM - [`049e60b`](https://github.com/eea/volto-arcgis-block/commit/049e60b7d124d1c05abd0b2775b510795f4ed59f)]
272
291
  - Mapviewer testing implementation [KCarpinteroBM - [`0103002`](https://github.com/eea/volto-arcgis-block/commit/0103002869eea108e16e3b5ff2e77a725dcc7c4b)]
273
292
  ### [0.1.39](https://github.com/eea/volto-arcgis-block/compare/0.1.38...0.1.39) - 24 March 2022
@@ -287,7 +306,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
287
306
  - ESLint fix [rodriama - [`75dae9b`](https://github.com/eea/volto-arcgis-block/commit/75dae9b5bba18ab6d9624f6c99714b4bd2179003)]
288
307
  - Remove section title [rodriama - [`ece860e`](https://github.com/eea/volto-arcgis-block/commit/ece860eae3519c7e611abac16e8d53c9a9408b34)]
289
308
  - Es-Lint [manuelmartinezbilbomatica - [`39d8d11`](https://github.com/eea/volto-arcgis-block/commit/39d8d11b9096fd603df8510c119d2e12817415d6)]
290
- - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`bf9f683`](https://github.com/eea/volto-arcgis-block/commit/bf9f683dd35a9edb4cfd9111affcb8f8edbeae89)]
291
309
  - FEAT: Parser Time implemented [manuelmartinezbilbomatica - [`689c99e`](https://github.com/eea/volto-arcgis-block/commit/689c99e55221fee6c7c7fafc4ab95ae7a646d3dd)]
292
310
  ### [0.1.38](https://github.com/eea/volto-arcgis-block/compare/0.1.37...0.1.38) - 18 March 2022
293
311
 
@@ -382,7 +400,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
382
400
  - ESLint fix [rodriama - [`5fd3772`](https://github.com/eea/volto-arcgis-block/commit/5fd3772f197a3a380067962a5638dbf901a4624e)]
383
401
  - Pixel info [rodriama - [`1ccef39`](https://github.com/eea/volto-arcgis-block/commit/1ccef39a9adcc3ee94655c77a5a166b613600a08)]
384
402
  - NUTS bug fix [rodriama - [`37fe7f3`](https://github.com/eea/volto-arcgis-block/commit/37fe7f3fad2c005e3b7c234b3b0564d5df92fa8c)]
385
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`ea5af8b`](https://github.com/eea/volto-arcgis-block/commit/ea5af8b02a5f2ee25b9b0be67cf3792bbbe84ed7)]
386
403
  ### [0.1.23](https://github.com/eea/volto-arcgis-block/compare/0.1.22...0.1.23) - 17 December 2021
387
404
 
388
405
  #### :hammer_and_wrench: Others
@@ -627,7 +644,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
627
644
  - Trying to delay ArcGIS modules load [gonzalezsd - [`ff16985`](https://github.com/eea/volto-arcgis-block/commit/ff169858e42d30bfcacc423ffc27762bb9ef05a4)]
628
645
  - Run bootstrap to fix files [valentinab25 - [`236893f`](https://github.com/eea/volto-arcgis-block/commit/236893f03314eb638b7667f81b1f91491a98ee17)]
629
646
  - fix git_name [valentinab25 - [`c7806c3`](https://github.com/eea/volto-arcgis-block/commit/c7806c312964425dc23e5d4c6973de8b81ddaeac)]
630
- - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`e3afb51`](https://github.com/eea/volto-arcgis-block/commit/e3afb515dda459ee03e2b5d4b56465d2d4ad1503)]
631
647
  - Trying to change imports [gonzalezsd - [`d83d7e2`](https://github.com/eea/volto-arcgis-block/commit/d83d7e2f68da4b2a284735847f93c0763a7e13b6)]
632
648
  - default design [bipoza - [`88fbe0b`](https://github.com/eea/volto-arcgis-block/commit/88fbe0b2bc73e732e2993324a567f53902e85506)]
633
649
  - cleanup of unused code [bipoza - [`b167677`](https://github.com/eea/volto-arcgis-block/commit/b1676771f637f056cad50cb0bc186f2ea79e8517)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.74",
3
+ "version": "0.1.75",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -297,11 +297,14 @@ class InfoWidget extends React.Component {
297
297
  break;
298
298
  case 'featureLayer':
299
299
  if (data.results.length) {
300
- var graphic = data.results.filter((result) => {
300
+ var graphics = data.results.filter((result) => {
301
301
  return result.graphic.layer === layers[index];
302
- })[0].graphic;
303
- if (graphic) {
304
- properties = graphic.attributes;
302
+ });
303
+ if (graphics[0]) {
304
+ let graphic = graphics[0].graphic;
305
+ if (graphic) {
306
+ properties = graphic.attributes;
307
+ }
305
308
  }
306
309
  }
307
310
  this.infoData[index] = {
@@ -9,7 +9,7 @@ import TimesliderWidget from './TimesliderWidget';
9
9
  import { Toast } from '@plone/volto/components';
10
10
  import { toast } from 'react-toastify';
11
11
  import { UniversalLink } from '@plone/volto/components';
12
- var WMSLayer, WMTSLayer, FeatureLayer;
12
+ var WMSLayer, WMTSLayer, FeatureLayer, BaseTileLayer, esriRequest;
13
13
 
14
14
  const popupSettings = {
15
15
  basic: true,
@@ -412,16 +412,28 @@ class MenuWidget extends React.Component {
412
412
  this.container = createRef();
413
413
  //Initially, we set the state of the component to
414
414
  //not be showing the basemap panel
415
- this.state = { showMapMenu: false };
415
+ this.state = { showMapMenu: false, tms_jsx: null };
416
416
  // call the props of the layers list (mapviewer.jsx)
417
417
  this.compCfg = this.props.conf;
418
418
  this.map = this.props.map;
419
+ this.view = this.props.view;
419
420
  this.menuClass =
420
421
  'esri-icon-drag-horizontal esri-widget--button esri-widget esri-interactive';
421
422
  this.loadFirst = true;
422
423
  this.layers = {};
423
424
  this.activeLayersJSON = {};
424
425
  this.layerGroups = {};
426
+
427
+ // add zoomend listener to map to show/hide zoom in message
428
+ this.view.watch('stationary', (isStationary) => {
429
+ if (isStationary) {
430
+ let node = document.getElementById('snow-and-ice-zoom-message');
431
+ if (node) {
432
+ let zoom = this.view.get('zoom');
433
+ node.style.display = zoom > 6 ? 'none' : 'block';
434
+ }
435
+ }
436
+ });
425
437
  }
426
438
 
427
439
  loader() {
@@ -429,11 +441,53 @@ class MenuWidget extends React.Component {
429
441
  'esri/layers/WMSLayer',
430
442
  'esri/layers/WMTSLayer',
431
443
  'esri/layers/FeatureLayer',
432
- ]).then(([_WMSLayer, _WMTSLayer, _FeatureLayer]) => {
433
- WMSLayer = _WMSLayer;
434
- WMTSLayer = _WMTSLayer;
435
- FeatureLayer = _FeatureLayer;
444
+ 'esri/layers/BaseTileLayer',
445
+ 'esri/request',
446
+ ]).then(
447
+ ([
448
+ _WMSLayer,
449
+ _WMTSLayer,
450
+ _FeatureLayer,
451
+ _BaseTileLayer,
452
+ _esriRequest,
453
+ ]) => {
454
+ WMSLayer = _WMSLayer;
455
+ WMTSLayer = _WMTSLayer;
456
+ FeatureLayer = _FeatureLayer;
457
+ BaseTileLayer = _BaseTileLayer;
458
+ esriRequest = _esriRequest;
459
+ },
460
+ );
461
+ }
462
+
463
+ // get custom TMS layer JSON
464
+ getTMSLayersJSON() {
465
+ let promises = []; // download JSON file calls
466
+ this.compCfg.forEach((component) => {
467
+ component.Products.forEach((product) => {
468
+ product.Datasets.forEach((dataset) => {
469
+ if (dataset.ViewService.endsWith('file')) {
470
+ let promise = fetch(dataset.ViewService, { mode: 'no-cors' })
471
+ .then((response) => {
472
+ if (!response.ok) {
473
+ throw new Error(`HTTP error, status = ${response.status}`);
474
+ }
475
+ return response.json();
476
+ })
477
+ .then((data) => {
478
+ // fill dataset.Layer manually
479
+ dataset.Layer = data.Layers;
480
+ })
481
+ .catch((error) => {
482
+ throw new Error(error);
483
+ });
484
+ promises.push(promise);
485
+ }
486
+ });
487
+ });
436
488
  });
489
+
490
+ return Promise.all(promises);
437
491
  }
438
492
 
439
493
  /**
@@ -505,11 +559,12 @@ class MenuWidget extends React.Component {
505
559
  }
506
560
 
507
561
  /**
508
- * This method is executed after the rener method is executed
562
+ * This method is executed after the render method is executed
509
563
  */
510
564
  async componentDidMount() {
511
565
  loadCss();
512
566
  await this.loader();
567
+ await this.getTMSLayersJSON();
513
568
  this.props.view.ui.add(this.container.current, 'top-left');
514
569
  if (this.props.download) {
515
570
  document.querySelector('.area-panel input:checked').click();
@@ -802,12 +857,38 @@ class MenuWidget extends React.Component {
802
857
  <legend className="ccl-form-legend">
803
858
  {description ? (
804
859
  <Popup
805
- trigger={<span>{product.ProductTitle}</span>}
860
+ trigger={
861
+ product.ProductId ===
862
+ '8474c3b080fa42cc837f1d2338fcf096' ||
863
+ product.ProductTitle === 'Snow and Ice Parameters' ? (
864
+ <div class="zoom-in-message-container">
865
+ <span>{product.ProductTitle}</span>
866
+ <div
867
+ class="zoom-in-message"
868
+ id="snow-and-ice-zoom-message"
869
+ >
870
+ Zoom in to view on map
871
+ </div>
872
+ </div>
873
+ ) : (
874
+ <span>{product.ProductTitle}</span>
875
+ )
876
+ }
806
877
  content={description}
807
878
  basic
808
879
  className="custom"
809
880
  style={{ transform: 'translateX(-4rem)' }}
810
881
  />
882
+ ) : product.ProductId ===
883
+ '8474c3b080fa42cc837f1d2338fcf096' ||
884
+ product.ProductTitle ===
885
+ 'High Resolution Snow and Ice Parameters' ? (
886
+ <div class="zoom-in-message-container">
887
+ <span>{product.ProductTitle}</span>
888
+ <div class="zoom-in-message">
889
+ Zoom in to view on map
890
+ </div>
891
+ </div>
811
892
  ) : (
812
893
  <span>{product.ProductTitle}</span>
813
894
  )}
@@ -860,32 +941,93 @@ class MenuWidget extends React.Component {
860
941
  ? dataset.DatasetDescription.substr(0, 300) + '...'
861
942
  : dataset.DatasetDescription;
862
943
 
944
+ let style = this.props.download
945
+ ? { paddingLeft: dataset.HandlingLevel ? '0' : '1rem' }
946
+ : {};
947
+
863
948
  if (dataset.HandlingLevel) {
864
949
  this.layerGroups[dataset.DatasetId] = [];
865
950
  }
866
- for (var i in dataset.Layer) {
867
- if (dataset.Layer[i].Default_active === true) {
868
- layer_default.push(
869
- dataset.Layer[i].LayerId + '_' + inheritedIndexDataset + '_' + i,
951
+
952
+ // TMS
953
+ if (dataset.ViewService.endsWith('file')) {
954
+ let tmsLayerIndex = 0;
955
+
956
+ dataset.Layer.forEach((layer, sublayerIndex) => {
957
+ if (!layer.LayerId) {
958
+ layer.LayerId = sublayerIndex;
959
+ }
960
+ let inheritedIndexLayer = inheritedIndex + '_' + tmsLayerIndex;
961
+ let checkboxId = layer.LayerId + '_' + inheritedIndexLayer;
962
+
963
+ // add as default
964
+ if (!layer_default.length) {
965
+ layer_default.push(checkboxId);
966
+ }
967
+ // add each sublayer to this.layers
968
+ this.processTMSLayer(layer, checkboxId, dataset);
969
+
970
+ // build TMS DOM nodes for TOC
971
+ layers.push(
972
+ <div
973
+ className="ccl-form-group map-menu-layer"
974
+ id={'layer_' + inheritedIndexLayer}
975
+ key={'a' + tmsLayerIndex}
976
+ data-timeseries={dataset.IsTimeSeries}
977
+ style={style}
978
+ >
979
+ <input
980
+ type="checkbox"
981
+ id={checkboxId}
982
+ parentid={checkIndex}
983
+ layerid={layer.LayerId}
984
+ name="layerCheckbox"
985
+ value="name"
986
+ className="ccl-checkbox ccl-required ccl-form-check-input"
987
+ key={'c' + tmsLayerIndex}
988
+ title={layer.Title}
989
+ onChange={(e) => {
990
+ this.toggleLayer(e.target);
991
+ }}
992
+ ></input>
993
+ <label
994
+ className="ccl-form-check-label"
995
+ htmlFor={layer.LayerId + '_' + inheritedIndexLayer}
996
+ key={'d' + tmsLayerIndex}
997
+ >
998
+ <span>{layer.Title}</span>
999
+ </label>
1000
+ </div>,
870
1001
  );
1002
+ tmsLayerIndex++;
1003
+ });
1004
+ } else {
1005
+ for (var i in dataset.Layer) {
1006
+ if (dataset.Layer[i].Default_active === true) {
1007
+ layer_default.push(
1008
+ dataset.Layer[i].LayerId + '_' + inheritedIndexDataset + '_' + i,
1009
+ );
1010
+ }
1011
+ if (dataset.HandlingLevel) {
1012
+ this.layerGroups[dataset.DatasetId].push(dataset.Layer[i].LayerId);
1013
+ }
1014
+
1015
+ layers.push(
1016
+ this.metodProcessLayer(
1017
+ dataset.Layer[i],
1018
+ index,
1019
+ inheritedIndexDataset,
1020
+ dataset.ViewService,
1021
+ dataset.TimeSeriesService,
1022
+ checkIndex,
1023
+ dataset.IsTimeSeries,
1024
+ dataset.DatasetId,
1025
+ dataset.DatasetTitle,
1026
+ dataset.ProductId,
1027
+ ),
1028
+ );
1029
+ index++;
871
1030
  }
872
- if (dataset.HandlingLevel) {
873
- this.layerGroups[dataset.DatasetId].push(dataset.Layer[i].LayerId);
874
- }
875
- layers.push(
876
- this.metodProcessLayer(
877
- dataset.Layer[i],
878
- index,
879
- inheritedIndexDataset,
880
- dataset.ViewService,
881
- dataset.TimeSeriesService,
882
- checkIndex,
883
- dataset.IsTimeSeries,
884
- layer_default,
885
- dataset.HandlingLevel,
886
- ),
887
- );
888
- index++;
889
1031
  }
890
1032
 
891
1033
  if (!layer_default.length) {
@@ -893,9 +1035,6 @@ class MenuWidget extends React.Component {
893
1035
  dataset.Layer[0].LayerId + '_' + inheritedIndexDataset + '_0',
894
1036
  );
895
1037
  }
896
- let style = this.props.download
897
- ? { paddingLeft: dataset.HandlingLevel ? '0' : '1rem' }
898
- : {};
899
1038
 
900
1039
  return (
901
1040
  <div
@@ -1048,28 +1187,32 @@ class MenuWidget extends React.Component {
1048
1187
  layer,
1049
1188
  layerIndex,
1050
1189
  inheritedIndex,
1051
- urlWMS,
1190
+ viewService,
1052
1191
  featureInfoUrl,
1053
1192
  parentIndex,
1054
1193
  isTimeSeries,
1055
- layer_default,
1056
- handlingLevel,
1194
+ DatasetId,
1195
+ DatasetTitle,
1196
+ ProductId,
1057
1197
  ) {
1058
1198
  //For Legend request
1059
1199
  const legendRequest =
1060
1200
  'request=GetLegendGraphic&version=1.0.0&format=image/png&layer=';
1061
1201
  //For each layer
1062
- var inheritedIndexLayer = inheritedIndex + '_' + layerIndex;
1202
+ let inheritedIndexLayer = inheritedIndex + '_' + layerIndex;
1203
+ let style = this.props.download ? { paddingLeft: '4rem' } : {};
1063
1204
  //Add sublayers and popup enabled for layers
1064
1205
  if (
1065
1206
  !this.layers.hasOwnProperty(layer.LayerId + '_' + inheritedIndexLayer)
1066
1207
  ) {
1067
- if (urlWMS.toLowerCase().includes('wms')) {
1068
- urlWMS = urlWMS.endsWith('?') ? urlWMS : urlWMS + '?';
1208
+ if (viewService.toLowerCase().includes('wms')) {
1209
+ viewService = viewService.endsWith('?')
1210
+ ? viewService
1211
+ : viewService + '?';
1069
1212
  this.layers[layer.LayerId + '_' + inheritedIndexLayer] = new WMSLayer({
1070
- url: urlWMS,
1213
+ url: viewService,
1071
1214
  featureInfoFormat: 'text/html',
1072
- featureInfoUrl: urlWMS,
1215
+ featureInfoUrl: viewService,
1073
1216
  //id: layer.LayerId,
1074
1217
  title: '',
1075
1218
  legendEnabled: true,
@@ -1083,16 +1226,19 @@ class MenuWidget extends React.Component {
1083
1226
  legendEnabled: true,
1084
1227
  legendUrl: layer.StaticImageLegend
1085
1228
  ? layer.StaticImageLegend
1086
- : urlWMS + legendRequest + layer.LayerId,
1229
+ : viewService + legendRequest + layer.LayerId,
1087
1230
  featureInfoUrl: featureInfoUrl,
1088
1231
  },
1089
1232
  ],
1090
1233
  isTimeSeries: isTimeSeries,
1091
1234
  fields: layer.Fields,
1235
+ DatasetId: DatasetId,
1236
+ DatasetTitle: DatasetTitle,
1237
+ ProductId: ProductId,
1092
1238
  });
1093
- } else if (urlWMS.toLowerCase().includes('wmts')) {
1239
+ } else if (viewService.toLowerCase().includes('wmts')) {
1094
1240
  this.layers[layer.LayerId + '_' + inheritedIndexLayer] = new WMTSLayer({
1095
- url: urlWMS.endsWith('?') ? urlWMS : urlWMS + '?',
1241
+ url: viewService.endsWith('?') ? viewService : viewService + '?',
1096
1242
  //id: layer.LayerId,
1097
1243
  title: '',
1098
1244
  _wmtsTitle: layer.Title, // CLMS-1105
@@ -1103,22 +1249,31 @@ class MenuWidget extends React.Component {
1103
1249
  },
1104
1250
  isTimeSeries: isTimeSeries,
1105
1251
  fields: layer.Fields,
1252
+ DatasetId: DatasetId,
1253
+ DatasetTitle: DatasetTitle,
1254
+ ProductId: ProductId,
1106
1255
  });
1107
1256
  } else {
1108
1257
  this.layers[
1109
1258
  layer.LayerId + '_' + inheritedIndexLayer
1110
1259
  ] = new FeatureLayer({
1111
- url: urlWMS + (urlWMS.endsWith('/') ? '' : '/') + layer.LayerId,
1260
+ url:
1261
+ viewService +
1262
+ (viewService.endsWith('/') ? '' : '/') +
1263
+ layer.LayerId,
1112
1264
  id: layer.LayerId,
1113
1265
  title: layer.Title,
1114
1266
  featureInfoUrl: featureInfoUrl,
1115
1267
  popupEnabled: true,
1116
1268
  isTimeSeries: isTimeSeries,
1117
1269
  fields: layer.Fields,
1270
+ DatasetId: DatasetId,
1271
+ DatasetTitle: DatasetTitle,
1272
+ ProductId: ProductId,
1118
1273
  });
1119
1274
  }
1120
1275
  }
1121
- let style = this.props.download ? { paddingLeft: '4rem' } : {};
1276
+
1122
1277
  return (
1123
1278
  <div
1124
1279
  className="ccl-form-group map-menu-layer"
@@ -1152,6 +1307,97 @@ class MenuWidget extends React.Component {
1152
1307
  );
1153
1308
  }
1154
1309
 
1310
+ /**
1311
+ * adds a custom TMS layer to this.layers array
1312
+ * @param {*} checkboxId Is the layers checkbox ID
1313
+ */
1314
+ processTMSLayer(layer, checkboxId, dataset) {
1315
+ const CustomTileLayer = BaseTileLayer.createSubclass({
1316
+ properties: {
1317
+ urlTemplate: null,
1318
+ tms: false,
1319
+ tint: {
1320
+ value: null,
1321
+ },
1322
+ },
1323
+
1324
+ // generate the tile url for a given level, row and column
1325
+ getTileUrl: function (level, row, col) {
1326
+ // si es cero será el maximo. las filas serán el array invertido
1327
+ // tengo que extrarer de alguna manera la cantidad de filas y columnas que se muestran.
1328
+
1329
+ return this.urlTemplate
1330
+ .replace('{z}', level)
1331
+ .replace('{x}', col)
1332
+ .replace('{y}', row);
1333
+ },
1334
+
1335
+ // This method fetches tiles for the specified level and size.
1336
+ // Override this method to process the data returned from the server.
1337
+ fetchTile: function (level, row, col, options) {
1338
+ // call getTileUrl() method to construct the URL to tiles
1339
+ // for a given level, row and col provided by the LayerView
1340
+
1341
+ // Images pyramid formula
1342
+ if (this.tms) {
1343
+ var rowmax = 1 << level; // LEVEL 1 * (2 ** 1) = 1 * (2) = 2 ; LEVEL 2 * (2 ** 2) = 1 * (4) = 4 ; LEVEL 3 * (2 ** 3) = 1 * (8) = 8 . . .
1344
+ row = rowmax - row - 1; // Invert Y axis
1345
+ }
1346
+
1347
+ const url = this.getTileUrl(level, row, col);
1348
+
1349
+ // request for tiles based on the generated url
1350
+ // the signal option ensures that obsolete requests are aborted
1351
+ return esriRequest(url, {
1352
+ responseType: 'image',
1353
+ signal: options && options.signal,
1354
+ }).then(
1355
+ function (response) {
1356
+ // when esri request resolves successfully
1357
+ // get the image from the response
1358
+ const image = response.data;
1359
+ const width = this.tileInfo.size[0];
1360
+ const height = this.tileInfo.size[0];
1361
+ // create a canvas with 2D rendering context
1362
+ const canvas = document.createElement('canvas');
1363
+ const context = canvas.getContext('2d');
1364
+ //canvas
1365
+ canvas.width = width;
1366
+ canvas.height = height;
1367
+
1368
+ // Draw the blended image onto the canvas.
1369
+ context.drawImage(image, 0, 0, width, height);
1370
+
1371
+ return canvas;
1372
+ }.bind(this),
1373
+ );
1374
+ },
1375
+ });
1376
+ // *******************************************************
1377
+ // end of Custom tile layer class code
1378
+ // *******************************************************
1379
+ this.layers[checkboxId] = new CustomTileLayer({
1380
+ id: checkboxId,
1381
+ tms: true, // True establishes Y axis from the south northwards. False establishes tile origin top left and Y from north southwards (Default False)
1382
+ urlTemplate: layer.LayerUrl,
1383
+ // TMS Service.
1384
+ // 'https://s3-eu-west-1.amazonaws.com/vito-lcv/global/2019/cog-full_l0-colored-full/{z}/{x}/{y}.png',
1385
+ // Google/ESRI/OSM tiling style services
1386
+ // "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
1387
+ // "https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}",
1388
+ // "https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg",
1389
+ spatialReference: {
1390
+ wkid: 3857,
1391
+ },
1392
+ title: layer.Title,
1393
+ LayerTitle: layer.Title,
1394
+ DatasetTitle: dataset.DatasetTitle,
1395
+ url: layer.LayerUrl,
1396
+ legendEnabled: true,
1397
+ legendUrl: layer.StaticImageLegend,
1398
+ });
1399
+ }
1400
+
1155
1401
  /**
1156
1402
  * Method to show/hide a layer. Update checkboxes from dataset and products
1157
1403
  * @param {*} elem Is the checkbox
@@ -1195,6 +1441,8 @@ class MenuWidget extends React.Component {
1195
1441
  } else {
1196
1442
  this.deleteCheckedLayer(elem.id);
1197
1443
  this.layers[elem.id].opacity = 1;
1444
+ let mapLayer = this.map.findLayerById(elem.id);
1445
+ if (mapLayer) mapLayer.destroy();
1198
1446
  this.map.remove(this.layers[elem.id]);
1199
1447
  delete this.activeLayersJSON[elem.id];
1200
1448
  delete this.visibleLayers[elem.id];
@@ -1282,6 +1530,7 @@ class MenuWidget extends React.Component {
1282
1530
  } else {
1283
1531
  datasetChecks = document.querySelectorAll(`[parentid=${id}]`);
1284
1532
  }
1533
+
1285
1534
  datasetChecks.forEach((element) => {
1286
1535
  element.checked = value;
1287
1536
  this.toggleDataset(value, element.id, element);
@@ -1006,3 +1006,13 @@ input[type='range']::-ms-track {
1006
1006
  background: transparent;
1007
1007
  box-shadow: none;
1008
1008
  }
1009
+
1010
+ .zoom-in-message {
1011
+ padding: 0.1rem 0.6rem 0.1rem 0.6rem;
1012
+ margin-top: 0.2rem;
1013
+ background: #a0b128;
1014
+ border-radius: 10px;
1015
+ color: white;
1016
+ font-size: 0.875rem;
1017
+ text-align: center;
1018
+ }