@mapcomponents/react-maplibre 0.1.13 → 0.1.17
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/.github/workflows/storybook.yml +4 -2
- package/CHANGELOG.md +33 -0
- package/README.md +22 -6
- package/coverage/clover.xml +447 -460
- package/coverage/coverage-final.json +14 -14
- package/coverage/lcov-report/index.html +77 -78
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.js.html +2 -3
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +2 -3
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.js.html +2 -3
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +2 -3
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.js.html +2 -3
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +2 -3
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +2 -3
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +2 -3
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.js.html +112 -107
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +16 -17
- package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.js.html +2 -3
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +2 -3
- package/coverage/lcov-report/src/components/MlGPXViewer/index.html +2 -3
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js.html +142 -134
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +20 -21
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +46 -152
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +20 -21
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.js.html +92 -30
- package/coverage/lcov-report/src/components/MlLayer/index.html +20 -21
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.js.html +2 -3
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +2 -3
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.js.html +2 -3
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +2 -3
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +3 -10
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +9 -82
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +10 -11
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +2 -3
- package/coverage/lcov-report/src/components/MlMarker/MlMarker.js.html +6 -7
- package/coverage/lcov-report/src/components/MlMarker/index.html +6 -7
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.js.html +2 -3
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +2 -3
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.js.html +11 -15
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +8 -9
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +2 -3
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +2 -3
- package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +2 -3
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +2 -3
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +209 -18
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +10 -11
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +2 -3
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +2 -3
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +2 -3
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +2 -3
- package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +6 -25
- package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +6 -7
- package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.js.html +2 -3
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +2 -3
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +2 -3
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +2 -3
- package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.js.html +2 -3
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +2 -3
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.js.html +6 -19
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +8 -9
- package/coverage/lcov-report/src/hooks/index.html +35 -36
- package/coverage/lcov-report/src/hooks/useMap.js.html +81 -169
- package/coverage/lcov-report/src/hooks/useMapState.js.html +82 -125
- package/coverage/lcov-report/src/hooks/useWms.js.html +9 -22
- package/coverage/lcov-report/src/i18n.js.html +2 -3
- package/coverage/lcov-report/src/index.html +2 -3
- package/coverage/lcov-report/src/translations/english.js.html +2 -3
- package/coverage/lcov-report/src/translations/german.js.html +2 -3
- package/coverage/lcov-report/src/translations/index.html +2 -3
- package/coverage/lcov.info +891 -896
- package/dist/index.esm.js +941 -717
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +16 -14
- package/src/components/MlComponentTemplate/MlComponentTemplate.js +7 -32
- package/src/components/MlFollowGps/MlFollowGps.js +67 -65
- package/src/components/MlFollowGps/MlFollowGps.test.js +3 -5
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +91 -88
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +20 -6
- package/src/components/MlGeoJsonLayer/assets/sample_polygon_1.json +33 -0
- package/src/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.js +25 -0
- package/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.js +22 -0
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +21 -56
- package/src/components/MlLayer/MlLayer.js +26 -5
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +0 -2
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +3 -6
- package/src/components/MlLayerSwitcher/components/LayerBox.js +2 -26
- package/src/components/MlMarker/MlMarker.js +1 -1
- package/src/components/MlNavigationTools/MlNavigationTools.js +4 -5
- package/src/components/MlShareMapState/MlShareMapState.js +73 -9
- package/src/components/MlShareMapState/MlShareMapState.stories.js +22 -2
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +1 -3
- package/src/components/MlUseMapDebugger/MlUseMapDebugger.js +1 -7
- package/src/components/MlWmsLoader/MlWmsLoader.js +0 -4
- package/src/hooks/useMap.js +33 -62
- package/src/hooks/useMapState.js +3 -17
- package/src/hooks/useWms.js +2 -7
- package/src/index.js +3 -0
- package/src/ui_components/ImageLoader.js +8 -3
- package/src/ui_components/Sidebar.js +1 -1
- package/src/ui_components/TopToolbar.js +0 -2
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">65.67% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>44/67</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">55% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>33/60</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">88.88% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
42
|
+
<span class='fraction'>8/9</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">63.49% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>40/63</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -303,7 +303,10 @@
|
|
|
303
303
|
<a name='L238'></a><a href='#L238'>238</a>
|
|
304
304
|
<a name='L239'></a><a href='#L239'>239</a>
|
|
305
305
|
<a name='L240'></a><a href='#L240'>240</a>
|
|
306
|
-
<a name='L241'></a><a href='#L241'>241</a
|
|
306
|
+
<a name='L241'></a><a href='#L241'>241</a>
|
|
307
|
+
<a name='L242'></a><a href='#L242'>242</a>
|
|
308
|
+
<a name='L243'></a><a href='#L243'>243</a>
|
|
309
|
+
<a name='L244'></a><a href='#L244'>244</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
307
310
|
<span class="cline-any cline-neutral"> </span>
|
|
308
311
|
<span class="cline-any cline-neutral"> </span>
|
|
309
312
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -312,6 +315,9 @@
|
|
|
312
315
|
<span class="cline-any cline-neutral"> </span>
|
|
313
316
|
<span class="cline-any cline-neutral"> </span>
|
|
314
317
|
<span class="cline-any cline-neutral"> </span>
|
|
318
|
+
<span class="cline-any cline-neutral"> </span>
|
|
319
|
+
<span class="cline-any cline-neutral"> </span>
|
|
320
|
+
<span class="cline-any cline-yes">2x</span>
|
|
315
321
|
<span class="cline-any cline-yes">2x</span>
|
|
316
322
|
<span class="cline-any cline-neutral"> </span>
|
|
317
323
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -321,36 +327,29 @@
|
|
|
321
327
|
<span class="cline-any cline-neutral"> </span>
|
|
322
328
|
<span class="cline-any cline-yes">2x</span>
|
|
323
329
|
<span class="cline-any cline-neutral"> </span>
|
|
324
|
-
<span class="cline-any cline-yes">
|
|
325
|
-
<span class="cline-any cline-yes">
|
|
326
|
-
<span class="cline-any cline-yes">
|
|
327
|
-
<span class="cline-any cline-yes">
|
|
328
|
-
<span class="cline-any cline-yes">8x</span>
|
|
329
|
-
<span class="cline-any cline-yes">8x</span>
|
|
330
|
-
<span class="cline-any cline-yes">8x</span>
|
|
331
|
-
<span class="cline-any cline-yes">8x</span>
|
|
332
|
-
<span class="cline-any cline-yes">8x</span>
|
|
333
|
-
<span class="cline-any cline-yes">8x</span>
|
|
330
|
+
<span class="cline-any cline-yes">12x</span>
|
|
331
|
+
<span class="cline-any cline-yes">12x</span>
|
|
332
|
+
<span class="cline-any cline-yes">12x</span>
|
|
333
|
+
<span class="cline-any cline-yes">12x</span>
|
|
334
334
|
<span class="cline-any cline-neutral"> </span>
|
|
335
335
|
<span class="cline-any cline-neutral"> </span>
|
|
336
|
-
<span class="cline-any cline-yes">
|
|
336
|
+
<span class="cline-any cline-yes">12x</span>
|
|
337
|
+
<span class="cline-any cline-yes">12x</span>
|
|
338
|
+
<span class="cline-any cline-yes">12x</span>
|
|
339
|
+
<span class="cline-any cline-yes">12x</span>
|
|
340
|
+
<span class="cline-any cline-yes">12x</span>
|
|
341
|
+
<span class="cline-any cline-yes">12x</span>
|
|
337
342
|
<span class="cline-any cline-neutral"> </span>
|
|
338
|
-
<span class="cline-any cline-yes">
|
|
339
|
-
<span class="cline-any cline-yes">4x</span>
|
|
343
|
+
<span class="cline-any cline-yes">12x</span>
|
|
340
344
|
<span class="cline-any cline-yes">4x</span>
|
|
341
345
|
<span class="cline-any cline-neutral"> </span>
|
|
342
346
|
<span class="cline-any cline-yes">2x</span>
|
|
343
347
|
<span class="cline-any cline-no"> </span>
|
|
344
348
|
<span class="cline-any cline-neutral"> </span>
|
|
345
|
-
<span class="cline-any cline-yes">2x</span>
|
|
346
|
-
<span class="cline-any cline-yes">2x</span>
|
|
347
|
-
<span class="cline-any cline-neutral"> </span>
|
|
348
|
-
<span class="cline-any cline-yes">2x</span>
|
|
349
|
-
<span class="cline-any cline-neutral"> </span>
|
|
350
349
|
<span class="cline-any cline-neutral"> </span>
|
|
351
350
|
<span class="cline-any cline-neutral"> </span>
|
|
352
351
|
<span class="cline-any cline-neutral"> </span>
|
|
353
|
-
<span class="cline-any cline-yes">
|
|
352
|
+
<span class="cline-any cline-yes">12x</span>
|
|
354
353
|
<span class="cline-any cline-yes">8x</span>
|
|
355
354
|
<span class="cline-any cline-neutral"> </span>
|
|
356
355
|
<span class="cline-any cline-no"> </span>
|
|
@@ -358,7 +357,7 @@
|
|
|
358
357
|
<span class="cline-any cline-neutral"> </span>
|
|
359
358
|
<span class="cline-any cline-neutral"> </span>
|
|
360
359
|
<span class="cline-any cline-neutral"> </span>
|
|
361
|
-
<span class="cline-any cline-yes">
|
|
360
|
+
<span class="cline-any cline-yes">12x</span>
|
|
362
361
|
<span class="cline-any cline-yes">8x</span>
|
|
363
362
|
<span class="cline-any cline-neutral"> </span>
|
|
364
363
|
<span class="cline-any cline-no"> </span>
|
|
@@ -366,7 +365,7 @@
|
|
|
366
365
|
<span class="cline-any cline-neutral"> </span>
|
|
367
366
|
<span class="cline-any cline-neutral"> </span>
|
|
368
367
|
<span class="cline-any cline-neutral"> </span>
|
|
369
|
-
<span class="cline-any cline-yes">
|
|
368
|
+
<span class="cline-any cline-yes">12x</span>
|
|
370
369
|
<span class="cline-any cline-neutral"> </span>
|
|
371
370
|
<span class="cline-any cline-no"> </span>
|
|
372
371
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -385,10 +384,8 @@
|
|
|
385
384
|
<span class="cline-any cline-neutral"> </span>
|
|
386
385
|
<span class="cline-any cline-neutral"> </span>
|
|
387
386
|
<span class="cline-any cline-neutral"> </span>
|
|
387
|
+
<span class="cline-any cline-yes">12x</span>
|
|
388
388
|
<span class="cline-any cline-yes">8x</span>
|
|
389
|
-
<span class="cline-any cline-yes">8x</span>
|
|
390
|
-
<span class="cline-any cline-neutral"> </span>
|
|
391
|
-
<span class="cline-any cline-neutral"> </span>
|
|
392
389
|
<span class="cline-any cline-neutral"> </span>
|
|
393
390
|
<span class="cline-any cline-no"> </span>
|
|
394
391
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -413,13 +410,7 @@
|
|
|
413
410
|
<span class="cline-any cline-neutral"> </span>
|
|
414
411
|
<span class="cline-any cline-neutral"> </span>
|
|
415
412
|
<span class="cline-any cline-neutral"> </span>
|
|
416
|
-
<span class="cline-any cline-yes">
|
|
417
|
-
<span class="cline-any cline-yes">8x</span>
|
|
418
|
-
<span class="cline-any cline-neutral"> </span>
|
|
419
|
-
<span class="cline-any cline-neutral"> </span>
|
|
420
|
-
<span class="cline-any cline-neutral"> </span>
|
|
421
|
-
<span class="cline-any cline-yes">4x</span>
|
|
422
|
-
<span class="cline-any cline-yes">4x</span>
|
|
413
|
+
<span class="cline-any cline-yes">12x</span>
|
|
423
414
|
<span class="cline-any cline-yes">4x</span>
|
|
424
415
|
<span class="cline-any cline-neutral"> </span>
|
|
425
416
|
<span class="cline-any cline-yes">4x</span>
|
|
@@ -449,7 +440,8 @@
|
|
|
449
440
|
<span class="cline-any cline-neutral"> </span>
|
|
450
441
|
<span class="cline-any cline-neutral"> </span>
|
|
451
442
|
<span class="cline-any cline-neutral"> </span>
|
|
452
|
-
<span class="cline-any cline-
|
|
443
|
+
<span class="cline-any cline-yes">4x</span>
|
|
444
|
+
<span class="cline-any cline-no"> </span>
|
|
453
445
|
<span class="cline-any cline-neutral"> </span>
|
|
454
446
|
<span class="cline-any cline-neutral"> </span>
|
|
455
447
|
<span class="cline-any cline-yes">4x</span>
|
|
@@ -461,29 +453,43 @@
|
|
|
461
453
|
<span class="cline-any cline-neutral"> </span>
|
|
462
454
|
<span class="cline-any cline-neutral"> </span>
|
|
463
455
|
<span class="cline-any cline-yes">4x</span>
|
|
456
|
+
<span class="cline-any cline-neutral"> </span>
|
|
457
|
+
<span class="cline-any cline-neutral"> </span>
|
|
458
|
+
<span class="cline-any cline-neutral"> </span>
|
|
459
|
+
<span class="cline-any cline-neutral"> </span>
|
|
460
|
+
<span class="cline-any cline-no"> </span>
|
|
464
461
|
<span class="cline-any cline-no"> </span>
|
|
465
462
|
<span class="cline-any cline-neutral"> </span>
|
|
466
463
|
<span class="cline-any cline-neutral"> </span>
|
|
464
|
+
<span class="cline-any cline-neutral"> </span>
|
|
465
|
+
<span class="cline-any cline-yes">12x</span>
|
|
466
|
+
<span class="cline-any cline-yes">8x</span>
|
|
467
|
+
<span class="cline-any cline-neutral"> </span>
|
|
467
468
|
<span class="cline-any cline-yes">4x</span>
|
|
468
469
|
<span class="cline-any cline-neutral"> </span>
|
|
469
470
|
<span class="cline-any cline-neutral"> </span>
|
|
470
471
|
<span class="cline-any cline-neutral"> </span>
|
|
471
472
|
<span class="cline-any cline-neutral"> </span>
|
|
473
|
+
<span class="cline-any cline-neutral"> </span>
|
|
472
474
|
<span class="cline-any cline-no"> </span>
|
|
473
|
-
<span class="cline-any cline-
|
|
475
|
+
<span class="cline-any cline-yes">4x</span>
|
|
474
476
|
<span class="cline-any cline-neutral"> </span>
|
|
475
477
|
<span class="cline-any cline-neutral"> </span>
|
|
476
478
|
<span class="cline-any cline-neutral"> </span>
|
|
477
479
|
<span class="cline-any cline-neutral"> </span>
|
|
478
|
-
<span class="cline-any cline-
|
|
480
|
+
<span class="cline-any cline-no"> </span>
|
|
479
481
|
<span class="cline-any cline-neutral"> </span>
|
|
480
482
|
<span class="cline-any cline-neutral"> </span>
|
|
481
|
-
<span class="cline-any cline-yes">2x</span>
|
|
482
483
|
<span class="cline-any cline-neutral"> </span>
|
|
484
|
+
<span class="cline-any cline-yes">4x</span>
|
|
485
|
+
<span class="cline-any cline-neutral"> </span>
|
|
486
|
+
<span class="cline-any cline-yes">4x</span>
|
|
483
487
|
<span class="cline-any cline-neutral"> </span>
|
|
484
488
|
<span class="cline-any cline-neutral"> </span>
|
|
489
|
+
<span class="cline-any cline-yes">12x</span>
|
|
485
490
|
<span class="cline-any cline-neutral"> </span>
|
|
486
491
|
<span class="cline-any cline-neutral"> </span>
|
|
492
|
+
<span class="cline-any cline-yes">2x</span>
|
|
487
493
|
<span class="cline-any cline-neutral"> </span>
|
|
488
494
|
<span class="cline-any cline-neutral"> </span>
|
|
489
495
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -543,16 +549,19 @@
|
|
|
543
549
|
<span class="cline-any cline-neutral"> </span>
|
|
544
550
|
<span class="cline-any cline-neutral"> </span>
|
|
545
551
|
<span class="cline-any cline-neutral"> </span>
|
|
546
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import React, { useRef, useEffect,
|
|
552
|
+
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import React, { useRef, useEffect, useCallback } from "react";
|
|
547
553
|
import PropTypes from "prop-types";
|
|
548
554
|
|
|
549
|
-
import { v4 as uuidv4 } from "uuid";
|
|
550
555
|
import * as turf from "@turf/turf";
|
|
551
|
-
|
|
556
|
+
|
|
557
|
+
import useMap from "../../hooks/useMap";
|
|
552
558
|
|
|
553
559
|
import { _transitionToGeojson } from "./util/transitionFunctions";
|
|
560
|
+
import getDefaultPaintPropsByType from "./util/getDefaultPaintPropsByType";
|
|
561
|
+
import getDefaulLayerTypeByGeometry from "./util/getDefaultLayerTypeByGeometry";
|
|
554
562
|
|
|
555
563
|
const msPerStep = 50;
|
|
564
|
+
const legalLayerTypes = ["circle", "fill", "line"];
|
|
556
565
|
|
|
557
566
|
/**
|
|
558
567
|
* Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
|
|
@@ -561,50 +570,43 @@ const msPerStep = 50;
|
|
|
561
570
|
*/
|
|
562
571
|
const MlGeoJsonLayer = (props) => {
|
|
563
572
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
564
|
-
const
|
|
565
|
-
const oldGeojsonRef = useRef(null);
|
|
566
|
-
const mapRef = useRef(null);
|
|
573
|
+
const mapHook = useMap({ mapId: props.mapId, waitForLayer: props.insertBeforeLayer });
|
|
567
574
|
const initializedRef = useRef(false);
|
|
575
|
+
const layerId = useRef(props.layerId || "MlGeoJsonLayer-" + mapHook.componentId);
|
|
576
|
+
const layerTypeRef = useRef(undefined);
|
|
577
|
+
|
|
578
|
+
// transition effect variables
|
|
579
|
+
const oldGeojsonRef = useRef(null);
|
|
568
580
|
const transitionInProgressRef = useRef(false);
|
|
569
581
|
const transitionTimeoutRef = useRef(undefined);
|
|
570
582
|
const currentTransitionStepRef = useRef(false);
|
|
571
583
|
const transitionGeojsonDataRef = useRef([]);
|
|
572
584
|
const transitionGeojsonCommonDataRef = useRef([]);
|
|
573
|
-
const componentId = useRef(
|
|
574
|
-
(props.layerId ? <span class="branch-0 cbranch-no" title="branch not covered" >props.layerId </span>: "MlGeoJsonLayer-") + (props.idSuffix || uuidv4())
|
|
575
|
-
);
|
|
576
|
-
const layerId = useRef(props.layerId || componentId.current);
|
|
577
585
|
|
|
578
586
|
useEffect(() => {
|
|
579
|
-
let _componentId = componentId.current;
|
|
580
587
|
return () => {
|
|
581
588
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
582
589
|
<span class="missing-if-branch" title="if path not taken" >I</span>if (transitionTimeoutRef.current) {
|
|
583
590
|
<span class="cstat-no" title="statement not covered" > clearTimeout(transitionTimeoutRef.current);</span>
|
|
584
591
|
}
|
|
585
|
-
if (mapRef.current) {
|
|
586
|
-
mapRef.current.cleanup(_componentId);
|
|
587
|
-
|
|
588
|
-
mapRef.current = null;
|
|
589
|
-
}
|
|
590
592
|
};
|
|
591
593
|
}, []);
|
|
592
594
|
|
|
593
595
|
useEffect(() => {
|
|
594
|
-
if (!
|
|
596
|
+
if (!mapHook.map || !initializedRef.current) return;
|
|
595
597
|
|
|
596
598
|
<span class="cstat-no" title="statement not covered" > for (var key in props.layout) {</span>
|
|
597
|
-
<span class="cstat-no" title="statement not covered" >
|
|
599
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.setLayoutProperty(layerId.current, key, props.layout[key]);</span>
|
|
598
600
|
}
|
|
599
|
-
}, [props.layout,
|
|
601
|
+
}, [props.layout, mapHook.map, props.mapId]);
|
|
600
602
|
|
|
601
603
|
useEffect(() => {
|
|
602
|
-
if (!
|
|
604
|
+
if (!mapHook.map || !initializedRef.current) return;
|
|
603
605
|
|
|
604
606
|
<span class="cstat-no" title="statement not covered" > for (var key in props.paint) {</span>
|
|
605
|
-
<span class="cstat-no" title="statement not covered" >
|
|
607
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.setPaintProperty(layerId.current, key, props.paint[key]);</span>
|
|
606
608
|
}
|
|
607
|
-
}, [props.paint,
|
|
609
|
+
}, [props.paint, mapHook.map, props.mapId]);
|
|
608
610
|
|
|
609
611
|
const transitionToGeojson = useCallback(
|
|
610
612
|
<span class="fstat-no" title="function not covered" > (n</span>ewGeojson) => {
|
|
@@ -617,18 +619,16 @@ const MlGeoJsonLayer = (props) => {
|
|
|
617
619
|
oldGeojsonRef,
|
|
618
620
|
msPerStep,
|
|
619
621
|
currentTransitionStepRef,
|
|
620
|
-
|
|
621
|
-
|
|
622
|
+
mapHook.map,
|
|
623
|
+
layerId.current,
|
|
622
624
|
transitionTimeoutRef
|
|
623
625
|
);
|
|
624
626
|
},
|
|
625
|
-
[props]
|
|
627
|
+
[props, mapHook.map]
|
|
626
628
|
);
|
|
627
629
|
|
|
628
630
|
useEffect(() => {
|
|
629
|
-
if (!
|
|
630
|
-
// the MapLibre-gl instance (mapContext.map) is accessible here
|
|
631
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
631
|
+
if (!mapHook?.map?.getSource(layerId.current) || <span class="branch-1 cbranch-no" title="branch not covered" >!initializedRef.current)</span> return;
|
|
632
632
|
|
|
633
633
|
<span class="cstat-no" title="statement not covered" > if (</span>
|
|
634
634
|
typeof props.transitionTime !== "undefined" &&
|
|
@@ -641,79 +641,93 @@ const MlGeoJsonLayer = (props) => {
|
|
|
641
641
|
<span class="cstat-no" title="statement not covered" > transitionGeojsonCommonDataRef.current = [];</span>
|
|
642
642
|
<span class="cstat-no" title="statement not covered" > transitionToGeojson(props.geojson);</span>
|
|
643
643
|
} else {
|
|
644
|
-
<span class="cstat-no" title="statement not covered" >
|
|
644
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.getSource(layerId.current).setData(props.geojson);</span>
|
|
645
645
|
}
|
|
646
646
|
<span class="cstat-no" title="statement not covered" > oldGeojsonRef.current = props.geojson;</span>
|
|
647
647
|
}, [
|
|
648
648
|
props.geojson,
|
|
649
649
|
props.mapId,
|
|
650
|
-
|
|
650
|
+
mapHook.map,
|
|
651
651
|
props.type,
|
|
652
652
|
transitionToGeojson,
|
|
653
653
|
props.transitionTime,
|
|
654
654
|
]);
|
|
655
655
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
// the MapLibre-gl instance (mapContext.map) is accessible here
|
|
659
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
660
|
-
|
|
661
|
-
if (props.geojson) {
|
|
662
|
-
initializedRef.current = true;
|
|
663
|
-
let geojson = props.geojson;
|
|
656
|
+
const createLayer = useCallback(() => {
|
|
657
|
+
let geojson = props.geojson;
|
|
664
658
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
<span class="branch-2 cbranch-no" title="branch not covered" >
|
|
669
|
-
<span class="branch-3 cbranch-no" title="branch not covered" >
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
<span class="cstat-no" title="statement not covered" >
|
|
673
|
-
|
|
659
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
660
|
+
props.type === "line" &&
|
|
661
|
+
typeof props.transitionTime !== "undefined" &&
|
|
662
|
+
<span class="branch-2 cbranch-no" title="branch not covered" > props.transitionTime </span>&&
|
|
663
|
+
<span class="branch-3 cbranch-no" title="branch not covered" > typeof props.geojson.geometry !== "undefined"</span>
|
|
664
|
+
) {
|
|
665
|
+
var tmpChunks = <span class="cstat-no" title="statement not covered" >turf.lineChunk(props.geojson, 0.01);</span>
|
|
666
|
+
<span class="cstat-no" title="statement not covered" > geojson = tmpChunks.features[0];</span>
|
|
667
|
+
}
|
|
674
668
|
|
|
675
|
-
|
|
669
|
+
layerTypeRef.current = props.type || <span class="branch-1 cbranch-no" title="branch not covered" >getDefaulLayerTypeByGeometry(props.geojson);</span>
|
|
676
670
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
},
|
|
684
|
-
type: props.type || <span class="branch-1 cbranch-no" title="branch not covered" >"line",</span>
|
|
685
|
-
paint: props.paint || {
|
|
686
|
-
"line-color": "rgb(100,200,100)",
|
|
687
|
-
"line-width": 10,
|
|
688
|
-
},
|
|
689
|
-
layout: props.layout || {},
|
|
671
|
+
mapHook.map.addLayer(
|
|
672
|
+
{
|
|
673
|
+
id: layerId.current,
|
|
674
|
+
source: {
|
|
675
|
+
type: "geojson",
|
|
676
|
+
data: geojson,
|
|
690
677
|
},
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
678
|
+
type: layerTypeRef.current,
|
|
679
|
+
paint: props.paint || getDefaultPaintPropsByType(layerTypeRef.current),
|
|
680
|
+
layout: props.layout || {},
|
|
681
|
+
},
|
|
682
|
+
props.insertBeforeLayer,
|
|
683
|
+
mapHook.componentId
|
|
684
|
+
);
|
|
694
685
|
|
|
695
|
-
|
|
696
|
-
<span class="cstat-no" title="statement not covered" >
|
|
697
|
-
|
|
686
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (typeof props.onHover !== "undefined") {
|
|
687
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.on("mousemove", mapHook.componentId, props.onHover, mapHook.componentId);</span>
|
|
688
|
+
}
|
|
698
689
|
|
|
699
|
-
|
|
700
|
-
<span class="cstat-no" title="statement not covered" >
|
|
701
|
-
|
|
690
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (typeof props.onClick !== "undefined") {
|
|
691
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.on("click", mapHook.componentId, props.onClick, mapHook.componentId);</span>
|
|
692
|
+
}
|
|
702
693
|
|
|
703
|
-
|
|
704
|
-
<span class="cstat-no" title="statement not covered" >
|
|
705
|
-
|
|
694
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (typeof props.onLeave !== "undefined") {
|
|
695
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.on("mouseleave", mapHook.componentId, props.onLeave, mapHook.componentId);</span>
|
|
696
|
+
}
|
|
706
697
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
<span class="branch-2 cbranch-no" title="branch not covered" >
|
|
711
|
-
|
|
712
|
-
<span class="cstat-no" title="statement not covered" >
|
|
713
|
-
<span class="cstat-no" title="statement not covered" >
|
|
714
|
-
}
|
|
698
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
699
|
+
props.type === "line" &&
|
|
700
|
+
typeof props.transitionTime !== "undefined" &&
|
|
701
|
+
<span class="branch-2 cbranch-no" title="branch not covered" > typeof props.geojson.geometry !== "undefined"</span>
|
|
702
|
+
) {
|
|
703
|
+
<span class="cstat-no" title="statement not covered" > transitionToGeojson(props.geojson);</span>
|
|
704
|
+
<span class="cstat-no" title="statement not covered" > oldGeojsonRef.current = props.geojson;</span>
|
|
715
705
|
}
|
|
716
|
-
}, [
|
|
706
|
+
}, [mapHook.map, props, transitionToGeojson]);
|
|
707
|
+
|
|
708
|
+
useEffect(() => {
|
|
709
|
+
if (!mapHook.mapIsReady || !props.geojson) return;
|
|
710
|
+
|
|
711
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
712
|
+
initializedRef.current &&
|
|
713
|
+
<span class="branch-1 cbranch-no" title="branch not covered" > legalLayerTypes.indexOf(props.type) !== -1 </span>&&
|
|
714
|
+
<span class="branch-2 cbranch-no" title="branch not covered" > layerTypeRef.current </span>&&
|
|
715
|
+
<span class="branch-3 cbranch-no" title="branch not covered" > props.type !== layerTypeRef.current</span>
|
|
716
|
+
) {
|
|
717
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.cleanup(mapHook.componentId);</span>
|
|
718
|
+
} else <span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
719
|
+
initializedRef.current &&
|
|
720
|
+
(<span class="branch-1 cbranch-no" title="branch not covered" >legalLayerTypes.indexOf(props.type) === -1 </span>||
|
|
721
|
+
(<span class="branch-2 cbranch-no" title="branch not covered" >legalLayerTypes.indexOf(props.type) !== -1 </span>&& <span class="branch-3 cbranch-no" title="branch not covered" >props.type === layerTypeRef.current)</span>)
|
|
722
|
+
) {
|
|
723
|
+
<span class="cstat-no" title="statement not covered" > return;</span>
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
727
|
+
initializedRef.current = true;
|
|
728
|
+
|
|
729
|
+
createLayer();
|
|
730
|
+
}, [mapHook.mapIsReady, createLayer, props]);
|
|
717
731
|
|
|
718
732
|
return <></>;
|
|
719
733
|
};
|
|
@@ -775,11 +789,6 @@ MlGeoJsonLayer.propTypes = {
|
|
|
775
789
|
* Only works with layer type "line" and LineString GeoJSON data.
|
|
776
790
|
*/
|
|
777
791
|
transitionTime: PropTypes.number,
|
|
778
|
-
/**
|
|
779
|
-
* Id suffix string that is appended to the componentId.
|
|
780
|
-
* Probably removed soon.
|
|
781
|
-
*/
|
|
782
|
-
idSuffix: PropTypes.string,
|
|
783
792
|
};
|
|
784
793
|
|
|
785
794
|
export default MlGeoJsonLayer;
|
|
@@ -789,10 +798,9 @@ export default MlGeoJsonLayer;
|
|
|
789
798
|
</div><!-- /wrapper -->
|
|
790
799
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
791
800
|
Code coverage generated by
|
|
792
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener">istanbul</a>
|
|
793
|
-
at
|
|
801
|
+
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
802
|
+
at Sun Jan 09 2022 17:13:08 GMT+0000 (Coordinated Universal Time)
|
|
794
803
|
</div>
|
|
795
|
-
</div>
|
|
796
804
|
<script src="../../../prettify.js"></script>
|
|
797
805
|
<script>
|
|
798
806
|
window.onload = function () {
|
|
@@ -23,30 +23,30 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">65.67% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>44/67</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">55% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>33/60</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">88.88% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
42
|
+
<span class='fraction'>8/9</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">63.49% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>40/63</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -80,17 +80,17 @@
|
|
|
80
80
|
</thead>
|
|
81
81
|
<tbody><tr>
|
|
82
82
|
<td class="file medium" data-value="MlGeoJsonLayer.js"><a href="MlGeoJsonLayer.js.html">MlGeoJsonLayer.js</a></td>
|
|
83
|
-
<td data-value="
|
|
84
|
-
<div class="chart"><div class="cover-fill" style="width:
|
|
83
|
+
<td data-value="65.67" class="pic medium">
|
|
84
|
+
<div class="chart"><div class="cover-fill" style="width: 65%"></div><div class="cover-empty" style="width: 35%"></div></div>
|
|
85
85
|
</td>
|
|
86
|
-
<td data-value="
|
|
87
|
-
<td data-value="
|
|
88
|
-
<td data-value="
|
|
89
|
-
<td data-value="
|
|
90
|
-
<td data-value="
|
|
91
|
-
<td data-value="
|
|
92
|
-
<td data-value="
|
|
93
|
-
<td data-value="
|
|
86
|
+
<td data-value="65.67" class="pct medium">65.67%</td>
|
|
87
|
+
<td data-value="67" class="abs medium">44/67</td>
|
|
88
|
+
<td data-value="55" class="pct medium">55%</td>
|
|
89
|
+
<td data-value="60" class="abs medium">33/60</td>
|
|
90
|
+
<td data-value="88.88" class="pct high">88.88%</td>
|
|
91
|
+
<td data-value="9" class="abs high">8/9</td>
|
|
92
|
+
<td data-value="63.49" class="pct medium">63.49%</td>
|
|
93
|
+
<td data-value="63" class="abs medium">40/63</td>
|
|
94
94
|
</tr>
|
|
95
95
|
|
|
96
96
|
</tbody>
|
|
@@ -100,10 +100,9 @@
|
|
|
100
100
|
</div><!-- /wrapper -->
|
|
101
101
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
102
102
|
Code coverage generated by
|
|
103
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener">istanbul</a>
|
|
104
|
-
at
|
|
103
|
+
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
104
|
+
at Sun Jan 09 2022 17:13:08 GMT+0000 (Coordinated Universal Time)
|
|
105
105
|
</div>
|
|
106
|
-
</div>
|
|
107
106
|
<script src="../../../prettify.js"></script>
|
|
108
107
|
<script>
|
|
109
108
|
window.onload = function () {
|