@eeacms/volto-arcgis-block 0.1.202 → 0.1.203

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,12 @@ 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.203](https://github.com/eea/volto-arcgis-block/compare/0.1.202...0.1.203) - 21 September 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-1800, CLMS-2574 [masanchez85 - [`88f5c1d`](https://github.com/eea/volto-arcgis-block/commit/88f5c1da3ff1ce588608f22424bb2402af500da2)]
12
+ - CLMS-1800, CLMS-2574 [masanchez85 - [`18c055e`](https://github.com/eea/volto-arcgis-block/commit/18c055e436434e3bc0c14c8df32077e15d6d6689)]
7
13
  ### [0.1.202](https://github.com/eea/volto-arcgis-block/compare/0.1.201...0.1.202) - 21 September 2023
8
14
 
9
15
  ### [0.1.201](https://github.com/eea/volto-arcgis-block/compare/0.1.200...0.1.201) - 21 September 2023
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.202",
3
+ "version": "0.1.203",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -1035,9 +1035,16 @@ class InfoWidget extends React.Component {
1035
1035
  </span>
1036
1036
  )
1037
1037
  ) : (
1038
- <span className="info-panel-empty">
1039
- Click on the map to get pixel info
1040
- </span>
1038
+ <>
1039
+ <span className="info-panel-empty">
1040
+ Click on the map to get pixel info.
1041
+ </span>
1042
+ <br />
1043
+ <span className="info-panel-empty">
1044
+ Some products may not have information available to be
1045
+ displayed.
1046
+ </span>
1047
+ </>
1041
1048
  )}
1042
1049
  </>
1043
1050
  )}
@@ -212,7 +212,6 @@ export const TouchScreenPopup = () => {
212
212
  </>
213
213
  );
214
214
  };
215
-
216
215
  class MenuWidget extends React.Component {
217
216
  /**
218
217
  * Creator of the Basemap widget class
@@ -224,16 +223,17 @@ class MenuWidget extends React.Component {
224
223
  this.container = createRef();
225
224
  //Initially, we set the state of the component to
226
225
  //not be showing the basemap panel
227
- this.state = {
228
- showMapMenu: false,
229
- noServiceModal: true,
230
- setNoServiceModal: true,
231
- };
232
226
  // call the props of the layers list (mapviewer.jsx)
233
227
  this.location = this.props.location;
234
228
  this.compCfg = this.props.conf;
235
229
  this.map = this.props.map;
236
230
  this.view = this.props.view;
231
+ this.state = {
232
+ showMapMenu: false,
233
+ noServiceModal: true,
234
+ setNoServiceModal: true,
235
+ TMSLayerObj: null,
236
+ };
237
237
  this.menuClass =
238
238
  'esri-icon-drag-horizontal esri-widget--button esri-widget esri-interactive';
239
239
  this.loadFirst = true;
@@ -971,6 +971,11 @@ class MenuWidget extends React.Component {
971
971
  } else {
972
972
  sessionStorage.setItem('snowAndIce', false);
973
973
  }
974
+ if (productId === '333e4100b79045daa0ff16466ac83b7f') {
975
+ sessionStorage.setItem('DynamicLandCover', true);
976
+ } else {
977
+ sessionStorage.setItem('DynamicLandCover', false);
978
+ }
974
979
  }
975
980
 
976
981
  /**
@@ -1015,6 +1020,19 @@ class MenuWidget extends React.Component {
1015
1020
  if (!layer_default.length) {
1016
1021
  layer_default.push(checkboxId);
1017
1022
  }
1023
+ //CHECK SESSION STORAGE for TMSlAYEROBJ, if not there, create it with TMSLayerObj{ layer: layer, checboxId: checkboxId, dataset: dataset }, and if it is there, replace it with the new one
1024
+ let TMSLayerObj = {
1025
+ layer: layer,
1026
+ checkboxId: checkboxId,
1027
+ dataset: dataset,
1028
+ };
1029
+
1030
+ if (sessionStorage.getItem('TMSLayerObj')) {
1031
+ sessionStorage.setItem('TMSLayerObj', JSON.stringify(TMSLayerObj));
1032
+ } else {
1033
+ sessionStorage.setItem('TMSLayerObj', JSON.stringify(TMSLayerObj));
1034
+ }
1035
+
1018
1036
  // add each sublayer to this.layers
1019
1037
  this.processTMSLayer(layer, checkboxId, dataset);
1020
1038
 
@@ -1413,6 +1431,13 @@ class MenuWidget extends React.Component {
1413
1431
  * @param {*} checkboxId Is the layers checkbox ID
1414
1432
  */
1415
1433
  processTMSLayer(layer, checkboxId, dataset) {
1434
+ let selectedUrl;
1435
+ let zoom = this.view.get('zoom');
1436
+ if (Array.isArray(layer.LayerUrl)) {
1437
+ zoom < 10
1438
+ ? (selectedUrl = layer.LayerUrl[0])
1439
+ : (selectedUrl = layer.LayerUrl[1]);
1440
+ } else selectedUrl = layer.LayerUrl;
1416
1441
  const CustomTileLayer = BaseTileLayer.createSubclass({
1417
1442
  properties: {
1418
1443
  urlTemplate: null,
@@ -1427,7 +1452,7 @@ class MenuWidget extends React.Component {
1427
1452
  // si es cero será el maximo. las filas serán el array invertido
1428
1453
  // tengo que extrarer de alguna manera la cantidad de filas y columnas que se muestran.
1429
1454
 
1430
- return this.urlTemplate
1455
+ return /* this.urlTemplate */ selectedUrl
1431
1456
  .replace('{z}', level)
1432
1457
  .replace('{x}', col)
1433
1458
  .replace('{y}', row);
@@ -1442,11 +1467,10 @@ class MenuWidget extends React.Component {
1442
1467
  // Images pyramid formula
1443
1468
  if (this.tms) {
1444
1469
  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 . . .
1445
- row = rowmax - row - 1; // Invert Y axis
1470
+ row = zoom < 10 ? rowmax - row - 1 : row; // Invert Y axis
1446
1471
  }
1447
1472
 
1448
1473
  const url = this.getTileUrl(level, row, col);
1449
-
1450
1474
  // request for tiles based on the generated url
1451
1475
  // the signal option ensures that obsolete requests are aborted
1452
1476
  return esriRequest(url, {
@@ -1477,26 +1501,23 @@ class MenuWidget extends React.Component {
1477
1501
  // *******************************************************
1478
1502
  // end of Custom tile layer class code
1479
1503
  // *******************************************************
1480
- this.layers[checkboxId] = new CustomTileLayer({
1481
- id: checkboxId,
1482
- tms: true, // True establishes Y axis from the south northwards. False establishes tile origin top left and Y from north southwards (Default False)
1483
- urlTemplate: layer.LayerUrl,
1484
- // TMS Service.
1485
- // 'https://s3-eu-west-1.amazonaws.com/vito-lcv/global/2019/cog-full_l0-colored-full/{z}/{x}/{y}.png',
1486
- // Google/ESRI/OSM tiling style services
1487
- // "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
1488
- // "https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}",
1489
- // "https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg",
1490
- spatialReference: {
1491
- wkid: 3857,
1492
- },
1493
- title: layer.Title,
1494
- LayerTitle: layer.Title,
1495
- DatasetTitle: dataset.DatasetTitle,
1496
- ViewService: dataset.ViewService,
1497
- StaticImageLegend: layer.StaticImageLegend,
1498
- url: dataset.ViewService,
1499
- });
1504
+ let customTileLayer = this.getGlobalDynamicLandCoverUrl(
1505
+ CustomTileLayer,
1506
+ checkboxId,
1507
+ layer,
1508
+ dataset,
1509
+ selectedUrl,
1510
+ );
1511
+ if (customTileLayer === null || customTileLayer === undefined) return;
1512
+ if (this.layers[checkboxId]) {
1513
+ if (customTileLayer.urlTemplate !== this.layers[checkboxId].urlTemplate) {
1514
+ this.map.remove(this.layers[checkboxId]);
1515
+ this.layers[checkboxId] = customTileLayer;
1516
+ this.map.add(this.layers[checkboxId]);
1517
+ }
1518
+ } else {
1519
+ this.layers[checkboxId] = customTileLayer;
1520
+ }
1500
1521
  }
1501
1522
 
1502
1523
  /**
@@ -1719,6 +1740,7 @@ class MenuWidget extends React.Component {
1719
1740
  } */ else {
1720
1741
  this.map.add(this.layers[elem.id]);
1721
1742
  }
1743
+ if (this.layers[elem.id] === undefined) return;
1722
1744
  this.layers[elem.id].visible = true; //layer id
1723
1745
  this.visibleLayers[elem.id] = ['fas', 'eye'];
1724
1746
  this.timeLayers[elem.id] = ['far', 'clock'];
@@ -1893,6 +1915,31 @@ class MenuWidget extends React.Component {
1893
1915
  }
1894
1916
  }
1895
1917
 
1918
+ getGlobalDynamicLandCoverUrl(
1919
+ CustomTileLayer,
1920
+ checkboxId,
1921
+ layer,
1922
+ dataset,
1923
+ url,
1924
+ ) {
1925
+ const customTileLayer = new CustomTileLayer({
1926
+ id: checkboxId,
1927
+ tms: true,
1928
+ urlTemplate: url,
1929
+ spatialReference: {
1930
+ wkid: 3857,
1931
+ },
1932
+ title: layer.Title,
1933
+ LayerTitle: layer.Title,
1934
+ DatasetTitle: dataset.DatasetTitle,
1935
+ ViewService: dataset.ViewService,
1936
+ StaticImageLegend: layer.StaticImageLegend,
1937
+ url: dataset.ViewService,
1938
+ });
1939
+
1940
+ return customTileLayer;
1941
+ }
1942
+
1896
1943
  createStaticLegendImageNode(id, title, imageURL) {
1897
1944
  let node = document.createElement('div');
1898
1945
  node.classList.add('esri-legend__service');
@@ -3026,7 +3073,7 @@ class MenuWidget extends React.Component {
3026
3073
  }
3027
3074
  }
3028
3075
 
3029
- componentDidUpdate() {
3076
+ componentDidUpdate(prevState, prevProps) {
3030
3077
  if (this.props.download) return;
3031
3078
 
3032
3079
  if (sessionStorage.getItem('snowAndIce') === 'true') {
@@ -3044,6 +3091,16 @@ class MenuWidget extends React.Component {
3044
3091
  this.showZoomMessageOnDataset(datasetCheck);
3045
3092
  }
3046
3093
  }
3094
+ const latestLayer = JSON.parse(sessionStorage.getItem('TMSLayerObj'));
3095
+
3096
+ if (latestLayer) {
3097
+ this.view.when(() => {
3098
+ if (this.view.stationary) {
3099
+ const { layer, checkboxId, dataset } = latestLayer;
3100
+ this.processTMSLayer(checkboxId, layer, dataset);
3101
+ }
3102
+ });
3103
+ }
3047
3104
  }
3048
3105
 
3049
3106
  /**