@eeacms/volto-arcgis-block 0.1.220 → 0.1.221
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 +11 -0
- package/package.json +1 -1
- package/src/components/MapViewer/HotspotWidget.jsx +190 -169
- package/src/components/MapViewer/LegendWidget.jsx +36 -10
- package/src/components/MapViewer/LoadingSpinner.jsx +49 -11
- package/src/components/MapViewer/MapViewer.jsx +11 -3
- package/src/components/MapViewer/MenuWidget.jsx +146 -67
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.221](https://github.com/eea/volto-arcgis-block/compare/0.1.220...0.1.221) - 25 October 2023
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- final lint check before push [ujbolivar - [`f6835d2`](https://github.com/eea/volto-arcgis-block/commit/f6835d2ed53d0e600918a05b6a6da1f064395968)]
|
|
12
|
+
- hotspot tabs swaps order based on active layers tab order [ujbolivar - [`4989ddb`](https://github.com/eea/volto-arcgis-block/commit/4989ddb4ebbb6b6097d6d5ebb8aeb66cb132f924)]
|
|
13
|
+
- activelayers are arranged following menu order. Position of dragged layers is preserved [ujbolivar - [`d4cd100`](https://github.com/eea/volto-arcgis-block/commit/d4cd10054bc33a7772a0acbaa059e6e215743c67)]
|
|
14
|
+
- mods done to hotspot and legends again to cover new edgecases [ujbolivar - [`957971f`](https://github.com/eea/volto-arcgis-block/commit/957971fc619283d2ebb7317cf519bacbfebec44e)]
|
|
15
|
+
- hotspot and legend functions working properly [ujbolivar - [`21cafd8`](https://github.com/eea/volto-arcgis-block/commit/21cafd83333bbb4495f276e6cbc7c537b7d26470)]
|
|
16
|
+
- Completed: CLMS-2678, CLMS-2663, CLMS-1985, CLMS-2400, CLMS-2678 [ujbolivar - [`fd78b38`](https://github.com/eea/volto-arcgis-block/commit/fd78b381de7772cff70eef7fb480a4af5f03e539)]
|
|
17
|
+
- hotspot layers are added and removed correctly, still needs a bit of fine tuning, but definitely on track now [ujbolivar - [`1835b08`](https://github.com/eea/volto-arcgis-block/commit/1835b08daa1f4d9ce26d103d783b944e074059da)]
|
|
7
18
|
### [0.1.220](https://github.com/eea/volto-arcgis-block/compare/0.1.219...0.1.220) - 24 October 2023
|
|
8
19
|
|
|
9
20
|
### [0.1.219](https://github.com/eea/volto-arcgis-block/compare/0.1.218...0.1.219) - 24 October 2023
|
package/package.json
CHANGED
|
@@ -17,6 +17,10 @@ class HotspotWidget extends React.Component {
|
|
|
17
17
|
this.state = {
|
|
18
18
|
showMapMenu: false,
|
|
19
19
|
activeLayers: {},
|
|
20
|
+
selectedArea: null,
|
|
21
|
+
lcYear: null,
|
|
22
|
+
lccYear: null,
|
|
23
|
+
activeLayersArray: [],
|
|
20
24
|
};
|
|
21
25
|
this.menuClass =
|
|
22
26
|
'esri-icon-filter esri-widget--button esri-widget esri-interactive';
|
|
@@ -40,12 +44,15 @@ class HotspotWidget extends React.Component {
|
|
|
40
44
|
this.layerModelInit = this.layerModelInit.bind(this);
|
|
41
45
|
this.getBBoxData = this.getBBoxData.bind(this);
|
|
42
46
|
this.handleApplyFilter = this.handleApplyFilter.bind(this);
|
|
47
|
+
this.filteredLayersToHotspotData = this.filteredLayersToHotspotData.bind(
|
|
48
|
+
this,
|
|
49
|
+
);
|
|
43
50
|
this.mapCfg = this.props.mapCfg;
|
|
44
|
-
//this.getLayerParameters();
|
|
45
51
|
this.selectedArea = null;
|
|
46
52
|
this.lcYear = null;
|
|
47
53
|
this.lccYear = null;
|
|
48
54
|
this.urls = this.props.urls;
|
|
55
|
+
this.layers = this.props.selectedLayers;
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
loader() {
|
|
@@ -184,65 +191,24 @@ class HotspotWidget extends React.Component {
|
|
|
184
191
|
|
|
185
192
|
async handleApplyFilter(typeFilter) {
|
|
186
193
|
let typeLegend;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
var currentLcLayer = Object.keys(this.props.selectedLayers).find((e) =>
|
|
198
|
-
e.includes('lc_filter'),
|
|
199
|
-
);
|
|
200
|
-
if (currentLcLayer) delete this.props.selectedLayers[currentLcLayer];
|
|
201
|
-
|
|
202
|
-
var currentKlcLayer = Object.keys(this.props.selectedLayers).find((e) =>
|
|
203
|
-
e.includes('klc_filter'),
|
|
204
|
-
);
|
|
205
|
-
if (currentKlcLayer) delete this.props.selectedLayers[currentKlcLayer];
|
|
194
|
+
let activeLayers =
|
|
195
|
+
this.props.hotspotData && this.props.hotspotData['activeLayers']
|
|
196
|
+
? Object.keys(this.props.hotspotData['activeLayers'])
|
|
197
|
+
: [];
|
|
198
|
+
let filteredLayers =
|
|
199
|
+
this.props.hotspotData && this.props.hotspotData['filteredLayers']
|
|
200
|
+
? Object.keys(this.props.hotspotData['filteredLayers'])
|
|
201
|
+
: [];
|
|
202
|
+
let layersToAdd = {};
|
|
206
203
|
|
|
207
|
-
var currentPaLayer = Object.keys(this.props.selectedLayers).find((e) =>
|
|
208
|
-
e.includes('pa_filter'),
|
|
209
|
-
);
|
|
210
|
-
if (currentPaLayer) delete this.props.selectedLayers[currentPaLayer];
|
|
211
|
-
|
|
212
|
-
var currentLcckey = Object.keys(this.props.selectedLayers).find((e) =>
|
|
213
|
-
e.includes('all_lcc'),
|
|
214
|
-
);
|
|
215
|
-
var currentLckey = Object.keys(this.props.selectedLayers).find((e) =>
|
|
216
|
-
e.includes('all_present_lc'),
|
|
217
|
-
);
|
|
218
|
-
var currentKlckey = Object.keys(this.props.selectedLayers).find((e) =>
|
|
219
|
-
e.includes('cop_klc'),
|
|
220
|
-
);
|
|
221
|
-
var currentPakey = Object.keys(this.props.selectedLayers).find((e) =>
|
|
222
|
-
e.includes('protected_areas'),
|
|
223
|
-
);
|
|
224
|
-
if (currentLcckey) {
|
|
225
|
-
//this.props.map.remove(this.props.selectedLayers[currentLcckey]);
|
|
226
|
-
this.props.selectedLayers[currentLcckey].visible = false;
|
|
227
|
-
}
|
|
228
|
-
if (currentLckey) {
|
|
229
|
-
//this.props.map.remove(this.props.selectedLayers[currentLckey]);
|
|
230
|
-
this.props.selectedLayers[currentLckey].visible = false;
|
|
231
|
-
}
|
|
232
|
-
if (currentKlckey) {
|
|
233
|
-
//this.props.map.remove(this.props.selectedLayers[currentKlckey]);
|
|
234
|
-
this.props.selectedLayers[currentKlckey].visible = false;
|
|
235
|
-
}
|
|
236
|
-
if (currentPakey) {
|
|
237
|
-
//this.props.map.remove(this.props.selectedLayers[currentPakey]);
|
|
238
|
-
this.props.selectedLayers[currentPakey].visible = false;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
204
|
typeFilter.forEach((type) => {
|
|
205
|
+
let filterLayer;
|
|
206
|
+
|
|
242
207
|
if (type === 'lcc') {
|
|
243
208
|
let selectLccBoxTime = document.getElementById('select-klc-lccTime')
|
|
244
209
|
.value;
|
|
245
|
-
this.lccYear = selectLccBoxTime;
|
|
210
|
+
//this.lccYear = selectLccBoxTime;
|
|
211
|
+
this.setState({ lccYear: selectLccBoxTime });
|
|
246
212
|
var selectBoxHighlightsLcc = document
|
|
247
213
|
.getElementById('select-klc-lccTime')
|
|
248
214
|
.value.match(/\d+/g)
|
|
@@ -258,30 +224,19 @@ class HotspotWidget extends React.Component {
|
|
|
258
224
|
}
|
|
259
225
|
}
|
|
260
226
|
|
|
261
|
-
|
|
262
|
-
if (this.esriLayer_lcc2 !== null) {
|
|
263
|
-
this.props.map.remove(this.esriLayer_lcc2);
|
|
264
|
-
}
|
|
227
|
+
filterLayer = this.esriLayer_lcc;
|
|
265
228
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
" AND in_pa = 'not_defined' AND date = " +
|
|
278
|
-
selectBoxHighlightsLcc;
|
|
279
|
-
this.props.map.add(this.esriLayer_lcc);
|
|
280
|
-
this.props.selectedLayers['lcc_filter'] = this.esriLayer_lcc;
|
|
281
|
-
this.props.selectedLayers['lcc_filter'].visible = true;
|
|
282
|
-
this.esriLayer_lcc2 = this.esriLayer_lcc;
|
|
283
|
-
//this.layerModelInit();
|
|
284
|
-
}
|
|
229
|
+
filterLayer.sublayers.items[0].name = this.addLegendName(typeLegend);
|
|
230
|
+
filterLayer.sublayers.items[0].legendUrl = this.addLegendNameToUrl(
|
|
231
|
+
typeLegend,
|
|
232
|
+
);
|
|
233
|
+
filterLayer.customLayerParameters['CQL_FILTER'] =
|
|
234
|
+
'klc_code LIKE ' +
|
|
235
|
+
"'" +
|
|
236
|
+
this.dataKlc_code +
|
|
237
|
+
"'" +
|
|
238
|
+
" AND in_pa = 'not_defined' AND date = " +
|
|
239
|
+
selectBoxHighlightsLcc;
|
|
285
240
|
}
|
|
286
241
|
if (type === 'lc') {
|
|
287
242
|
for (let i = 0; i < activeLayers.length; i++) {
|
|
@@ -296,80 +251,94 @@ class HotspotWidget extends React.Component {
|
|
|
296
251
|
|
|
297
252
|
let selectLcBoxTime = document.getElementById('select-klc-lcTime')
|
|
298
253
|
.value;
|
|
299
|
-
this.lcYear = selectLcBoxTime;
|
|
254
|
+
//this.lcYear = selectLcBoxTime;
|
|
255
|
+
this.setState({ lcYear: selectLcBoxTime });
|
|
300
256
|
var selectBoxHighlightsLc = document
|
|
301
257
|
.getElementById('select-klc-lcTime')
|
|
302
258
|
.value.match(/\d+/g)
|
|
303
259
|
.map(Number)[0];
|
|
304
260
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
this.dataKlc_code +
|
|
319
|
-
"'" +
|
|
320
|
-
" AND in_pa = 'not_defined' AND date = " +
|
|
321
|
-
selectBoxHighlightsLc;
|
|
322
|
-
this.props.map.add(this.esriLayer_lc);
|
|
323
|
-
this.props.selectedLayers['lc_filter'] = this.esriLayer_lc;
|
|
324
|
-
this.props.selectedLayers['lc_filter'].visible = true;
|
|
325
|
-
this.esriLayer_lc2 = this.esriLayer_lc;
|
|
326
|
-
}
|
|
261
|
+
filterLayer = this.esriLayer_lc;
|
|
262
|
+
|
|
263
|
+
filterLayer.sublayers.items[0].name = this.addLegendName(typeLegend);
|
|
264
|
+
filterLayer.sublayers.items[0].legendUrl = this.addLegendNameToUrl(
|
|
265
|
+
typeLegend,
|
|
266
|
+
);
|
|
267
|
+
filterLayer.customLayerParameters['CQL_FILTER'] =
|
|
268
|
+
'klc_code LIKE ' +
|
|
269
|
+
"'" +
|
|
270
|
+
this.dataKlc_code +
|
|
271
|
+
"'" +
|
|
272
|
+
" AND in_pa = 'not_defined' AND date = " +
|
|
273
|
+
selectBoxHighlightsLc;
|
|
327
274
|
}
|
|
328
|
-
this.esriLayer_klc.customLayerParameters['CQL_FILTER'] =
|
|
329
|
-
"klc_code LIKE '" + this.dataKlc_code + "'";
|
|
330
|
-
this.props.selectedLayers['klc_filter'] = this.esriLayer_klc;
|
|
331
275
|
if (type === 'klc') {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
this.props.map.add(this.esriLayer_klc);
|
|
337
|
-
this.props.selectedLayers['klc_filter'].visible = true;
|
|
338
|
-
this.esriLayer_klc2 = this.esriLayer_klc;
|
|
339
|
-
//this.layerModelInit();
|
|
340
|
-
}
|
|
276
|
+
this.esriLayer_klc.customLayerParameters['CQL_FILTER'] =
|
|
277
|
+
"klc_code LIKE '" + this.dataKlc_code + "'";
|
|
278
|
+
filterLayer = this.esriLayer_klc;
|
|
341
279
|
}
|
|
342
|
-
this.esriLayer_pa.customLayerParameters['CQL_FILTER'] =
|
|
343
|
-
"klc_code LIKE '" + this.dataKlc_code + "'";
|
|
344
|
-
this.props.selectedLayers['pa_filter'] = this.esriLayer_pa;
|
|
345
280
|
if (type === 'pa') {
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
281
|
+
this.esriLayer_pa.customLayerParameters['CQL_FILTER'] =
|
|
282
|
+
"klc_code LIKE '" + this.dataKlc_code + "'";
|
|
283
|
+
filterLayer = this.esriLayer_pa;
|
|
284
|
+
}
|
|
285
|
+
layersToAdd[type + '_filter'] = filterLayer;
|
|
286
|
+
});
|
|
287
|
+
activeLayers.forEach((activeLayer) => {
|
|
288
|
+
let layerId = Object.keys(this.layers).find((key) =>
|
|
289
|
+
key.includes(activeLayer),
|
|
290
|
+
);
|
|
291
|
+
if (layerId !== undefined) this.layers[layerId].visible = false;
|
|
292
|
+
let layer = this.props.map.findLayerById(layerId);
|
|
293
|
+
if (layer !== undefined) {
|
|
294
|
+
layer.clear();
|
|
295
|
+
layer.destroy();
|
|
296
|
+
this.props.map.remove(layer);
|
|
355
297
|
}
|
|
356
|
-
this.layerModelInit();
|
|
357
|
-
this.setBBoxCoordinates(this.dataBBox);
|
|
358
|
-
//this.setState({ activeLayers: {[type+'_filter']: this.props.selectedLayers[type+'_filter']}})
|
|
359
298
|
});
|
|
299
|
+
filteredLayers.forEach((filteredLayer) => {
|
|
300
|
+
let layerId = Object.keys(this.layers).find((key) =>
|
|
301
|
+
key.includes(filteredLayer),
|
|
302
|
+
);
|
|
303
|
+
if (layerId !== undefined) this.layers[layerId].visible = false;
|
|
304
|
+
let layer = this.props.map.findLayerById(layerId);
|
|
305
|
+
if (layer !== undefined) {
|
|
306
|
+
layer.clear();
|
|
307
|
+
layer.destroy();
|
|
308
|
+
this.props.map.remove(layer);
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
this.props.map.addMany(Object.values(layersToAdd));
|
|
312
|
+
Object.keys(layersToAdd).forEach((key) => {
|
|
313
|
+
this.layers[key] = layersToAdd[key];
|
|
314
|
+
this.layers[key].visible = true;
|
|
315
|
+
});
|
|
316
|
+
this.setBBoxCoordinates(this.dataBBox);
|
|
360
317
|
//set sessionStorage value to keep the widget open
|
|
361
318
|
sessionStorage.setItem('hotspotFilterApplied', 'true');
|
|
362
319
|
this.disableButton();
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
320
|
+
this.props.mapLayersHandler(this.layers);
|
|
321
|
+
this.filteredLayersToHotspotData(Object.keys(layersToAdd));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
filteredLayersToHotspotData(layerIds) {
|
|
325
|
+
let updatedFilteredLayers = this.props.hotspotData['filteredLayers'] || {};
|
|
326
|
+
let newHotspotData = this.props.hotspotData;
|
|
327
|
+
layerIds.forEach((layerId) => {
|
|
328
|
+
let layer = Object.entries(this.layers).find(
|
|
329
|
+
([key, value]) => key === layerId,
|
|
330
|
+
)?.[1];
|
|
331
|
+
|
|
332
|
+
Object.keys(updatedFilteredLayers).forEach((key) => {
|
|
333
|
+
if (key === layerId) {
|
|
334
|
+
delete updatedFilteredLayers[key];
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
updatedFilteredLayers[layerId] = layer;
|
|
372
339
|
});
|
|
340
|
+
newHotspotData['filteredLayers'] = updatedFilteredLayers;
|
|
341
|
+
return this.props.hotspotDataHandler(newHotspotData);
|
|
373
342
|
}
|
|
374
343
|
|
|
375
344
|
dropdownAnimation() {
|
|
@@ -389,7 +358,6 @@ class HotspotWidget extends React.Component {
|
|
|
389
358
|
|
|
390
359
|
openMenu() {
|
|
391
360
|
if (this.state.showMapMenu) {
|
|
392
|
-
//this.getKLCNames(this.dataJSONNames, this.selectedArea);
|
|
393
361
|
this.props.mapViewer.setActiveWidget();
|
|
394
362
|
this.container.current.querySelector('.right-panel').style.display =
|
|
395
363
|
'none';
|
|
@@ -403,9 +371,6 @@ class HotspotWidget extends React.Component {
|
|
|
403
371
|
// and ensure that the component is rendered again
|
|
404
372
|
this.setState({ showMapMenu: false });
|
|
405
373
|
} else {
|
|
406
|
-
//this.getLayerParameters();
|
|
407
|
-
//if (this.getLayerParameters.length !== 0)
|
|
408
|
-
//this.getKLCNames(this.dataJSONNames, this.selectedArea);
|
|
409
374
|
this.props.mapViewer.setActiveWidget(this);
|
|
410
375
|
this.container.current.querySelector('.right-panel').style.display =
|
|
411
376
|
'flex';
|
|
@@ -432,9 +397,6 @@ class HotspotWidget extends React.Component {
|
|
|
432
397
|
})
|
|
433
398
|
.then((data) => {
|
|
434
399
|
this.dataJSONNames = data.nodes;
|
|
435
|
-
//if (this.selectedArea == null) {
|
|
436
|
-
// this.selectedArea = data.nodes[0].node.klc_name;
|
|
437
|
-
//}
|
|
438
400
|
})
|
|
439
401
|
.catch(function (error) {
|
|
440
402
|
/* console.log('error while getting data'); */
|
|
@@ -475,6 +437,7 @@ class HotspotWidget extends React.Component {
|
|
|
475
437
|
let lccContainer = document.querySelector('.landCoverChangeContainer');
|
|
476
438
|
let lccTimeSelect = document.querySelector('#select-klc-lccTime');
|
|
477
439
|
let lcTimeSelect = document.querySelector('#select-klc-lcTime');
|
|
440
|
+
if (lcContainer === null || lccContainer === null) return;
|
|
478
441
|
if (
|
|
479
442
|
(lcContainer.style.display === 'block' &&
|
|
480
443
|
lcTimeSelect.value === 'default') ||
|
|
@@ -541,12 +504,14 @@ class HotspotWidget extends React.Component {
|
|
|
541
504
|
selectBoxLccTime = document.getElementById('select-klc-lccTime');
|
|
542
505
|
selectBoxLcTime = document.getElementById('select-klc-lcTime');
|
|
543
506
|
|
|
544
|
-
if (selectedOption !== this.selectedArea) {
|
|
545
|
-
this.
|
|
546
|
-
|
|
507
|
+
if (selectedOption !== this.state.selectedArea) {
|
|
508
|
+
this.setState({
|
|
509
|
+
lcYear: null,
|
|
510
|
+
lccYear: null,
|
|
511
|
+
});
|
|
547
512
|
}
|
|
548
513
|
|
|
549
|
-
this.selectedArea = selectedOption;
|
|
514
|
+
//this.selectedArea = selectedOption;
|
|
550
515
|
|
|
551
516
|
for (let i = 0; i < data.length; i++) {
|
|
552
517
|
var option = data[i].node.klc_name;
|
|
@@ -632,16 +597,16 @@ class HotspotWidget extends React.Component {
|
|
|
632
597
|
selectBox.options.add(new Option(option, option, option));
|
|
633
598
|
}
|
|
634
599
|
for (let u = 0; u < selectBox.options.length; u++) {
|
|
635
|
-
if (!selectBox.options[u].label.includes(this.selectedArea)) {
|
|
600
|
+
if (!selectBox.options[u].label.includes(this.state.selectedArea)) {
|
|
636
601
|
selectBox.value = 'default';
|
|
637
602
|
continue;
|
|
638
603
|
} else {
|
|
639
|
-
selectBox.value = this.selectedArea;
|
|
640
|
-
if (this.lcYear !== null) {
|
|
641
|
-
selectBoxLcTime.value = this.lcYear;
|
|
604
|
+
selectBox.value = this.state.selectedArea;
|
|
605
|
+
if (this.state.lcYear !== null) {
|
|
606
|
+
selectBoxLcTime.value = this.state.lcYear;
|
|
642
607
|
}
|
|
643
|
-
if (this.lccYear !== null) {
|
|
644
|
-
selectBoxLccTime.value = this.lccYear;
|
|
608
|
+
if (this.state.lccYear !== null) {
|
|
609
|
+
selectBoxLccTime.value = this.state.lccYear;
|
|
645
610
|
}
|
|
646
611
|
break; // move break statement inside the if block
|
|
647
612
|
}
|
|
@@ -656,18 +621,18 @@ class HotspotWidget extends React.Component {
|
|
|
656
621
|
selectBox.options.add(new Option(option, option, option));
|
|
657
622
|
}
|
|
658
623
|
for (let u = 0; u < selectBox.options.length; u++) {
|
|
659
|
-
if (!selectBox.options[u].label.includes(this.selectedArea)) {
|
|
624
|
+
if (!selectBox.options[u].label.includes(this.state.selectedArea)) {
|
|
660
625
|
selectBox.value = 'default';
|
|
661
626
|
continue;
|
|
662
627
|
} else {
|
|
663
|
-
selectBox.value = this.selectedArea;
|
|
664
|
-
if (this.lcYear !== null) {
|
|
665
|
-
selectBoxLcTime.value = this.lcYear;
|
|
628
|
+
selectBox.value = this.state.selectedArea;
|
|
629
|
+
if (this.state.lcYear !== null) {
|
|
630
|
+
selectBoxLcTime.value = this.state.lcYear;
|
|
666
631
|
}
|
|
667
|
-
if (this.lccYear !== null) {
|
|
668
|
-
selectBoxLccTime.value = this.lccYear;
|
|
632
|
+
if (this.state.lccYear !== null) {
|
|
633
|
+
selectBoxLccTime.value = this.state.lccYear;
|
|
669
634
|
}
|
|
670
|
-
break;
|
|
635
|
+
break;
|
|
671
636
|
}
|
|
672
637
|
}
|
|
673
638
|
break;
|
|
@@ -738,6 +703,29 @@ class HotspotWidget extends React.Component {
|
|
|
738
703
|
}
|
|
739
704
|
|
|
740
705
|
render() {
|
|
706
|
+
let divs = [
|
|
707
|
+
{
|
|
708
|
+
id: 'all_present_lc',
|
|
709
|
+
func: this.renderPresentLandCover,
|
|
710
|
+
className: 'presentLandCoverContainer',
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
id: 'all_lcc',
|
|
714
|
+
func: this.renderLandCoverChange,
|
|
715
|
+
className: 'landCoverChangeContainer',
|
|
716
|
+
},
|
|
717
|
+
];
|
|
718
|
+
|
|
719
|
+
divs.sort((a, b) => {
|
|
720
|
+
let indexA = this.state.activeLayersArray.findIndex((layer) =>
|
|
721
|
+
layer.getAttribute('layer-id').includes(a.id),
|
|
722
|
+
);
|
|
723
|
+
let indexB = this.state.activeLayersArray.findIndex((layer) =>
|
|
724
|
+
layer.getAttribute('layer-id').includes(b.id),
|
|
725
|
+
);
|
|
726
|
+
if (indexA === -1 || indexB === -1) return 0;
|
|
727
|
+
return indexA - indexB;
|
|
728
|
+
});
|
|
741
729
|
return (
|
|
742
730
|
<>
|
|
743
731
|
<div ref={this.container} className="hotspot-container">
|
|
@@ -772,8 +760,7 @@ class HotspotWidget extends React.Component {
|
|
|
772
760
|
<select
|
|
773
761
|
onBlur={() => {}}
|
|
774
762
|
onChange={(e) => {
|
|
775
|
-
this.
|
|
776
|
-
this.disableButton();
|
|
763
|
+
this.setState({ selectedArea: e.target.value });
|
|
777
764
|
}}
|
|
778
765
|
id="select-klc-area"
|
|
779
766
|
className="esri-select"
|
|
@@ -781,11 +768,10 @@ class HotspotWidget extends React.Component {
|
|
|
781
768
|
</label>
|
|
782
769
|
</div>
|
|
783
770
|
</div>
|
|
784
|
-
<div
|
|
785
|
-
{
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
{this.renderLandCoverChange()}
|
|
771
|
+
<div>
|
|
772
|
+
{divs.map((div) => (
|
|
773
|
+
<div className={div.className}>{div.func()}</div>
|
|
774
|
+
))}
|
|
789
775
|
</div>
|
|
790
776
|
<button
|
|
791
777
|
id="applyFilterButton"
|
|
@@ -802,6 +788,31 @@ class HotspotWidget extends React.Component {
|
|
|
802
788
|
);
|
|
803
789
|
}
|
|
804
790
|
|
|
791
|
+
//sortHotspotTabs = () => {
|
|
792
|
+
// let activeLayersArray = Array.from(document.querySelectorAll('.active-layer'));
|
|
793
|
+
// let divs = [
|
|
794
|
+
// { id: 'all_present_lc', func: this.renderPresentLandCover, className: 'presentLandCoverContainer' },
|
|
795
|
+
// { id: 'all_lcc', func: this.renderLandCoverChange, className: 'landCoverChangeContainer' }
|
|
796
|
+
// ];
|
|
797
|
+
//
|
|
798
|
+
// divs.sort((a, b) => {
|
|
799
|
+
// let indexA = activeLayersArray.findIndex(layer => layer.getAttribute('layer-id').includes(a.id));
|
|
800
|
+
// let indexB = activeLayersArray.findIndex(layer => layer.getAttribute('layer-id').includes(b.id));
|
|
801
|
+
// if (indexA === -1 || indexB === -1) return 0;
|
|
802
|
+
// return indexA - indexB;
|
|
803
|
+
// });
|
|
804
|
+
//
|
|
805
|
+
// return (
|
|
806
|
+
// <div>
|
|
807
|
+
// {divs.map(div => (
|
|
808
|
+
// <div className={div.className}>
|
|
809
|
+
// {div.func()}
|
|
810
|
+
// </div>
|
|
811
|
+
// ))}
|
|
812
|
+
// </div>
|
|
813
|
+
// );
|
|
814
|
+
//}
|
|
815
|
+
|
|
805
816
|
/**
|
|
806
817
|
* This method is executed after the rener method is executed
|
|
807
818
|
*/
|
|
@@ -811,12 +822,22 @@ class HotspotWidget extends React.Component {
|
|
|
811
822
|
this.props.view.ui.add(this.container.current, 'top-right');
|
|
812
823
|
this.layerModelInit();
|
|
813
824
|
this.getBBoxData();
|
|
825
|
+
this.props.view.map.layers.on('change', () => {
|
|
826
|
+
this.setState({
|
|
827
|
+
activeLayersArray: Array.from(
|
|
828
|
+
document.querySelectorAll('.active-layer'),
|
|
829
|
+
),
|
|
830
|
+
});
|
|
831
|
+
const newHotspotData = this.props.hotspotData;
|
|
832
|
+
this.props.hotspotDataHandler(newHotspotData);
|
|
833
|
+
});
|
|
814
834
|
}
|
|
815
835
|
|
|
816
836
|
componentDidUpdate(prevState, prevProps) {
|
|
817
837
|
if (prevProps.hotspotData !== this.props.hotspotData) {
|
|
818
|
-
this.getKLCNames(this.dataJSONNames, this.selectedArea);
|
|
838
|
+
this.getKLCNames(this.dataJSONNames, this.state.selectedArea);
|
|
819
839
|
this.disableButton();
|
|
840
|
+
//this.layerModelInit();
|
|
820
841
|
}
|
|
821
842
|
}
|
|
822
843
|
}
|
|
@@ -45,6 +45,25 @@ class LegendWidget extends React.Component {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
scanImages() {
|
|
49
|
+
let img = {};
|
|
50
|
+
const collection = document.getElementsByClassName('esri-legend__symbol');
|
|
51
|
+
Array.prototype.forEach.call(collection, (element) => {
|
|
52
|
+
if (element.hasChildNodes()) {
|
|
53
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
54
|
+
let child = element.childNodes[i];
|
|
55
|
+
if (child.nodename === 'IMG') {
|
|
56
|
+
img = child;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} else img = element;
|
|
61
|
+
if (!(img instanceof HTMLImageElement)) return;
|
|
62
|
+
|
|
63
|
+
img.onerror = () => this.setState({ loading: true });
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
48
67
|
brokenLegendImagePatch() {
|
|
49
68
|
const collection = document.getElementsByClassName('esri-legend__symbol');
|
|
50
69
|
Array.prototype.forEach.call(collection, (element) => {
|
|
@@ -176,11 +195,6 @@ class LegendWidget extends React.Component {
|
|
|
176
195
|
}
|
|
177
196
|
|
|
178
197
|
imageFixWithTimer() {
|
|
179
|
-
let newHotspotData = this.props.hotspotData;
|
|
180
|
-
if (this.props.hotspotData?.layerViewError !== undefined) {
|
|
181
|
-
delete newHotspotData['layerViewError'];
|
|
182
|
-
}
|
|
183
|
-
this.props.hotspotDataHandler(newHotspotData);
|
|
184
198
|
this.setState({ loading: true });
|
|
185
199
|
setTimeout(() => {
|
|
186
200
|
this.brokenLegendImagePatch();
|
|
@@ -204,16 +218,28 @@ class LegendWidget extends React.Component {
|
|
|
204
218
|
}),
|
|
205
219
|
container: document.querySelector('.legend-panel'),
|
|
206
220
|
});
|
|
207
|
-
this.
|
|
208
|
-
this.
|
|
221
|
+
this.LegendWidget.when(() => {
|
|
222
|
+
this.LegendWidget.activeLayerInfos.on('after-changes', (event) => {
|
|
223
|
+
this.setState({ loading: true });
|
|
224
|
+
this.scanImages();
|
|
225
|
+
});
|
|
209
226
|
});
|
|
210
227
|
}
|
|
211
228
|
|
|
212
|
-
componentDidUpdate(prevProps) {
|
|
213
|
-
if (
|
|
214
|
-
this.
|
|
229
|
+
componentDidUpdate(prevState, prevProps) {
|
|
230
|
+
if (prevState.loading !== this.state.loading) {
|
|
231
|
+
if (this.state.loading === true) {
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
this.brokenLegendImagePatch();
|
|
234
|
+
if (this.props.download) {
|
|
235
|
+
this.hideNutsLegend();
|
|
236
|
+
}
|
|
237
|
+
this.setState({ loading: false });
|
|
238
|
+
}, 2000);
|
|
239
|
+
}
|
|
215
240
|
}
|
|
216
241
|
}
|
|
242
|
+
|
|
217
243
|
/**
|
|
218
244
|
* This method renders the component
|
|
219
245
|
* @returns jsx
|
|
@@ -9,7 +9,11 @@ class LoadingSpinner extends React.Component {
|
|
|
9
9
|
this.container = createRef();
|
|
10
10
|
//Initially, we set the state of the component to
|
|
11
11
|
//not be showing the basemap panel
|
|
12
|
-
this.state = {
|
|
12
|
+
this.state = {
|
|
13
|
+
loading: false,
|
|
14
|
+
};
|
|
15
|
+
this.showLoading = this.showLoading.bind(this);
|
|
16
|
+
this.listenForLayerChanges = this.listenForLayerChanges.bind(this);
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
loader() {
|
|
@@ -18,8 +22,38 @@ class LoadingSpinner extends React.Component {
|
|
|
18
22
|
});
|
|
19
23
|
}
|
|
20
24
|
|
|
25
|
+
listenForLayerChanges() {
|
|
26
|
+
this.props.view.map.layers.on('change', (event) => {
|
|
27
|
+
if (event.added.length > 0)
|
|
28
|
+
if (this.state.loading === false) {
|
|
29
|
+
this.setState({ loading: true });
|
|
30
|
+
this.showLoading();
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
this.props.view.on('layerview-create', (event) => {
|
|
34
|
+
if (event.layer.loadStatus === 'loaded') {
|
|
35
|
+
this.props.view.watch('updating', (isUpdating) => {
|
|
36
|
+
if (!isUpdating) {
|
|
37
|
+
if (this.state.loading === true) {
|
|
38
|
+
this.setState({ loading: false });
|
|
39
|
+
this.showLoading();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
this.props.view.on('layerview-create-error', (event) => {
|
|
46
|
+
if (event.layer.loadError !== null) {
|
|
47
|
+
if (this.state.loading === true) {
|
|
48
|
+
this.setState({ loading: false });
|
|
49
|
+
this.showLoading();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
21
55
|
showLoading() {
|
|
22
|
-
if (this.
|
|
56
|
+
if (this.state.loading === false) {
|
|
23
57
|
this.container.current.style.display = 'none';
|
|
24
58
|
} else {
|
|
25
59
|
this.container.current.style.display = 'block';
|
|
@@ -29,18 +63,22 @@ class LoadingSpinner extends React.Component {
|
|
|
29
63
|
|
|
30
64
|
async componentDidMount() {
|
|
31
65
|
await this.loader();
|
|
32
|
-
this.props.view.when(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
66
|
+
//this.props.view.when(() => {
|
|
67
|
+
// this.props.view.ui.add(this.container.current, 'manual');
|
|
68
|
+
// this.listenForLayerChanges();
|
|
69
|
+
//});
|
|
70
|
+
watchUtils.when(this.props.view, 'ready', (isReady) => {
|
|
71
|
+
if (isReady) {
|
|
72
|
+
this.props.view.ui.add(this.container.current, 'manual');
|
|
73
|
+
this.listenForLayerChanges();
|
|
74
|
+
}
|
|
37
75
|
});
|
|
38
76
|
}
|
|
39
77
|
|
|
40
|
-
componentDidUpdate(
|
|
41
|
-
if (this.
|
|
42
|
-
this.showLoading();
|
|
43
|
-
}
|
|
78
|
+
componentDidUpdate(prevState) {
|
|
79
|
+
// if (this.state.loading !== prevState.loading) {
|
|
80
|
+
// this.showLoading();
|
|
81
|
+
// }
|
|
44
82
|
}
|
|
45
83
|
|
|
46
84
|
render() {
|
|
@@ -55,8 +55,8 @@ class MapViewer extends React.Component {
|
|
|
55
55
|
});
|
|
56
56
|
this.state = {
|
|
57
57
|
layerLoading: false,
|
|
58
|
+
layers: {},
|
|
58
59
|
};
|
|
59
|
-
this.layers = {};
|
|
60
60
|
this.activeLayersHandler = this.activeLayersHandler.bind(this);
|
|
61
61
|
this.activeLayersArray = {};
|
|
62
62
|
this.props.mapviewer_config.loading = true;
|
|
@@ -64,6 +64,11 @@ class MapViewer extends React.Component {
|
|
|
64
64
|
this.userID = null;
|
|
65
65
|
this.loadingHandler = this.loadingHandler.bind(this);
|
|
66
66
|
this.hotspotDataHandler = this.hotspotDataHandler.bind(this);
|
|
67
|
+
this.mapLayersHandler = this.mapLayersHandler.bind(this);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
mapLayersHandler(newLayers) {
|
|
71
|
+
this.setState({ layers: newLayers });
|
|
67
72
|
}
|
|
68
73
|
|
|
69
74
|
loadingHandler(bool) {
|
|
@@ -307,6 +312,7 @@ class MapViewer extends React.Component {
|
|
|
307
312
|
mapViewer={this}
|
|
308
313
|
download={this.props.mapviewer_config.Download}
|
|
309
314
|
urls={this.cfgUrls}
|
|
315
|
+
layerLoading={this.state.layerLoading}
|
|
310
316
|
hotspotData={this.state.hotspotData}
|
|
311
317
|
hotspotDataHandler={this.hotspotDataHandler}
|
|
312
318
|
/>
|
|
@@ -364,7 +370,7 @@ class MapViewer extends React.Component {
|
|
|
364
370
|
<HotspotWidget
|
|
365
371
|
view={this.view}
|
|
366
372
|
map={this.map}
|
|
367
|
-
selectedLayers={this.layers}
|
|
373
|
+
selectedLayers={this.state.layers}
|
|
368
374
|
mapViewer={this}
|
|
369
375
|
layers={sessionStorage}
|
|
370
376
|
mapCfg={this.mapCfg}
|
|
@@ -372,6 +378,7 @@ class MapViewer extends React.Component {
|
|
|
372
378
|
loadingHandler={this.loadingHandler}
|
|
373
379
|
hotspotData={this.state.hotspotData}
|
|
374
380
|
hotspotDataHandler={this.hotspotDataHandler}
|
|
381
|
+
mapLayersHandler={this.mapLayersHandler}
|
|
375
382
|
/>
|
|
376
383
|
);
|
|
377
384
|
}
|
|
@@ -388,12 +395,13 @@ class MapViewer extends React.Component {
|
|
|
388
395
|
mapViewer={this}
|
|
389
396
|
updateArea={this.updateArea}
|
|
390
397
|
area={this.state.area}
|
|
391
|
-
layers={this.layers}
|
|
398
|
+
layers={this.state.layers}
|
|
392
399
|
activeLayersHandler={this.activeLayersHandler}
|
|
393
400
|
urls={this.cfgUrls}
|
|
394
401
|
loadingHandler={this.loadingHandler}
|
|
395
402
|
hotspotDataHandler={this.hotspotDataHandler}
|
|
396
403
|
hotspotData={this.state.hotspotData}
|
|
404
|
+
mapLayersHandler={this.mapLayersHandler}
|
|
397
405
|
/>
|
|
398
406
|
); //call conf
|
|
399
407
|
}
|
|
@@ -253,6 +253,7 @@ class MenuWidget extends React.Component {
|
|
|
253
253
|
noServiceModal: true,
|
|
254
254
|
setNoServiceModal: true,
|
|
255
255
|
TMSLayerObj: null,
|
|
256
|
+
draggedElements: [],
|
|
256
257
|
};
|
|
257
258
|
this.menuClass =
|
|
258
259
|
'esri-icon-drag-horizontal esri-widget--button esri-widget esri-interactive';
|
|
@@ -263,6 +264,8 @@ class MenuWidget extends React.Component {
|
|
|
263
264
|
this.xml = null;
|
|
264
265
|
this.dataBBox = null;
|
|
265
266
|
this.extentInitiated = false;
|
|
267
|
+
this.hotspotLayerIds = [];
|
|
268
|
+
this.getHotspotLayerIds = this.getHotspotLayerIds.bind(this);
|
|
266
269
|
this.prepareHotspotLayers = this.prepareHotspotLayers.bind(this);
|
|
267
270
|
this.activeLayersToHotspotData = this.activeLayersToHotspotData.bind(this);
|
|
268
271
|
this.getLimitScale = this.getLimitScale.bind(this);
|
|
@@ -631,7 +634,6 @@ class MenuWidget extends React.Component {
|
|
|
631
634
|
bubbles: true,
|
|
632
635
|
cancelable: false,
|
|
633
636
|
});
|
|
634
|
-
// let el = document.getElementById('active_label');
|
|
635
637
|
let el = document.getElementById('download_label');
|
|
636
638
|
el.dispatchEvent(event);
|
|
637
639
|
}
|
|
@@ -647,6 +649,7 @@ class MenuWidget extends React.Component {
|
|
|
647
649
|
await this.loader();
|
|
648
650
|
await this.getTMSLayersJSON();
|
|
649
651
|
this.prepareHotspotLayers();
|
|
652
|
+
this.getHotspotLayerIds();
|
|
650
653
|
this.props.view.ui.add(this.container.current, 'top-left');
|
|
651
654
|
if (this.props.download) {
|
|
652
655
|
setTimeout(() => {
|
|
@@ -1401,7 +1404,6 @@ class MenuWidget extends React.Component {
|
|
|
1401
1404
|
url: viewService,
|
|
1402
1405
|
featureInfoFormat: 'text/html',
|
|
1403
1406
|
featureInfoUrl: viewService,
|
|
1404
|
-
//id: layer.LayerId,
|
|
1405
1407
|
title: '',
|
|
1406
1408
|
legendEnabled: true,
|
|
1407
1409
|
sublayers: [
|
|
@@ -1559,7 +1561,7 @@ class MenuWidget extends React.Component {
|
|
|
1559
1561
|
const height = this.tileInfo.size[0];
|
|
1560
1562
|
// create a canvas with 2D rendering context
|
|
1561
1563
|
const canvas = document.createElement('canvas');
|
|
1562
|
-
const context = canvas.getContext('2d');
|
|
1564
|
+
const context = canvas.getContext('2d'); //try modifying this value for 3d test UNAI
|
|
1563
1565
|
//canvas
|
|
1564
1566
|
canvas.width = width;
|
|
1565
1567
|
canvas.height = height;
|
|
@@ -1691,16 +1693,6 @@ class MenuWidget extends React.Component {
|
|
|
1691
1693
|
}
|
|
1692
1694
|
}
|
|
1693
1695
|
if (productContainerId === 'd764e020485a402598551fa461bf1db2') {
|
|
1694
|
-
// if (this.layers['lc_filter'] || this.layers['lcc_filter']) {
|
|
1695
|
-
// let myExtent = new Extent({
|
|
1696
|
-
// xmin: -2037508.342789,
|
|
1697
|
-
// ymin: -2037508.342789,
|
|
1698
|
-
// xmax: 8037508.342789,
|
|
1699
|
-
// ymax: 8037508.342789,
|
|
1700
|
-
// spatialReference: 3857, // by default wkid 4326
|
|
1701
|
-
// });
|
|
1702
|
-
// this.view.goTo(myExtent);
|
|
1703
|
-
// }
|
|
1704
1696
|
if (nextElemSibling) {
|
|
1705
1697
|
siblingInput = nextElemSibling.querySelector('input');
|
|
1706
1698
|
} else if (previousElemSibling) {
|
|
@@ -1807,6 +1799,7 @@ class MenuWidget extends React.Component {
|
|
|
1807
1799
|
}
|
|
1808
1800
|
|
|
1809
1801
|
async toggleLayer(elem) {
|
|
1802
|
+
if (this.layers[elem.id] === undefined) return;
|
|
1810
1803
|
if (!this.visibleLayers) this.visibleLayers = {};
|
|
1811
1804
|
if (!this.timeLayers) this.timeLayers = {};
|
|
1812
1805
|
let parentId = elem.getAttribute('parentid');
|
|
@@ -1814,9 +1807,10 @@ class MenuWidget extends React.Component {
|
|
|
1814
1807
|
.getElementById(parentId)
|
|
1815
1808
|
.closest('.map-menu-product-dropdown')
|
|
1816
1809
|
.getAttribute('productid');
|
|
1810
|
+
|
|
1817
1811
|
let group = this.getGroup(elem);
|
|
1818
1812
|
if (elem.checked) {
|
|
1819
|
-
this.props.loadingHandler(true);
|
|
1813
|
+
//this.props.loadingHandler(true);
|
|
1820
1814
|
if (
|
|
1821
1815
|
this.props.download ||
|
|
1822
1816
|
this.location.search.includes('product=') ||
|
|
@@ -1833,20 +1827,25 @@ class MenuWidget extends React.Component {
|
|
|
1833
1827
|
}
|
|
1834
1828
|
}
|
|
1835
1829
|
if (this.layers['lc_filter'] || this.layers['lcc_filter']) {
|
|
1836
|
-
if (
|
|
1830
|
+
if (
|
|
1831
|
+
elem.id.includes('cop_klc') &&
|
|
1832
|
+
this.layers['klc_filter'] !== undefined
|
|
1833
|
+
) {
|
|
1837
1834
|
this.layers['klc_filter'].visible = true;
|
|
1838
1835
|
this.map.add(this.layers['klc_filter']);
|
|
1839
|
-
} else if (
|
|
1836
|
+
} else if (
|
|
1837
|
+
elem.id.includes('protected_areas') &&
|
|
1838
|
+
this.layers['pa_filter'] !== undefined
|
|
1839
|
+
) {
|
|
1840
1840
|
this.layers['pa_filter'].visible = true;
|
|
1841
1841
|
this.map.add(this.layers['pa_filter']);
|
|
1842
1842
|
} else {
|
|
1843
1843
|
this.map.add(this.layers[elem.id]);
|
|
1844
1844
|
}
|
|
1845
1845
|
} else {
|
|
1846
|
+
this.layers[elem.id].visible = true; //layer id
|
|
1846
1847
|
this.map.add(this.layers[elem.id]);
|
|
1847
1848
|
}
|
|
1848
|
-
if (this.layers[elem.id] === undefined) return;
|
|
1849
|
-
this.layers[elem.id].visible = true; //layer id
|
|
1850
1849
|
this.visibleLayers[elem.id] = ['fas', 'eye'];
|
|
1851
1850
|
this.timeLayers[elem.id] = ['far', 'clock'];
|
|
1852
1851
|
if (group) {
|
|
@@ -1872,36 +1871,41 @@ class MenuWidget extends React.Component {
|
|
|
1872
1871
|
if (nuts) {
|
|
1873
1872
|
this.map.reorder(nuts, this.map.layers.items.length + 1);
|
|
1874
1873
|
}
|
|
1875
|
-
this.props.view
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1874
|
+
//this.props.view //mueve esto
|
|
1875
|
+
// .whenLayerView(this.layers[elem.id])
|
|
1876
|
+
// .then((layerView) => {
|
|
1877
|
+
// layerView.watch('updating', (isUpdating) => {
|
|
1878
|
+
// if (!isUpdating) {
|
|
1879
|
+
// setTimeout(() => {
|
|
1880
|
+
// this.props.loadingHandler(false);
|
|
1881
|
+
// }, 2000);
|
|
1882
|
+
// } else {
|
|
1883
|
+
// }
|
|
1884
|
+
// });
|
|
1885
|
+
// })
|
|
1886
|
+
// .catch((error) => {
|
|
1887
|
+
// let newHotspotData = this.props.hotspotData;
|
|
1888
|
+
// let LayerId = elem.id.replace(/\d+\D*/g, '').slice(0, -1);
|
|
1889
|
+
// let errObj = {};
|
|
1890
|
+
// errObj[LayerId] = error;
|
|
1891
|
+
// newHotspotData['layerViewError'] = errObj;
|
|
1892
|
+
// this.props.hotspotDataHandler(newHotspotData);
|
|
1893
|
+
// this.props.loadingHandler(false);
|
|
1894
|
+
// });
|
|
1894
1895
|
this.checkForHotspots(elem, productContainerId);
|
|
1895
1896
|
} else {
|
|
1896
1897
|
sessionStorage.removeItem('downloadButtonClicked');
|
|
1897
1898
|
sessionStorage.removeItem('timeSliderTag');
|
|
1898
1899
|
this.deleteCheckedLayer(elem.id);
|
|
1899
|
-
this.deleteFilteredLayer(elem.id);
|
|
1900
1900
|
this.layers[elem.id].opacity = 1;
|
|
1901
1901
|
this.layers[elem.id].visible = false;
|
|
1902
|
+
this.deleteFilteredLayer(elem.id);
|
|
1902
1903
|
let mapLayer = this.map.findLayerById(elem.id);
|
|
1903
|
-
if (mapLayer)
|
|
1904
|
-
|
|
1904
|
+
if (mapLayer) {
|
|
1905
|
+
mapLayer.clear();
|
|
1906
|
+
mapLayer.destroy();
|
|
1907
|
+
this.map.remove(this.layers[elem.id]);
|
|
1908
|
+
}
|
|
1905
1909
|
delete this.activeLayersJSON[elem.id];
|
|
1906
1910
|
delete this.visibleLayers[elem.id];
|
|
1907
1911
|
delete this.timeLayers[elem.id];
|
|
@@ -1919,22 +1923,30 @@ class MenuWidget extends React.Component {
|
|
|
1919
1923
|
this.activeLayersToHotspotData(elem.id);
|
|
1920
1924
|
// update DOM
|
|
1921
1925
|
//this.setState({});
|
|
1926
|
+
let checkedLayers = sessionStorage.getItem('checkedLayers');
|
|
1927
|
+
if (checkedLayers && checkedLayers.length === 0) {
|
|
1928
|
+
this.props.loadingHandler(false);
|
|
1929
|
+
}
|
|
1922
1930
|
}
|
|
1923
1931
|
|
|
1924
|
-
|
|
1925
|
-
let layer = Object.entries(this.layers).find(
|
|
1926
|
-
([key, value]) => key === layerId,
|
|
1927
|
-
)?.[1];
|
|
1932
|
+
getHotspotLayerIds() {
|
|
1928
1933
|
let hotspotLayersIds = [];
|
|
1929
|
-
let updatedActiveLayers = this.props.hotspotData['activeLayers'] || {};
|
|
1930
|
-
let newHotspotData = this.props.hotspotData;
|
|
1931
|
-
|
|
1932
1934
|
Object.keys(this.props.hotspotData).forEach((key) => {
|
|
1933
1935
|
let dataset = this.props.hotspotData[key];
|
|
1934
1936
|
Object.keys(dataset).forEach((layerKey) => {
|
|
1935
1937
|
hotspotLayersIds.push(layerKey);
|
|
1936
1938
|
});
|
|
1937
1939
|
});
|
|
1940
|
+
this.hotspotLayersIds = hotspotLayersIds;
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
activeLayersToHotspotData(layerId) {
|
|
1944
|
+
let layer = Object.entries(this.layers).find(
|
|
1945
|
+
([key, value]) => key === layerId,
|
|
1946
|
+
)?.[1];
|
|
1947
|
+
let hotspotLayersIds = this.hotspotLayersIds;
|
|
1948
|
+
let updatedActiveLayers = this.props.hotspotData['activeLayers'] || {};
|
|
1949
|
+
let newHotspotData = this.props.hotspotData;
|
|
1938
1950
|
|
|
1939
1951
|
for (let i = 0; i < hotspotLayersIds.length; i++) {
|
|
1940
1952
|
const id = hotspotLayersIds[i];
|
|
@@ -2141,16 +2153,24 @@ class MenuWidget extends React.Component {
|
|
|
2141
2153
|
if (!activeLayersArray.length) {
|
|
2142
2154
|
messageLayers && (messageLayers.style.display = 'block');
|
|
2143
2155
|
} else messageLayers && (messageLayers.style.display = 'none');
|
|
2144
|
-
let
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2156
|
+
let data = activeLayersArray.sort((a, b) => {
|
|
2157
|
+
let layerIdA = a.props['layer-id'];
|
|
2158
|
+
let layerIdB = b.props['layer-id'];
|
|
2159
|
+
layerIdA = layerIdA.split('_').slice(-4).join('_');
|
|
2160
|
+
layerIdB = layerIdB.split('_').slice(-4).join('_');
|
|
2161
|
+
|
|
2162
|
+
if (
|
|
2163
|
+
this.state.draggedElements !== undefined &&
|
|
2164
|
+
(this.state.draggedElements.includes(layerIdA) ||
|
|
2165
|
+
this.state.draggedElements.includes(layerIdB))
|
|
2166
|
+
) {
|
|
2167
|
+
return 0;
|
|
2168
|
+
}
|
|
2169
|
+
|
|
2170
|
+
if (layerIdA < layerIdB) return -1;
|
|
2171
|
+
if (layerIdA > layerIdB) return 1;
|
|
2172
|
+
return 0;
|
|
2148
2173
|
});
|
|
2149
|
-
let data = activeLayersArray.sort(
|
|
2150
|
-
(a, b) =>
|
|
2151
|
-
activeLayers.indexOf(a.props['layer-id']) -
|
|
2152
|
-
activeLayers.indexOf(b.props['layer-id']),
|
|
2153
|
-
);
|
|
2154
2174
|
this.activeLayersHandler(activeLayersArray);
|
|
2155
2175
|
return data;
|
|
2156
2176
|
}
|
|
@@ -2731,7 +2751,7 @@ class MenuWidget extends React.Component {
|
|
|
2731
2751
|
onDrop(e) {
|
|
2732
2752
|
let dst = e.target.closest('div.active-layer');
|
|
2733
2753
|
if (dst === this.draggingElement) return;
|
|
2734
|
-
|
|
2754
|
+
let id = dst.id.split('_').slice(-4).join('_');
|
|
2735
2755
|
//First, we decide how to insert the element in the DOM
|
|
2736
2756
|
let init_ord = this.draggingElement.getAttribute('layer-order');
|
|
2737
2757
|
let dst_ord = dst.getAttribute('layer-order');
|
|
@@ -2742,6 +2762,9 @@ class MenuWidget extends React.Component {
|
|
|
2742
2762
|
dst.parentElement.insertBefore(this.draggingElement, dst);
|
|
2743
2763
|
}
|
|
2744
2764
|
|
|
2765
|
+
if (!this.state.draggedElements.includes(id)) {
|
|
2766
|
+
this.setState({ draggedElements: [...this.state.draggedElements, id] });
|
|
2767
|
+
}
|
|
2745
2768
|
this.layersReorder();
|
|
2746
2769
|
this.saveLayerOrder();
|
|
2747
2770
|
}
|
|
@@ -3378,16 +3401,72 @@ class MenuWidget extends React.Component {
|
|
|
3378
3401
|
}
|
|
3379
3402
|
|
|
3380
3403
|
deleteFilteredLayer(layer) {
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3404
|
+
if (
|
|
3405
|
+
!(
|
|
3406
|
+
layer.includes('all_lcc') ||
|
|
3407
|
+
layer.includes('all_present') ||
|
|
3408
|
+
layer.includes('cop_klc') ||
|
|
3409
|
+
layer.includes('protected_areas')
|
|
3410
|
+
)
|
|
3411
|
+
)
|
|
3412
|
+
return;
|
|
3413
|
+
let filterLayer;
|
|
3414
|
+
//let temp;
|
|
3415
|
+
let updatedHotspotData = this.props.hotspotData;
|
|
3416
|
+
let updatedFilteredLayers = this.props.hotspotData['filteredLayers'];
|
|
3417
|
+
if (this.layers['lcc_filter'] && layer.includes('all_lcc')) {
|
|
3418
|
+
this.layers['lcc_filter'].visible = false;
|
|
3419
|
+
filterLayer = this.props.map.findLayerById('lcc_filter');
|
|
3420
|
+
if (filterLayer !== undefined) {
|
|
3421
|
+
filterLayer.clear();
|
|
3422
|
+
filterLayer.destroy();
|
|
3423
|
+
this.props.map.remove(filterLayer);
|
|
3424
|
+
}
|
|
3425
|
+
delete updatedFilteredLayers['lcc_filter'];
|
|
3426
|
+
delete this.layers['lcc_filter'];
|
|
3427
|
+
} else if (this.layers['lc_filter'] && layer.includes('all_present_lc')) {
|
|
3428
|
+
this.layers['lc_filter'].visible = false;
|
|
3429
|
+
filterLayer = this.props.map.findLayerById('lc_filter');
|
|
3430
|
+
if (filterLayer !== undefined) {
|
|
3431
|
+
filterLayer.clear();
|
|
3432
|
+
filterLayer.destroy();
|
|
3433
|
+
this.props.map.remove(filterLayer);
|
|
3434
|
+
}
|
|
3435
|
+
delete updatedFilteredLayers['lc_filter'];
|
|
3436
|
+
delete this.layers['lc_filter'];
|
|
3437
|
+
} else if (
|
|
3438
|
+
this.layers['klc_filter'] !== undefined &&
|
|
3439
|
+
layer.includes('cop_klc')
|
|
3440
|
+
) {
|
|
3441
|
+
this.layers['klc_filter'].visible = false;
|
|
3442
|
+
this.layers[layer].visible = false;
|
|
3443
|
+
filterLayer = this.props.map.findLayerById('klc_filter');
|
|
3444
|
+
if (filterLayer !== undefined) {
|
|
3445
|
+
// temp = filterLayer;
|
|
3446
|
+
filterLayer.clear();
|
|
3447
|
+
filterLayer.destroy();
|
|
3448
|
+
this.props.map.remove(filterLayer);
|
|
3449
|
+
}
|
|
3450
|
+
delete updatedFilteredLayers['klc_filter'];
|
|
3451
|
+
//delete this.layers['klc_filter'];
|
|
3452
|
+
} else if (
|
|
3453
|
+
this.layers['pa_filter'] !== undefined &&
|
|
3454
|
+
layer.includes('protected_areas')
|
|
3455
|
+
) {
|
|
3456
|
+
this.layers['pa_filter'].visible = false;
|
|
3457
|
+
this.layers[layer].visible = false;
|
|
3458
|
+
filterLayer = this.props.map.findLayerById('pa_filter');
|
|
3459
|
+
if (filterLayer !== undefined) {
|
|
3460
|
+
// temp = filterLayer;
|
|
3461
|
+
filterLayer.clear();
|
|
3462
|
+
filterLayer.destroy();
|
|
3463
|
+
this.props.map.remove(filterLayer);
|
|
3464
|
+
}
|
|
3465
|
+
delete updatedFilteredLayers['pa_filter'];
|
|
3466
|
+
}
|
|
3467
|
+
this.props.mapLayersHandler(this.layers);
|
|
3468
|
+
updatedHotspotData['filteredLayers'] = updatedFilteredLayers;
|
|
3469
|
+
this.props.hotspotDataHandler(updatedHotspotData);
|
|
3391
3470
|
}
|
|
3392
3471
|
|
|
3393
3472
|
/**
|