@eeacms/volto-arcgis-block 0.1.303 → 0.1.304

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,8 @@ 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.304](https://github.com/eea/volto-arcgis-block/compare/0.1.303...0.1.304) - 13 September 2024
8
+
7
9
  ### [0.1.303](https://github.com/eea/volto-arcgis-block/compare/0.1.302...0.1.303) - 10 September 2024
8
10
 
9
11
  ### [0.1.302](https://github.com/eea/volto-arcgis-block/compare/0.1.301...0.1.302) - 6 September 2024
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-arcgis-block",
3
- "version": "0.1.303",
3
+ "version": "0.1.304",
4
4
  "description": "volto-arcgis-block: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: CodeSyntax",
@@ -948,9 +948,7 @@ class HotspotWidget extends React.Component {
948
948
  async componentDidMount() {
949
949
  await this.getLayerParameters();
950
950
  await this.loader();
951
- if (this.props.mapDiv.current) {
952
- this.props.view.ui.add(this.container.current, 'top-right');
953
- }
951
+ this.props.view.ui.add(this.container.current, 'top-right');
954
952
  this.layerModelInit();
955
953
  this.getBBoxData();
956
954
  this.props.view.when(() => {
@@ -90,9 +90,7 @@ class InfoWidget extends React.Component {
90
90
  * This method is executed after the rener method is executed
91
91
  */ async componentDidMount() {
92
92
  await this.loader();
93
- if (this.props.mapDiv.current) {
94
- this.props.view.ui.add(this.container.current, 'top-right');
95
- }
93
+ this.props.view.ui.add(this.container.current, 'top-right');
96
94
  this.props.view.on('click', (e) => {
97
95
  let screenPoint = {
98
96
  x: e.x,
@@ -232,9 +232,7 @@ class LegendWidget extends React.Component {
232
232
  */
233
233
  async componentDidMount() {
234
234
  await this.loader();
235
- if (this.props.mapDiv.current) {
236
- this.props.view.ui.add(this.container.current, 'top-right');
237
- }
235
+ this.props.view.ui.add(this.container.current, 'top-right');
238
236
  this.LegendWidget = new Legend({
239
237
  view: this.props.view,
240
238
  viewModel: new LegendViewModel({
@@ -55,9 +55,7 @@ class LoadingSpinner extends React.Component {
55
55
 
56
56
  async componentDidMount() {
57
57
  this.props.view.when(() => {
58
- if (this.props.mapDiv.current) {
59
- this.props.view.ui.add(this.container.current, 'manual');
60
- }
58
+ this.props.view.ui.add(this.container.current, 'manual');
61
59
  this.listenForLayerChanges();
62
60
  });
63
61
  }
@@ -57,6 +57,7 @@ class MapViewer extends React.Component {
57
57
  layerLoading: false,
58
58
  layers: {},
59
59
  uploadedFile: true,
60
+ isReady: false,
60
61
  };
61
62
  this.activeLayersHandler = this.activeLayersHandler.bind(this);
62
63
  this.activeLayersArray = {};
@@ -163,11 +164,24 @@ class MapViewer extends React.Component {
163
164
  return obj;
164
165
  }
165
166
 
167
+ waitForContainer(mapdiv) {
168
+ while (mapdiv === null) {
169
+ new Promise((resolve) => setTimeout(resolve, 100)); // wait for 100ms
170
+ }
171
+ return mapdiv;
172
+ }
173
+
166
174
  async componentDidMount() {
167
175
  loadCss();
168
176
  await this.loader();
169
177
  // this.state.url = window.location.href;
170
178
  await this.waitForDataFill(this.compCfg);
179
+ this.intervalId = setInterval(() => {
180
+ if (this.mapdiv.current !== null) {
181
+ this.setState({ isReady: true });
182
+ clearInterval(this.intervalId);
183
+ }
184
+ }, 100);
171
185
  this.positronCompositeBasemap = new Basemap({
172
186
  title: 'Positron composite',
173
187
  thumbnailUrl: this.cfgUrls.positronCompositeThumbnail,
@@ -181,92 +195,89 @@ class MapViewer extends React.Component {
181
195
  // new _WebTileLayer(...)
182
196
  // ],
183
197
  });
198
+ this.map = new Map({
199
+ // basemap: 'topo',
200
+ basemap: this.positronCompositeBasemap,
201
+ logo: false,
202
+ });
184
203
 
185
- if (this.mapdiv.current) {
186
- this.map = new Map({
187
- // basemap: 'topo',
188
- basemap: this.positronCompositeBasemap,
189
- logo: false,
190
- });
204
+ mapStatus = this.recoverState();
191
205
 
192
- mapStatus = this.recoverState();
193
-
194
- if (
195
- mapStatus === null ||
196
- (mapStatus.zoom === null && mapStatus.center === null) ||
197
- Object.entries(mapStatus).length === 0
198
- ) {
199
- mapStatus = {};
200
- mapStatus.zoom = this.mapCfg.zoom;
201
- mapStatus.center = this.mapCfg.center;
202
- mapStatus.activeLayers = this.mapCfg.activeLayers;
203
- this.setCenterState(this.mapCfg.center);
204
- this.setZoomState(this.mapCfg.zoom);
205
- this.activeLayersHandler(this.mapCfg.activeLayers);
206
- }
206
+ if (
207
+ mapStatus === null ||
208
+ (mapStatus.zoom === null && mapStatus.center === null) ||
209
+ Object.entries(mapStatus).length === 0
210
+ ) {
211
+ mapStatus = {};
212
+ mapStatus.zoom = this.mapCfg.zoom;
213
+ mapStatus.center = this.mapCfg.center;
214
+ mapStatus.activeLayers = this.mapCfg.activeLayers;
215
+ this.setCenterState(this.mapCfg.center);
216
+ this.setZoomState(this.mapCfg.zoom);
217
+ this.activeLayersHandler(this.mapCfg.activeLayers);
218
+ }
207
219
 
208
- this.view = new MapView({
209
- container: this.mapdiv.current,
210
- map: this.map,
211
- center: mapStatus.center,
212
- zoom: mapStatus.zoom,
213
- constraints: {
214
- minZoom: this.mapCfg.minZoom,
215
- maxZoom: this.mapCfg.maxZoom,
216
- rotationEnabled: false,
217
- geometry: this.mapCfg.geometry,
218
- },
219
- ui: {
220
- components: ['attribution'],
221
- },
222
- });
223
- this.zoom = new Zoom({
224
- view: this.view,
225
- });
226
- this.view.ui.add(this.zoom, {
227
- position: 'top-right',
220
+ this.view = new MapView({
221
+ container: this.mapdiv.current,
222
+ map: this.map,
223
+ center: mapStatus.center,
224
+ zoom: mapStatus.zoom,
225
+ constraints: {
226
+ minZoom: this.mapCfg.minZoom,
227
+ maxZoom: this.mapCfg.maxZoom,
228
+ rotationEnabled: false,
229
+ geometry: this.mapCfg.geometry,
230
+ },
231
+ ui: {
232
+ components: ['attribution'],
233
+ },
234
+ });
235
+ this.zoom = new Zoom({
236
+ view: this.view,
237
+ });
238
+ this.view.ui.add(this.zoom, {
239
+ position: 'top-right',
240
+ });
241
+
242
+ this.view.when(() => {
243
+ this.view.watch('center', (newValue, oldValue, property, object) => {
244
+ this.setCenterState(newValue);
228
245
  });
229
246
 
230
- this.view.when(() => {
231
- this.view.watch('center', (newValue, oldValue, property, object) => {
232
- this.setCenterState(newValue);
233
- });
234
-
235
- let constraintExtent = null;
236
- this.view.watch('zoom', (newValue, oldValue, property, object) => {
237
- this.setZoomState(newValue);
238
- if (mapStatus.zoom <= this.mapCfg.minZoom) {
239
- constraintExtent = new Extent({
240
- xmin: this.mapCfg.geometry.xmin,
241
- ymin: this.mapCfg.geometry.ymin,
242
- xmax: this.mapCfg.geometry.xmax,
243
- ymax: this.mapCfg.geometry.ymax,
244
- spatialReference: 4326,
245
- });
246
- } else {
247
- constraintExtent = new Extent({
248
- xmin: this.mapCfg.geometryZoomIn.xmin,
249
- ymin: this.mapCfg.geometryZoomIn.ymin,
250
- xmax: this.mapCfg.geometryZoomIn.xmax,
251
- ymax: this.mapCfg.geometryZoomIn.ymax,
252
- spatialReference: 4326,
253
- });
254
- }
255
- this.view.constraints.geometry = constraintExtent;
256
- });
257
- this.view.popup.autoOpenEnabled = false;
258
- // After launching the MapViewerConfig action
259
- // we will have stored the json response here:
260
- // this.props.mapviewer_config
261
- this.props.MapViewerConfig(flattenToAppURL(this.props.url));
262
- //Once we have created the MapView, we need to ensure that the map div
263
- //is refreshed in order to show the map on it. To do so, we need to
264
- //trigger the renderization again, and to trigger the renderization
265
- //we invoke the setState method, that changes the state and forces a
266
- //react component to render itself again
267
- //this.setState({});
247
+ let constraintExtent = null;
248
+ this.view.watch('zoom', (newValue, oldValue, property, object) => {
249
+ this.setZoomState(newValue);
250
+ if (mapStatus.zoom <= this.mapCfg.minZoom) {
251
+ constraintExtent = new Extent({
252
+ xmin: this.mapCfg.geometry.xmin,
253
+ ymin: this.mapCfg.geometry.ymin,
254
+ xmax: this.mapCfg.geometry.xmax,
255
+ ymax: this.mapCfg.geometry.ymax,
256
+ spatialReference: 4326,
257
+ });
258
+ } else {
259
+ constraintExtent = new Extent({
260
+ xmin: this.mapCfg.geometryZoomIn.xmin,
261
+ ymin: this.mapCfg.geometryZoomIn.ymin,
262
+ xmax: this.mapCfg.geometryZoomIn.xmax,
263
+ ymax: this.mapCfg.geometryZoomIn.ymax,
264
+ spatialReference: 4326,
265
+ });
266
+ }
267
+ this.view.constraints.geometry = constraintExtent;
268
268
  });
269
- }
269
+ this.view.popup.autoOpenEnabled = false;
270
+ // After launching the MapViewerConfig action
271
+ // we will have stored the json response here:
272
+ // this.props.mapviewer_config
273
+ this.props.MapViewerConfig(flattenToAppURL(this.props.url));
274
+ //Once we have created the MapView, we need to ensure that the map div
275
+ //is refreshed in order to show the map on it. To do so, we need to
276
+ //trigger the renderization again, and to trigger the renderization
277
+ //we invoke the setState method, that changes the state and forces a
278
+ //react component to render itself again
279
+ //this.setState({});
280
+ });
270
281
  }
271
282
 
272
283
  componentDidUpdate(prevProps, prevState) {
@@ -285,6 +296,7 @@ class MapViewer extends React.Component {
285
296
  componentWillUnmount() {
286
297
  // clean up
287
298
  if (this.view) {
299
+ clearInterval(this.intervalId);
288
300
  this.view.container = null;
289
301
  this.view.destroy();
290
302
  delete this.view;
@@ -321,12 +333,7 @@ class MapViewer extends React.Component {
321
333
  if (this.props.mapviewer_config.Download) return;
322
334
  if (this.view)
323
335
  return (
324
- <BasemapWidget
325
- view={this.view}
326
- mapViewer={this}
327
- urls={this.cfgUrls}
328
- mapDiv={this.mapdiv}
329
- />
336
+ <BasemapWidget view={this.view} mapViewer={this} urls={this.cfgUrls} />
330
337
  );
331
338
  }
332
339
 
@@ -341,7 +348,6 @@ class MapViewer extends React.Component {
341
348
  layerLoading={this.state.layerLoading}
342
349
  hotspotData={this.state.hotspotData}
343
350
  hotspotDataHandler={this.hotspotDataHandler}
344
- mapDiv={this.mapdiv}
345
351
  />
346
352
  );
347
353
  }
@@ -349,21 +355,12 @@ class MapViewer extends React.Component {
349
355
  renderMeasurement() {
350
356
  if (this.props.mapviewer_config.Download) return;
351
357
  if (this.view)
352
- return (
353
- <MeasurementWidget
354
- view={this.view}
355
- mapViewer={this}
356
- mapDiv={this.mapdiv}
357
- />
358
- );
358
+ return <MeasurementWidget view={this.view} mapViewer={this} />;
359
359
  }
360
360
 
361
361
  renderPrint() {
362
362
  if (this.props.mapviewer_config.Download) return;
363
- if (this.view)
364
- return (
365
- <PrintWidget view={this.view} mapViewer={this} mapDiv={this.mapdiv} />
366
- );
363
+ if (this.view) return <PrintWidget view={this.view} mapViewer={this} />;
367
364
  }
368
365
 
369
366
  renderSwipe() {
@@ -375,7 +372,6 @@ class MapViewer extends React.Component {
375
372
  mapViewer={this}
376
373
  map={this.map}
377
374
  layers={this.state.layers}
378
- mapDiv={this.mapdiv}
379
375
  />
380
376
  );
381
377
  }
@@ -383,17 +379,12 @@ class MapViewer extends React.Component {
383
379
  renderArea() {
384
380
  if (this.props.mapviewer_config.Download) return;
385
381
  if (this.view) {
386
- return (
387
- <CheckLogin reference={this} urls={this.cfgUrls} mapDiv={this.mapdiv} />
388
- );
382
+ return <CheckLogin reference={this} urls={this.cfgUrls} />;
389
383
  }
390
384
  }
391
385
 
392
386
  renderScale() {
393
- if (this.view)
394
- return (
395
- <ScaleWidget view={this.view} mapViewer={this} mapDiv={this.mapdiv} />
396
- );
387
+ if (this.view) return <ScaleWidget view={this.view} mapViewer={this} />;
397
388
  }
398
389
 
399
390
  renderInfo() {
@@ -404,21 +395,13 @@ class MapViewer extends React.Component {
404
395
  map={this.map}
405
396
  mapViewer={this}
406
397
  hotspotData={this.state.hotspotData}
407
- mapDiv={this.mapdiv}
408
398
  />
409
399
  );
410
400
  }
411
401
 
412
402
  renderPan() {
413
403
  if (this.view)
414
- return (
415
- <PanWidget
416
- view={this.view}
417
- map={this.map}
418
- mapViewer={this}
419
- mapDiv={this.mapdiv}
420
- />
421
- );
404
+ return <PanWidget view={this.view} map={this.map} mapViewer={this} />;
422
405
  }
423
406
 
424
407
  renderHotspot() {
@@ -437,7 +420,6 @@ class MapViewer extends React.Component {
437
420
  hotspotDataHandler={this.hotspotDataHandler}
438
421
  mapLayersHandler={this.mapLayersHandler}
439
422
  bookmarkData={this.state.bookmarkData}
440
- mapDiv={this.mapdiv}
441
423
  />
442
424
  );
443
425
  }
@@ -467,13 +449,12 @@ class MapViewer extends React.Component {
467
449
  prepackageHandler={this.prepackageHandler}
468
450
  uploadedFile={this.state.uploadedFile}
469
451
  uploadFileHandler={this.uploadFileHandler}
470
- mapDiv={this.mapdiv}
471
452
  />
472
453
  ); //call conf
473
454
  }
474
455
 
475
456
  renderBookmark() {
476
- if (this.view) return <CheckUserID reference={this} mapDiv={this.mapdiv} />;
457
+ if (this.view) return <CheckUserID reference={this} />;
477
458
  }
478
459
 
479
460
  appLanguage() {
@@ -482,11 +463,7 @@ class MapViewer extends React.Component {
482
463
 
483
464
  renderLoadingSpinner() {
484
465
  return (
485
- <LoadingSpinner
486
- view={this.view}
487
- layerLoading={this.state.layerLoading}
488
- mapDiv={this.mapdiv}
489
- />
466
+ <LoadingSpinner view={this.view} layerLoading={this.state.layerLoading} />
490
467
  );
491
468
  }
492
469
 
@@ -507,22 +484,26 @@ class MapViewer extends React.Component {
507
484
  } else {
508
485
  return (
509
486
  <div className={this.mapClass}>
510
- <div ref={this.mapdiv} className="map">
511
- {this.appLanguage()}
512
- {this.renderBasemap()}
513
- {this.renderLegend()}
514
- {this.renderMeasurement()}
515
- {this.renderPrint()}
516
- {this.renderSwipe()}
517
- {this.renderArea()}
518
- {this.renderPan()}
519
- {this.renderScale()}
520
- {this.renderInfo()}
521
- {this.renderHotspot()}
522
- {this.renderMenu()}
523
- {this.renderBookmark()}
524
- {this.renderLoadingSpinner()}
525
- </div>
487
+ {this.state.isReady ? (
488
+ <div ref={this.mapdiv} className="map">
489
+ {this.appLanguage()}
490
+ {this.renderBasemap()}
491
+ {this.renderLegend()}
492
+ {this.renderMeasurement()}
493
+ {this.renderPrint()}
494
+ {this.renderSwipe()}
495
+ {this.renderArea()}
496
+ {this.renderPan()}
497
+ {this.renderScale()}
498
+ {this.renderInfo()}
499
+ {this.renderHotspot()}
500
+ {this.renderMenu()}
501
+ {this.renderBookmark()}
502
+ {this.renderLoadingSpinner()}
503
+ </div>
504
+ ) : (
505
+ <p>Loading...</p>
506
+ )}
526
507
  </div>
527
508
  );
528
509
  }
@@ -180,13 +180,11 @@ class MeasurementWidget extends React.Component {
180
180
  */
181
181
  async componentDidMount() {
182
182
  await this.loader();
183
- if (this.props.mapDiv.current) {
184
- this.props.view.ui.add(this.container.current, 'top-right');
185
- this.measurement = new Measurement({
186
- view: this.props.view,
187
- container: this.container.current.querySelector('.measurement-area'),
188
- });
189
- }
183
+ this.props.view.ui.add(this.container.current, 'top-right');
184
+ this.measurement = new Measurement({
185
+ view: this.props.view,
186
+ container: this.container.current.querySelector('.measurement-area'),
187
+ });
190
188
  }
191
189
  /**
192
190
  * This method renders the component
@@ -799,11 +799,13 @@ class MenuWidget extends React.Component {
799
799
  loadCss();
800
800
  await this.loader();
801
801
  await this.getTMSLayersJSON();
802
- if (this.props.mapDiv.current) {
803
- if (!this.props.download) {
804
- this.prepareHotspotLayers();
805
- this.getHotspotLayerIds();
806
- }
802
+ //let currentContainer;
803
+ //do {
804
+ // currentContainer = await this.container.current;
805
+ //} while (currentContainer == null);
806
+ if (!this.props.download) {
807
+ this.prepareHotspotLayers();
808
+ this.getHotspotLayerIds();
807
809
  this.props.view.ui.add(this.container.current, 'top-left');
808
810
  }
809
811
  if (this.props.download) {
@@ -20,13 +20,11 @@ class PanWidget extends React.Component {
20
20
  * This method is executed after the rener method is executed
21
21
  */
22
22
  async componentDidMount() {
23
- if (this.props.mapDiv.current) {
24
- this.props.view.ui.add({
25
- component: this.container.current,
26
- position: 'top-right',
27
- index: 0,
28
- });
29
- }
23
+ this.props.view.ui.add({
24
+ component: this.container.current,
25
+ position: 'top-right',
26
+ index: 0,
27
+ });
30
28
  }
31
29
 
32
30
  togglePan() {
@@ -71,13 +71,11 @@ class PrintWidget extends React.Component {
71
71
  */
72
72
  async componentDidMount() {
73
73
  await this.loader();
74
- if (this.props.mapDiv.current) {
75
- this.props.view.ui.add(this.container.current, 'top-right');
76
- this.print = new Print({
77
- view: this.props.view,
78
- container: this.container.current.querySelector('.print-panel'),
79
- });
80
- }
74
+ this.props.view.ui.add(this.container.current, 'top-right');
75
+ this.print = new Print({
76
+ view: this.props.view,
77
+ container: this.container.current.querySelector('.print-panel'),
78
+ });
81
79
  }
82
80
 
83
81
  componentDidUpdate() {
@@ -35,9 +35,7 @@ class ScaleWidget extends React.Component {
35
35
  view: this.props.view,
36
36
  unit: 'dual',
37
37
  });
38
- if (this.props.mapDiv.current) {
39
- this.props.view.ui.add(this.scaleBar, 'bottom-left');
40
- }
38
+ this.props.view.ui.add(this.scaleBar, 'bottom-left');
41
39
  }
42
40
  /**
43
41
  * This method renders the component
@@ -91,9 +91,7 @@ class SwipeWidget extends React.Component {
91
91
  * This method is executed after the rener method is executed
92
92
  */
93
93
  async componentDidMount() {
94
- if (this.props.mapDiv.current) {
95
- this.props.view.ui.add(this.container.current, 'top-right');
96
- }
94
+ this.props.view.ui.add(this.container.current, 'top-right');
97
95
  await this.loader();
98
96
  this.swipe = new Swipe({
99
97
  view: this.props.view,
@@ -262,14 +262,12 @@ class TimesliderWidget extends React.Component {
262
262
  }
263
263
  },
264
264
  });
265
- if (this.props.mapDiv.current) {
266
- this.props.view.ui.add(this.container.current, 'bottom-right');
267
- this.container.current.insertAdjacentHTML(
268
- 'beforeend',
269
- '<div class="esri-icon-close" id="timeslider_close" role="button"></div>',
270
- );
271
- this.container.current.style.display = 'block';
272
- }
265
+ this.props.view.ui.add(this.container.current, 'bottom-right');
266
+ this.container.current.insertAdjacentHTML(
267
+ 'beforeend',
268
+ '<div class="esri-icon-close" id="timeslider_close" role="button"></div>',
269
+ );
270
+ this.container.current.style.display = 'block';
273
271
  this.setState({ showDatePanel: true });
274
272
 
275
273
  document