@eeacms/volto-arcgis-block 0.1.351 → 0.1.353

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,17 @@ 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.353](https://github.com/eea/volto-arcgis-block/compare/0.1.352...0.1.353) - 15 April 2025
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-286928 (bug): linter error fixed. [Unai Bolivar - [`d7afc23`](https://github.com/eea/volto-arcgis-block/commit/d7afc238ad25575b7e4857bb8ef6f693b3f1f736)]
12
+ - CLMS-286928 (bug): Fixed issues pertaining user upload wms services for logged in users [Unai Bolivar - [`49eaf4c`](https://github.com/eea/volto-arcgis-block/commit/49eaf4cfa94fdd406709cd50b50aafd18a13f25e)]
13
+ ### [0.1.352](https://github.com/eea/volto-arcgis-block/compare/0.1.351...0.1.352) - 11 April 2025
14
+
15
+ #### :hammer_and_wrench: Others
16
+
17
+ - CLMS-285178 (bug): Swipe widget loads if coming from dataset catalogue and also auto updates without having to close and open widget manually. [Unai Bolivar - [`2d18dc2`](https://github.com/eea/volto-arcgis-block/commit/2d18dc28cdba2a1056894c70a0ebb06f8bf30c41)]
7
18
  ### [0.1.351](https://github.com/eea/volto-arcgis-block/compare/0.1.350...0.1.351) - 11 April 2025
8
19
 
9
20
  ### [0.1.350](https://github.com/eea/volto-arcgis-block/compare/0.1.349...0.1.350) - 11 April 2025
@@ -182,7 +193,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
182
193
 
183
194
  #### :house: Internal changes
184
195
 
185
- - chore: [JENKINSFILE] remove unused code [valentinab25 - [`c62af37`](https://github.com/eea/volto-arcgis-block/commit/c62af37e5c81f7b6b1d204de8a724499d00420d9)]
186
196
 
187
197
  #### :house: Documentation changes
188
198
 
@@ -501,13 +511,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
501
511
  #### :hammer_and_wrench: Others
502
512
 
503
513
  - CLMS-2916 (bug): Map Viewer / Products and Datasets tab / Layer - The information icon links to localhost in demo environment [Unai Bolivar - [`eda000a`](https://github.com/eea/volto-arcgis-block/commit/eda000a72278ab073033e520b868ded75dcc2904)]
504
- - test: [JENKINS] fix jest config, fail with logs on coverage [valentinab25 - [`8a0855d`](https://github.com/eea/volto-arcgis-block/commit/8a0855dfe47ec58a596ae0ec360ba8f8d075e991)]
505
- - test: [JENKINS] fix jest config, fail with logs on coverage [valentinab25 - [`3cfe9be`](https://github.com/eea/volto-arcgis-block/commit/3cfe9be4c6d4ace0ef83b452ebdd5b06025123aa)]
506
514
  ### [0.1.245](https://github.com/eea/volto-arcgis-block/compare/0.1.244...0.1.245) - 4 January 2024
507
515
 
508
516
  #### :hammer_and_wrench: Others
509
517
 
510
- - test: [JENKINS] fix jest config, fail with logs on coverage [valentinab25 - [`a93b081`](https://github.com/eea/volto-arcgis-block/commit/a93b0819eaa765c92bc25cf195f7a43fcd1dddbd)]
511
518
  ### [0.1.244](https://github.com/eea/volto-arcgis-block/compare/0.1.243...0.1.244) - 19 December 2023
512
519
 
513
520
  ### [0.1.243](https://github.com/eea/volto-arcgis-block/compare/0.1.242...0.1.243) - 15 December 2023
@@ -547,7 +554,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
547
554
 
548
555
  #### :hammer_and_wrench: Others
549
556
 
550
- - test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`f45d4bf`](https://github.com/eea/volto-arcgis-block/commit/f45d4bf42061d13d9c18554bef692cb40b3a6fb7)]
551
557
  ### [0.1.235](https://github.com/eea/volto-arcgis-block/compare/0.1.234...0.1.235) - 16 November 2023
552
558
 
553
559
  ### [0.1.234](https://github.com/eea/volto-arcgis-block/compare/0.1.233...0.1.234) - 15 November 2023
@@ -1621,13 +1627,10 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1621
1627
  #### :hammer_and_wrench: Others
1622
1628
 
1623
1629
  - Merge pull request #148 from eea/develop [KCarpinteroBM - [`24266fb`](https://github.com/eea/volto-arcgis-block/commit/24266fb3a0c1662d22ae0529dc1d5a25c711cf97)]
1624
- - Revert "[JENKINS] Use eeacms/plone-backend and Volto alpha version- Refs #151967" [Mikel Larreategi - [`f751f69`](https://github.com/eea/volto-arcgis-block/commit/f751f69f652f0340ae55af6a4dab89d6bdc80906)]
1625
1630
  - Revert "Revert "Mapviewer menu and map viewer options persistence"" [Mikel Larreategi - [`ad6e440`](https://github.com/eea/volto-arcgis-block/commit/ad6e440cdc160cffb1e86e1b26e501dbe648476c)]
1626
1631
  - Revert "code coverage removal" [Mikel Larreategi - [`376f2d1`](https://github.com/eea/volto-arcgis-block/commit/376f2d1cd6e4e5110b3b63d5114af1bcfebe094b)]
1627
1632
  - Revert "Update cypress.json" [Mikel Larreategi - [`43d01a0`](https://github.com/eea/volto-arcgis-block/commit/43d01a0a95a58ef5215c6cbf18223ca30a11b9cc)]
1628
1633
  - Revert "Update cypress.json" [Mikel Larreategi - [`054c4ae`](https://github.com/eea/volto-arcgis-block/commit/054c4ae1767e1f26e6ec7e96a0e26a9711f29f04)]
1629
- - 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)]
1630
- - revert [JENKINS] Use eeacms/plone-backend and Volto alpha version- Refs #151967 [Mikel Larreategi - [`85ee194`](https://github.com/eea/volto-arcgis-block/commit/85ee1941e029df2b7dc910bf75231c75ffeca8c2)]
1631
1634
  - Update cypress.json [KCarpinteroBM - [`be285ff`](https://github.com/eea/volto-arcgis-block/commit/be285fff0c53e06a0180d5318cce81195eabcf80)]
1632
1635
  - Update cypress.json [KCarpinteroBM - [`a7f2118`](https://github.com/eea/volto-arcgis-block/commit/a7f2118acb7b048b4cef85aa9663c2244a1c9ca0)]
1633
1636
  - linting fix [KCarpinteroBM - [`27e969a`](https://github.com/eea/volto-arcgis-block/commit/27e969a7a411fd4646e0e742ce846efc0d79703e)]
@@ -1687,7 +1690,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1687
1690
  - UX improvements [rodriama - [`151dc4b`](https://github.com/eea/volto-arcgis-block/commit/151dc4b02d0a73fdd66de9d594620ac0fa5f1dbf)]
1688
1691
  - deleted failing tests [KCarpinteroBM - [`ddaa9e6`](https://github.com/eea/volto-arcgis-block/commit/ddaa9e6f06db6960a4c214d3be2420c48b26715d)]
1689
1692
  - cleaning unnecessary files [KCarpinteroBM - [`2c02199`](https://github.com/eea/volto-arcgis-block/commit/2c021990912beb02b603a1de89aecd62e0063769)]
1690
- - Reverting to Automated release 0.1.39 [KCarpinteroBM - [`fb9f317`](https://github.com/eea/volto-arcgis-block/commit/fb9f3176ccdea18fceb329eaac13ced0566ee648)]
1691
1693
  - commands added [KCarpinteroBM - [`049e60b`](https://github.com/eea/volto-arcgis-block/commit/049e60b7d124d1c05abd0b2775b510795f4ed59f)]
1692
1694
  - Mapviewer testing implementation [KCarpinteroBM - [`0103002`](https://github.com/eea/volto-arcgis-block/commit/0103002869eea108e16e3b5ff2e77a725dcc7c4b)]
1693
1695
  ### [0.1.39](https://github.com/eea/volto-arcgis-block/compare/0.1.38...0.1.39) - 24 March 2022
@@ -1707,7 +1709,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1707
1709
  - ESLint fix [rodriama - [`75dae9b`](https://github.com/eea/volto-arcgis-block/commit/75dae9b5bba18ab6d9624f6c99714b4bd2179003)]
1708
1710
  - Remove section title [rodriama - [`ece860e`](https://github.com/eea/volto-arcgis-block/commit/ece860eae3519c7e611abac16e8d53c9a9408b34)]
1709
1711
  - Es-Lint [manuelmartinezbilbomatica - [`39d8d11`](https://github.com/eea/volto-arcgis-block/commit/39d8d11b9096fd603df8510c119d2e12817415d6)]
1710
- - Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`bf9f683`](https://github.com/eea/volto-arcgis-block/commit/bf9f683dd35a9edb4cfd9111affcb8f8edbeae89)]
1711
1712
  - FEAT: Parser Time implemented [manuelmartinezbilbomatica - [`689c99e`](https://github.com/eea/volto-arcgis-block/commit/689c99e55221fee6c7c7fafc4ab95ae7a646d3dd)]
1712
1713
  ### [0.1.38](https://github.com/eea/volto-arcgis-block/compare/0.1.37...0.1.38) - 18 March 2022
1713
1714
 
@@ -1802,7 +1803,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
1802
1803
  - ESLint fix [rodriama - [`5fd3772`](https://github.com/eea/volto-arcgis-block/commit/5fd3772f197a3a380067962a5638dbf901a4624e)]
1803
1804
  - Pixel info [rodriama - [`1ccef39`](https://github.com/eea/volto-arcgis-block/commit/1ccef39a9adcc3ee94655c77a5a166b613600a08)]
1804
1805
  - NUTS bug fix [rodriama - [`37fe7f3`](https://github.com/eea/volto-arcgis-block/commit/37fe7f3fad2c005e3b7c234b3b0564d5df92fa8c)]
1805
- - Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`ea5af8b`](https://github.com/eea/volto-arcgis-block/commit/ea5af8b02a5f2ee25b9b0be67cf3792bbbe84ed7)]
1806
1806
  ### [0.1.23](https://github.com/eea/volto-arcgis-block/compare/0.1.22...0.1.23) - 17 December 2021
1807
1807
 
1808
1808
  #### :hammer_and_wrench: Others
@@ -2047,7 +2047,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
2047
2047
  - Trying to delay ArcGIS modules load [gonzalezsd - [`ff16985`](https://github.com/eea/volto-arcgis-block/commit/ff169858e42d30bfcacc423ffc27762bb9ef05a4)]
2048
2048
  - Run bootstrap to fix files [valentinab25 - [`236893f`](https://github.com/eea/volto-arcgis-block/commit/236893f03314eb638b7667f81b1f91491a98ee17)]
2049
2049
  - fix git_name [valentinab25 - [`c7806c3`](https://github.com/eea/volto-arcgis-block/commit/c7806c312964425dc23e5d4c6973de8b81ddaeac)]
2050
- - Add Sonarqube tag using frontend addons list [EEA Jenkins - [`e3afb51`](https://github.com/eea/volto-arcgis-block/commit/e3afb515dda459ee03e2b5d4b56465d2d4ad1503)]
2051
2050
  - Trying to change imports [gonzalezsd - [`d83d7e2`](https://github.com/eea/volto-arcgis-block/commit/d83d7e2f68da4b2a284735847f93c0763a7e13b6)]
2052
2051
  - default design [bipoza - [`88fbe0b`](https://github.com/eea/volto-arcgis-block/commit/88fbe0b2bc73e732e2993324a567f53902e85506)]
2053
2052
  - 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.351",
3
+ "version": "0.1.353",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -2035,15 +2035,25 @@ class MenuWidget extends React.Component {
2035
2035
  layerId = title.toUpperCase().replace(/ /g, '_');
2036
2036
  const constructedSublayers = resourceLayer.sublayers?.items?.map(
2037
2037
  (sublayer) => {
2038
- const { index, name, title, legendUrl, featureInfoUrl } = sublayer;
2038
+ const {
2039
+ index,
2040
+ name,
2041
+ title,
2042
+ legendUrl,
2043
+ featureInfoUrl,
2044
+ queryable,
2045
+ popupEnabled,
2046
+ visible,
2047
+ legendEnabled,
2048
+ } = sublayer;
2039
2049
  return {
2040
2050
  index,
2041
2051
  name,
2042
2052
  title,
2043
- popupEnabled: true,
2044
- queryable: true,
2045
- visible: true,
2046
- legendEnabled: true,
2053
+ popupEnabled,
2054
+ queryable,
2055
+ visible,
2056
+ legendEnabled,
2047
2057
  legendUrl: legendUrl
2048
2058
  ? legendUrl
2049
2059
  : viewService + legendRequest + name,
@@ -2202,7 +2212,9 @@ class MenuWidget extends React.Component {
2202
2212
  const newWmsUserServiceLayers = prevState.wmsUserServiceLayers.filter(
2203
2213
  (layer) => layer.LayerId !== elemId,
2204
2214
  );
2205
- this.saveUserServicesToStorage(newWmsUserServiceLayers);
2215
+ if (this.userID && this.userID !== null) {
2216
+ this.saveUserServicesToStorage(newWmsUserServiceLayers);
2217
+ }
2206
2218
  return { wmsUserServiceLayers: newWmsUserServiceLayers };
2207
2219
  }
2208
2220
  return null;
@@ -2214,6 +2226,11 @@ class MenuWidget extends React.Component {
2214
2226
 
2215
2227
  try {
2216
2228
  const layersToSave = layers.map((layer) => {
2229
+ // First, see if this layer exists in previous saved services to retain checked state
2230
+ const checkedLayers =
2231
+ JSON.parse(sessionStorage.getItem('checkedLayers')) || [];
2232
+ const isChecked = checkedLayers.includes(layer.LayerId);
2233
+
2217
2234
  // Create a simplified object for storage
2218
2235
  return {
2219
2236
  url: layer.url,
@@ -2234,6 +2251,9 @@ class MenuWidget extends React.Component {
2234
2251
  })),
2235
2252
  ViewService: layer.ViewService,
2236
2253
  LayerId: layer.LayerId,
2254
+ visibility: layer.visible !== false,
2255
+ opacity: layer.opacity || 1,
2256
+ checked: isChecked || layer.checked || false,
2237
2257
  };
2238
2258
  });
2239
2259
 
@@ -2246,6 +2266,7 @@ class MenuWidget extends React.Component {
2246
2266
 
2247
2267
  async loadUserServicesFromStorage() {
2248
2268
  if (this.userID != null) {
2269
+ sessionStorage.clear();
2249
2270
  try {
2250
2271
  const savedServices = JSON.parse(
2251
2272
  localStorage.getItem(USER_SERVICES_KEY + '_' + this.userID),
@@ -2258,6 +2279,20 @@ class MenuWidget extends React.Component {
2258
2279
  try {
2259
2280
  // Create a new WMSLayer with the saved properties
2260
2281
  const newLayer = new WMSLayer(serviceData);
2282
+
2283
+ // Set visibility property based on saved value
2284
+ newLayer.visible = serviceData.visibility !== false;
2285
+
2286
+ // Remember the original checked state and visibility
2287
+ newLayer.checked = serviceData.checked;
2288
+
2289
+ // Initialize visibleLayers for this layer
2290
+ if (!this.visibleLayers) this.visibleLayers = {};
2291
+ this.visibleLayers[serviceData.LayerId] =
2292
+ serviceData.visibility !== false
2293
+ ? ['fas', 'eye']
2294
+ : ['fas', 'eye-slash'];
2295
+
2261
2296
  // Add to this.layers
2262
2297
  this.layers[serviceData.LayerId] = newLayer;
2263
2298
  return newLayer;
@@ -2271,27 +2306,87 @@ class MenuWidget extends React.Component {
2271
2306
  const validLayers = recreatedLayers.filter((layer) => layer !== null);
2272
2307
 
2273
2308
  // Update state with recreated layers
2274
- this.setState({ wmsUserServiceLayers: validLayers });
2275
- // Get checked layers from session storage
2276
- // const checkedLayers =
2277
- // JSON.parse(sessionStorage.getItem('checkedLayers')) || [];
2278
-
2279
- // For each valid layer that was previously checked, make it visible
2280
- validLayers.forEach((layer) => {
2281
- // if (checkedLayers.includes(layer.LayerId)) {
2282
- const node = document.getElementById(layer.LayerId);
2283
- if (node) {
2284
- layer.visible === true
2285
- ? (node.checked = true)
2286
- : (node.checked = false);
2287
- this.toggleLayer(node);
2288
- }
2309
+ this.setState({ wmsUserServiceLayers: validLayers }, () => {
2310
+ // For each layer, update the checkbox state based on localStorage
2311
+ setTimeout(() => {
2312
+ validLayers.forEach((layer) => {
2313
+ const node = document.getElementById(layer.LayerId);
2314
+ if (node) {
2315
+ // Check the checkbox if it was saved as checked
2316
+ if (layer.checked === true) {
2317
+ // First add to checkedLayers in sessionStorage if not already there
2318
+ const checkedLayers =
2319
+ JSON.parse(sessionStorage.getItem('checkedLayers')) || [];
2320
+
2321
+ if (!checkedLayers.includes(layer.LayerId)) {
2322
+ checkedLayers.unshift(layer.LayerId);
2323
+ sessionStorage.setItem(
2324
+ 'checkedLayers',
2325
+ JSON.stringify(checkedLayers),
2326
+ );
2327
+ window.dispatchEvent(new Event('storage'));
2328
+ }
2329
+
2330
+ // Then check the checkbox and call toggleLayer with a flag to preserve visibility
2331
+ node.checked = true;
2332
+
2333
+ // Custom addition to toggleLayer to bypass visibility override
2334
+ this.toggleLayerWithoutVisibilityReset(node);
2335
+ }
2336
+ }
2337
+ });
2338
+ }, 100);
2289
2339
  });
2290
2340
  }
2291
2341
  } catch (error) {}
2292
2342
  }
2293
2343
  }
2294
2344
 
2345
+ toggleLayerWithoutVisibilityReset(elem) {
2346
+ // Copy most of toggleLayer behavior but don't set this.visibleLayers[elem.id]
2347
+ if (this.layers[elem.id] === undefined) return;
2348
+ if (!this.visibleLayers) this.visibleLayers = {};
2349
+ if (!this.timeLayers) this.timeLayers = {};
2350
+
2351
+ // Add the layer to the map
2352
+ this.layers[elem.id].visible = this.visibleLayers[elem.id][1] === 'eye';
2353
+ this.map.add(this.layers[elem.id]);
2354
+
2355
+ // Continue with other toggleLayer operations
2356
+ this.timeLayers[elem.id] = ['far', 'clock'];
2357
+
2358
+ // Add to active layers
2359
+ this.activeLayersJSON[elem.id] = this.addActiveLayer(
2360
+ elem,
2361
+ Object.keys(this.activeLayersJSON).length,
2362
+ );
2363
+
2364
+ this.saveCheckedLayer(elem.id);
2365
+
2366
+ // Reorder layers
2367
+ let nuts = this.map.layers.items.find((layer) => layer.title === 'nuts');
2368
+ if (nuts) {
2369
+ this.map.reorder(nuts, this.map.layers.items.length + 1);
2370
+ }
2371
+
2372
+ this.layersReorder();
2373
+ this.checkInfoWidget();
2374
+
2375
+ // Toggle custom legend
2376
+ if (
2377
+ this.layers[elem.id].ViewService?.toLowerCase().includes('wmts') ||
2378
+ this.layers[elem.id].ViewService?.toLowerCase().endsWith('file')
2379
+ ) {
2380
+ this.toggleCustomLegendItem(this.layers[elem.id]);
2381
+ }
2382
+
2383
+ if (!this.props.download && this.props.hotspotData) {
2384
+ this.activeLayersToHotspotData(elem.id);
2385
+ }
2386
+
2387
+ this.renderHotspot();
2388
+ }
2389
+
2295
2390
  /**
2296
2391
  * Method to show/hide a layer. Update checkboxes from dataset and products
2297
2392
  * @param {*} elem Is the checkbox
@@ -4033,22 +4128,28 @@ class MenuWidget extends React.Component {
4033
4128
  let layerOpacities = JSON.parse(sessionStorage.getItem('layerOpacities'));
4034
4129
  if (layerOpacities === null) {
4035
4130
  layerOpacities = {};
4036
- layerOpacities[layer] = value;
4037
- sessionStorage.setItem('layerOpacities', JSON.stringify(layerOpacities));
4038
- } else {
4039
- layerOpacities[layer] = value;
4040
- sessionStorage.setItem('layerOpacities', JSON.stringify(layerOpacities));
4041
4131
  }
4042
- let savedServices = JSON.parse(
4132
+ layerOpacities[layer] = value;
4133
+ sessionStorage.setItem('layerOpacities', JSON.stringify(layerOpacities));
4134
+
4135
+ // Save to localStorage for user service layers
4136
+ const savedServices = JSON.parse(
4043
4137
  localStorage.getItem(USER_SERVICES_KEY + '_' + this.userID),
4044
4138
  );
4045
- if (savedServices === null) {
4046
- return;
4047
- } else {
4048
- for (const service of Object.values(savedServices)) {
4139
+
4140
+ if (savedServices && Array.isArray(savedServices)) {
4141
+ let servicesUpdated = false;
4142
+
4143
+ // Update opacity for matching layer in user services
4144
+ savedServices.forEach((service) => {
4049
4145
  if (service.LayerId === layer) {
4050
4146
  service.opacity = value;
4147
+ servicesUpdated = true;
4051
4148
  }
4149
+ });
4150
+
4151
+ // Only save if we made changes
4152
+ if (servicesUpdated) {
4052
4153
  localStorage.setItem(
4053
4154
  USER_SERVICES_KEY + '_' + this.userID,
4054
4155
  JSON.stringify(savedServices),
@@ -4065,43 +4166,44 @@ class MenuWidget extends React.Component {
4065
4166
  loadOpacity() {
4066
4167
  let layerOpacities =
4067
4168
  JSON.parse(sessionStorage.getItem('layerOpacities')) || {};
4169
+
4170
+ // Load from localStorage for user service layers
4068
4171
  const savedUserServices = JSON.parse(
4069
4172
  localStorage.getItem(USER_SERVICES_KEY + '_' + this.userID),
4070
4173
  );
4071
- if (savedUserServices) {
4072
- Object.values(savedUserServices).forEach((service) => {
4073
- let layer = service.LayerId;
4074
- let value = service.opacity;
4075
- // Check if the layer is already in layerOpacities
4076
- if (layerOpacities[layer] === undefined) {
4077
- //add to layerOpacties
4078
- layerOpacities[layer] = value;
4079
- // if (this.layers[service]) {
4080
- // // set map
4081
- // this.layers[service].opacity = value;
4082
- // // set slider
4083
- // let nodeValue = `.active-layer[layer-id="${layer}"] .active-layer-opacity`;
4084
- // let node = document.querySelector(nodeValue);
4085
- // if (node) {
4086
- // node.dataset.opacity = value * 100;
4087
- // }
4088
- // }
4174
+
4175
+ // Import opacity values from user services if not already in session storage
4176
+ if (savedUserServices && Array.isArray(savedUserServices)) {
4177
+ savedUserServices.forEach((service) => {
4178
+ const layerId = service.LayerId;
4179
+ const opacity = service.opacity;
4180
+
4181
+ // If this layer's opacity isn't in session storage yet, add it
4182
+ if (
4183
+ layerId &&
4184
+ opacity !== undefined &&
4185
+ layerOpacities[layerId] === undefined
4186
+ ) {
4187
+ layerOpacities[layerId] = opacity;
4089
4188
  }
4090
4189
  });
4091
4190
  }
4092
- if (layerOpacities) {
4093
- for (const layer in layerOpacities) {
4094
- if (this.layers[layer]) {
4095
- let value = layerOpacities[layer];
4096
- // set map
4097
- this.layers[layer].opacity = value;
4098
- // set slider
4099
- let node = document.querySelector(
4100
- '.active-layer[layer-id="' + layer + '"] .active-layer-opacity',
4101
- );
4102
- if (node) {
4103
- node.dataset.opacity = value * 100;
4104
- }
4191
+ //save layerOpacities to sessionStorage
4192
+ sessionStorage.setItem('layerOpacities', JSON.stringify(layerOpacities));
4193
+ // Apply opacity values to layers and UI
4194
+ for (const layerId in layerOpacities) {
4195
+ if (this.layers[layerId]) {
4196
+ const value = layerOpacities[layerId];
4197
+
4198
+ // Set opacity on the map layer
4199
+ this.layers[layerId].opacity = value;
4200
+
4201
+ // Update UI opacity slider
4202
+ const node = document.querySelector(
4203
+ `.active-layer[layer-id="${layerId}"] .active-layer-opacity`,
4204
+ );
4205
+ if (node) {
4206
+ node.dataset.opacity = value * 100;
4105
4207
  }
4106
4208
  }
4107
4209
  }
@@ -4287,7 +4389,13 @@ class MenuWidget extends React.Component {
4287
4389
  }
4288
4390
  this.setLegendOpacity();
4289
4391
  this.loadOpacity();
4290
- this.loadVisibility();
4392
+ if (
4393
+ prevProps.hotspotData !== this.props.hotspotData ||
4394
+ !this._visibilityInitialized
4395
+ ) {
4396
+ this.loadVisibility();
4397
+ this._visibilityInitialized = true;
4398
+ }
4291
4399
  }
4292
4400
 
4293
4401
  /**
@@ -4295,6 +4403,34 @@ class MenuWidget extends React.Component {
4295
4403
  */
4296
4404
  saveVisibility() {
4297
4405
  if (this.props.download) return;
4406
+
4407
+ // Get services from localStorage - it's an array of objects
4408
+ const savedServices = JSON.parse(
4409
+ localStorage.getItem(USER_SERVICES_KEY + '_' + this.userID),
4410
+ );
4411
+
4412
+ if (savedServices && Array.isArray(savedServices)) {
4413
+ let servicesUpdated = false;
4414
+
4415
+ // Update visibility state for each service in the array
4416
+ savedServices.forEach((service) => {
4417
+ const layerId = service.LayerId;
4418
+ if (layerId && this.visibleLayers[layerId]) {
4419
+ // Update visibility based on eye icon state
4420
+ service.visibility =
4421
+ this.visibleLayers[layerId][1] === 'eye' ? true : false;
4422
+ servicesUpdated = true;
4423
+ }
4424
+ });
4425
+
4426
+ // Only save if we made changes
4427
+ if (servicesUpdated) {
4428
+ localStorage.setItem(
4429
+ USER_SERVICES_KEY + '_' + this.userID,
4430
+ JSON.stringify(savedServices),
4431
+ );
4432
+ }
4433
+ }
4298
4434
  sessionStorage.setItem('visibleLayers', JSON.stringify(this.visibleLayers));
4299
4435
  }
4300
4436
 
@@ -4304,6 +4440,8 @@ class MenuWidget extends React.Component {
4304
4440
  loadVisibility() {
4305
4441
  if (this.props.download) return;
4306
4442
 
4443
+ let hasChanges = false;
4444
+
4307
4445
  // Load visibility settings from sessionStorage
4308
4446
  let vl = JSON.parse(sessionStorage.getItem('visibleLayers'));
4309
4447
  if (vl) {
@@ -4317,44 +4455,52 @@ class MenuWidget extends React.Component {
4317
4455
  localStorage.getItem(USER_SERVICES_KEY + '_' + this.userID),
4318
4456
  );
4319
4457
 
4320
- if (savedUserServices) {
4321
- Object.values(savedUserServices).forEach((service) => {
4322
- let layerId = service.LayerId;
4323
- let visibility = service.visibility;
4324
- // Only add visibility from localStorage if not already in sessionStorage
4325
- if (this.visibleLayers[layerId] === undefined) {
4326
- if (visibility) {
4327
- this.visibleLayers[layerId] = ['fas', 'eye'];
4328
- } else {
4329
- this.visibleLayers[layerId] = ['fas', 'eye-slash'];
4330
- }
4458
+ if (savedUserServices && Array.isArray(savedUserServices)) {
4459
+ savedUserServices.forEach((service) => {
4460
+ const layerId = service.LayerId;
4461
+ // Check if visibility is explicitly defined (could be true, false, or undefined)
4462
+ if (
4463
+ layerId &&
4464
+ this.visibleLayers[layerId] === undefined &&
4465
+ service.visibility !== undefined
4466
+ ) {
4467
+ // Set visible icon based on saved visibility boolean value
4468
+ this.visibleLayers[layerId] =
4469
+ service.visibility === true ? ['fas', 'eye'] : ['fas', 'eye-slash'];
4470
+ hasChanges = true;
4331
4471
  }
4332
4472
  });
4333
4473
  }
4334
-
4335
- // Apply visibility settings to layers
4474
+ //add this.visibleLayers to session storage
4475
+ sessionStorage.setItem('visibleLayers', JSON.stringify(this.visibleLayers));
4336
4476
  for (const key in this.visibleLayers) {
4337
4477
  if (this.layers[key]) {
4338
- if (this.visibleLayers[key][1] === 'eye') {
4339
- this.layers[key].visible = true;
4340
- } else {
4341
- this.layers[key].visible = false;
4342
- }
4478
+ // Set layer visibility based on eye/eye-slash
4479
+ const shouldBeVisible = this.visibleLayers[key][1] === 'eye';
4480
+ this.layers[key].visible = shouldBeVisible;
4343
4481
 
4482
+ // Update the active layer UI if it exists
4344
4483
  let elem = document.getElementById(key);
4345
4484
  if (elem && this.activeLayersJSON[key]) {
4485
+ // Get the current order of the active layer
4346
4486
  let order = this.activeLayersJSON[key].props['layer-order'];
4347
- // add active layer to DOM
4487
+
4488
+ // Force recreate the active layer component with the correct visibility state
4348
4489
  this.activeLayersJSON[key] = this.addActiveLayer(elem, order);
4349
- // reorder layers
4490
+
4491
+ // Update related UI
4350
4492
  this.layersReorder();
4351
- // show/hide info widget
4352
4493
  this.checkInfoWidget();
4353
- // update
4354
- this.setState({});
4494
+ this.toggleCustomLegendItem(this.layers[key]);
4495
+ hasChanges = true;
4355
4496
  }
4356
4497
  }
4357
4498
  }
4499
+
4500
+ // Only update state once if there were changes
4501
+ if (hasChanges) {
4502
+ this.setState({});
4503
+ }
4358
4504
  }
4359
4505
 
4360
4506
  /**
@@ -4393,6 +4539,8 @@ class MenuWidget extends React.Component {
4393
4539
  */
4394
4540
  saveCheckedLayer(layer) {
4395
4541
  if (this.props.download) return;
4542
+
4543
+ // Update sessionStorage as before
4396
4544
  let checkedLayers = JSON.parse(sessionStorage.getItem('checkedLayers'));
4397
4545
  if (checkedLayers === null) {
4398
4546
  checkedLayers = [layer];
@@ -4404,6 +4552,31 @@ class MenuWidget extends React.Component {
4404
4552
  sessionStorage.setItem('checkedLayers', JSON.stringify(checkedLayers));
4405
4553
  }
4406
4554
  window.dispatchEvent(new Event('storage'));
4555
+
4556
+ // Also update localStorage for user service layers
4557
+ const savedServices = JSON.parse(
4558
+ localStorage.getItem(USER_SERVICES_KEY + '_' + this.userID),
4559
+ );
4560
+
4561
+ if (savedServices && Array.isArray(savedServices)) {
4562
+ let servicesUpdated = false;
4563
+
4564
+ // Update checked state for matching layer in user services
4565
+ savedServices.forEach((service) => {
4566
+ if (service.LayerId === layer) {
4567
+ service.checked = true;
4568
+ servicesUpdated = true;
4569
+ }
4570
+ });
4571
+
4572
+ // Only save if we made changes
4573
+ if (servicesUpdated) {
4574
+ localStorage.setItem(
4575
+ USER_SERVICES_KEY + '_' + this.userID,
4576
+ JSON.stringify(savedServices),
4577
+ );
4578
+ }
4579
+ }
4407
4580
  }
4408
4581
 
4409
4582
  /**
@@ -4442,6 +4615,31 @@ class MenuWidget extends React.Component {
4442
4615
  sessionStorage.setItem('visibleLayers', JSON.stringify(visibleLayers));
4443
4616
  }
4444
4617
  }
4618
+
4619
+ // Also update localStorage for user service layers
4620
+ const savedServices = JSON.parse(
4621
+ localStorage.getItem(USER_SERVICES_KEY + '_' + this.userID),
4622
+ );
4623
+
4624
+ if (savedServices && Array.isArray(savedServices)) {
4625
+ let servicesUpdated = false;
4626
+
4627
+ // Update checked state for matching layer in user services
4628
+ savedServices.forEach((service) => {
4629
+ if (service.LayerId === layer) {
4630
+ service.checked = false;
4631
+ servicesUpdated = true;
4632
+ }
4633
+ });
4634
+
4635
+ // Only save if we made changes
4636
+ if (servicesUpdated) {
4637
+ localStorage.setItem(
4638
+ USER_SERVICES_KEY + '_' + this.userID,
4639
+ JSON.stringify(savedServices),
4640
+ );
4641
+ }
4642
+ }
4445
4643
  }
4446
4644
 
4447
4645
  deleteFilteredLayer(layer) {
@@ -73,6 +73,7 @@ class SwipeWidget extends React.Component {
73
73
  // and ensure that the component is rendered again
74
74
  this.loadOptions();
75
75
  this.map.layers.on('change', () => {
76
+ this.loadOptions();
76
77
  if (this.hasSwipe) {
77
78
  this.map.layers.removeAll();
78
79
  if (this.swipe.leadingLayers && this.swipe.leadingLayers.items[0]) {
@@ -82,7 +83,6 @@ class SwipeWidget extends React.Component {
82
83
  this.map.layers.add(this.swipe.trailingLayers.items[0]);
83
84
  }
84
85
  }
85
- this.loadOptions();
86
86
  });
87
87
  this.setState({ showMapMenu: true });
88
88
  }
@@ -136,7 +136,31 @@ class SwipeWidget extends React.Component {
136
136
  selectTrailingLayer.options[0].disabled = true;
137
137
  }
138
138
  let cl = JSON.parse(sessionStorage.getItem('checkedLayers'));
139
- if (cl) {
139
+ if (
140
+ (!cl || cl.length === 0) &&
141
+ this.map &&
142
+ this.map.layers &&
143
+ this.map.layers.items.length > 0
144
+ ) {
145
+ cl = [];
146
+ // Find the layer ID in this.layers that corresponds to each map.layers item
147
+ for (const mapLayer of this.map.layers.items) {
148
+ for (const [layerKey, layerObj] of Object.entries(this.layers)) {
149
+ if (layerObj.id === mapLayer.id) {
150
+ cl.push(layerKey);
151
+ break;
152
+ }
153
+ }
154
+ }
155
+
156
+ // Save the newly created checkedLayers to sessionStorage
157
+ if (cl.length > 0) {
158
+ sessionStorage.setItem('checkedLayers', JSON.stringify(cl));
159
+ }
160
+ }
161
+
162
+ // Process the layers
163
+ if (cl && cl.length > 0) {
140
164
  cl.forEach((layer) => {
141
165
  if (this.layers[layer]) {
142
166
  let layerId = this.layers[layer].id;
@@ -128,20 +128,37 @@ class UploadWidget extends React.Component {
128
128
  this.setState({ wmsServiceUrl: event.target.value });
129
129
  };
130
130
 
131
- handleUploadService = () => {
131
+ handleUploadService = async () => {
132
132
  const { wmsServiceUrl } = this.state;
133
+ try {
134
+ // Use a CORS proxy or add mode: 'no-cors' if you just need to check if service exists
135
+ let urlResult = await fetch(wmsServiceUrl, {
136
+ method: 'GET',
137
+ mode: 'cors', // You might need to change this to 'no-cors' if proxy isn't available
138
+ });
133
139
 
140
+ // Check if service is valid and properly responds
141
+ if (!urlResult || !urlResult.ok) {
142
+ this.errorPopup();
143
+ this.setState({ wmsServiceUrl: '' });
144
+ return;
145
+ }
146
+ } catch (error) {
147
+ this.errorPopup();
148
+ this.setState({ wmsServiceUrl: '' });
149
+ return;
150
+ }
151
+ // If service is valid and is a WMS service
134
152
  if (
135
153
  wmsServiceUrl &&
136
154
  wmsServiceUrl.trim() !== '' &&
137
155
  wmsServiceUrl.toLowerCase().includes('wms')
138
156
  ) {
139
157
  this.uploadUrlServiceHandler(wmsServiceUrl);
140
- this.setState({
141
- wmsServiceUrl: '',
142
- });
158
+ this.setState({ wmsServiceUrl: '' });
143
159
  } else {
144
160
  this.errorPopup();
161
+ this.setState({ wmsServiceUrl: '' });
145
162
  }
146
163
  };
147
164