@mapcomponents/react-maplibre 0.1.16 → 0.1.20
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 +16 -7
- package/coverage/clover.xml +259 -285
- package/coverage/coverage-final.json +10 -10
- package/coverage/lcov-report/index.html +42 -43
- 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 +2 -3
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +2 -3
- 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 +145 -161
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +16 -17
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +2 -3
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +2 -3
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.js.html +9 -13
- package/coverage/lcov-report/src/components/MlLayer/index.html +16 -17
- 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 +2 -3
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +2 -3
- 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 +2 -3
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +2 -3
- 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 +3 -4
- 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 +14 -15
- package/coverage/lcov-report/src/hooks/useMap.js.html +23 -24
- package/coverage/lcov-report/src/hooks/useMapState.js.html +7 -50
- 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 +490 -524
- package/dist/index.esm.js +165 -153
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +3 -2
- package/src/components/MlComponentTemplate/MlComponentTemplate.js +3 -3
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +104 -109
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +35 -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 +31 -0
- package/src/components/MlLayer/MlLayer.js +0 -1
- 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/MlShareMapState/MlShareMapState.stories.js +14 -17
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +1 -3
- package/src/components/MlUseMapDebugger/MlUseMapDebugger.js +1 -7
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.js +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.js +0 -4
- package/src/hooks/useMapState.js +0 -14
- package/src/hooks/useWms.js +2 -7
- 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,9 +23,9 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">64.7% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>44/68</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
@@ -37,16 +37,16 @@
|
|
|
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">62.5% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>40/64</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -320,12 +320,7 @@
|
|
|
320
320
|
<a name='L255'></a><a href='#L255'>255</a>
|
|
321
321
|
<a name='L256'></a><a href='#L256'>256</a>
|
|
322
322
|
<a name='L257'></a><a href='#L257'>257</a>
|
|
323
|
-
<a name='L258'></a><a href='#L258'>258</a>
|
|
324
|
-
<a name='L259'></a><a href='#L259'>259</a>
|
|
325
|
-
<a name='L260'></a><a href='#L260'>260</a>
|
|
326
|
-
<a name='L261'></a><a href='#L261'>261</a>
|
|
327
|
-
<a name='L262'></a><a href='#L262'>262</a>
|
|
328
|
-
<a name='L263'></a><a href='#L263'>263</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
323
|
+
<a name='L258'></a><a href='#L258'>258</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
329
324
|
<span class="cline-any cline-neutral"> </span>
|
|
330
325
|
<span class="cline-any cline-neutral"> </span>
|
|
331
326
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -335,49 +330,36 @@
|
|
|
335
330
|
<span class="cline-any cline-neutral"> </span>
|
|
336
331
|
<span class="cline-any cline-neutral"> </span>
|
|
337
332
|
<span class="cline-any cline-neutral"> </span>
|
|
338
|
-
<span class="cline-any cline-yes">2x</span>
|
|
339
|
-
<span class="cline-any cline-neutral"> </span>
|
|
340
|
-
<span class="cline-any cline-neutral"> </span>
|
|
341
|
-
<span class="cline-any cline-neutral"> </span>
|
|
342
|
-
<span class="cline-any cline-neutral"> </span>
|
|
343
|
-
<span class="cline-any cline-neutral"> </span>
|
|
344
333
|
<span class="cline-any cline-neutral"> </span>
|
|
345
334
|
<span class="cline-any cline-yes">2x</span>
|
|
346
|
-
<span class="cline-any cline-
|
|
347
|
-
<span class="cline-any cline-yes">12x</span>
|
|
348
|
-
<span class="cline-any cline-yes">12x</span>
|
|
335
|
+
<span class="cline-any cline-yes">2x</span>
|
|
349
336
|
<span class="cline-any cline-neutral"> </span>
|
|
350
337
|
<span class="cline-any cline-neutral"> </span>
|
|
351
338
|
<span class="cline-any cline-neutral"> </span>
|
|
352
339
|
<span class="cline-any cline-neutral"> </span>
|
|
353
340
|
<span class="cline-any cline-neutral"> </span>
|
|
354
341
|
<span class="cline-any cline-neutral"> </span>
|
|
342
|
+
<span class="cline-any cline-yes">2x</span>
|
|
355
343
|
<span class="cline-any cline-neutral"> </span>
|
|
356
344
|
<span class="cline-any cline-yes">12x</span>
|
|
357
345
|
<span class="cline-any cline-yes">12x</span>
|
|
358
346
|
<span class="cline-any cline-yes">12x</span>
|
|
359
347
|
<span class="cline-any cline-yes">12x</span>
|
|
348
|
+
<span class="cline-any cline-neutral"> </span>
|
|
349
|
+
<span class="cline-any cline-neutral"> </span>
|
|
360
350
|
<span class="cline-any cline-yes">12x</span>
|
|
361
351
|
<span class="cline-any cline-yes">12x</span>
|
|
362
352
|
<span class="cline-any cline-yes">12x</span>
|
|
363
353
|
<span class="cline-any cline-yes">12x</span>
|
|
364
354
|
<span class="cline-any cline-yes">12x</span>
|
|
365
|
-
<span class="cline-any cline-neutral"> </span>
|
|
366
|
-
<span class="cline-any cline-neutral"> </span>
|
|
367
355
|
<span class="cline-any cline-yes">12x</span>
|
|
368
356
|
<span class="cline-any cline-neutral"> </span>
|
|
369
357
|
<span class="cline-any cline-yes">12x</span>
|
|
370
358
|
<span class="cline-any cline-yes">4x</span>
|
|
371
|
-
<span class="cline-any cline-yes">4x</span>
|
|
372
359
|
<span class="cline-any cline-neutral"> </span>
|
|
373
360
|
<span class="cline-any cline-yes">2x</span>
|
|
374
361
|
<span class="cline-any cline-no"> </span>
|
|
375
362
|
<span class="cline-any cline-neutral"> </span>
|
|
376
|
-
<span class="cline-any cline-yes">2x</span>
|
|
377
|
-
<span class="cline-any cline-yes">2x</span>
|
|
378
|
-
<span class="cline-any cline-neutral"> </span>
|
|
379
|
-
<span class="cline-any cline-yes">2x</span>
|
|
380
|
-
<span class="cline-any cline-neutral"> </span>
|
|
381
363
|
<span class="cline-any cline-neutral"> </span>
|
|
382
364
|
<span class="cline-any cline-neutral"> </span>
|
|
383
365
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -392,6 +374,9 @@
|
|
|
392
374
|
<span class="cline-any cline-yes">12x</span>
|
|
393
375
|
<span class="cline-any cline-yes">8x</span>
|
|
394
376
|
<span class="cline-any cline-neutral"> </span>
|
|
377
|
+
<span class="cline-any cline-neutral"> </span>
|
|
378
|
+
<span class="cline-any cline-no"> </span>
|
|
379
|
+
<span class="cline-any cline-neutral"> </span>
|
|
395
380
|
<span class="cline-any cline-no"> </span>
|
|
396
381
|
<span class="cline-any cline-no"> </span>
|
|
397
382
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -419,8 +404,6 @@
|
|
|
419
404
|
<span class="cline-any cline-yes">12x</span>
|
|
420
405
|
<span class="cline-any cline-yes">8x</span>
|
|
421
406
|
<span class="cline-any cline-neutral"> </span>
|
|
422
|
-
<span class="cline-any cline-neutral"> </span>
|
|
423
|
-
<span class="cline-any cline-neutral"> </span>
|
|
424
407
|
<span class="cline-any cline-no"> </span>
|
|
425
408
|
<span class="cline-any cline-neutral"> </span>
|
|
426
409
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -445,18 +428,12 @@
|
|
|
445
428
|
<span class="cline-any cline-neutral"> </span>
|
|
446
429
|
<span class="cline-any cline-neutral"> </span>
|
|
447
430
|
<span class="cline-any cline-yes">12x</span>
|
|
448
|
-
<span class="cline-any cline-yes">12x</span>
|
|
449
|
-
<span class="cline-any cline-neutral"> </span>
|
|
450
|
-
<span class="cline-any cline-neutral"> </span>
|
|
451
|
-
<span class="cline-any cline-neutral"> </span>
|
|
452
431
|
<span class="cline-any cline-yes">4x</span>
|
|
453
432
|
<span class="cline-any cline-neutral"> </span>
|
|
454
433
|
<span class="cline-any cline-yes">4x</span>
|
|
455
|
-
<span class="cline-any cline-no"> </span>
|
|
456
434
|
<span class="cline-any cline-neutral"> </span>
|
|
457
|
-
<span class="cline-any cline-
|
|
458
|
-
<span class="cline-any cline-
|
|
459
|
-
<span class="cline-any cline-no"> </span>
|
|
435
|
+
<span class="cline-any cline-neutral"> </span>
|
|
436
|
+
<span class="cline-any cline-neutral"> </span>
|
|
460
437
|
<span class="cline-any cline-neutral"> </span>
|
|
461
438
|
<span class="cline-any cline-neutral"> </span>
|
|
462
439
|
<span class="cline-any cline-no"> </span>
|
|
@@ -464,7 +441,6 @@
|
|
|
464
441
|
<span class="cline-any cline-neutral"> </span>
|
|
465
442
|
<span class="cline-any cline-neutral"> </span>
|
|
466
443
|
<span class="cline-any cline-yes">4x</span>
|
|
467
|
-
<span class="cline-any cline-yes">4x</span>
|
|
468
444
|
<span class="cline-any cline-neutral"> </span>
|
|
469
445
|
<span class="cline-any cline-yes">4x</span>
|
|
470
446
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -472,13 +448,9 @@
|
|
|
472
448
|
<span class="cline-any cline-neutral"> </span>
|
|
473
449
|
<span class="cline-any cline-neutral"> </span>
|
|
474
450
|
<span class="cline-any cline-neutral"> </span>
|
|
475
|
-
<span class="cline-any cline-no"> </span>
|
|
476
|
-
<span class="cline-any cline-no"> </span>
|
|
477
451
|
<span class="cline-any cline-neutral"> </span>
|
|
478
452
|
<span class="cline-any cline-neutral"> </span>
|
|
479
|
-
<span class="cline-any cline-yes">4x</span>
|
|
480
453
|
<span class="cline-any cline-neutral"> </span>
|
|
481
|
-
<span class="cline-any cline-yes">4x</span>
|
|
482
454
|
<span class="cline-any cline-neutral"> </span>
|
|
483
455
|
<span class="cline-any cline-neutral"> </span>
|
|
484
456
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -488,36 +460,51 @@
|
|
|
488
460
|
<span class="cline-any cline-neutral"> </span>
|
|
489
461
|
<span class="cline-any cline-neutral"> </span>
|
|
490
462
|
<span class="cline-any cline-neutral"> </span>
|
|
463
|
+
<span class="cline-any cline-yes">4x</span>
|
|
464
|
+
<span class="cline-any cline-no"> </span>
|
|
491
465
|
<span class="cline-any cline-neutral"> </span>
|
|
492
466
|
<span class="cline-any cline-neutral"> </span>
|
|
467
|
+
<span class="cline-any cline-yes">4x</span>
|
|
468
|
+
<span class="cline-any cline-no"> </span>
|
|
493
469
|
<span class="cline-any cline-neutral"> </span>
|
|
494
470
|
<span class="cline-any cline-neutral"> </span>
|
|
471
|
+
<span class="cline-any cline-yes">4x</span>
|
|
472
|
+
<span class="cline-any cline-no"> </span>
|
|
495
473
|
<span class="cline-any cline-neutral"> </span>
|
|
496
474
|
<span class="cline-any cline-neutral"> </span>
|
|
475
|
+
<span class="cline-any cline-yes">4x</span>
|
|
497
476
|
<span class="cline-any cline-neutral"> </span>
|
|
498
477
|
<span class="cline-any cline-neutral"> </span>
|
|
499
|
-
<span class="cline-any cline-yes">4x</span>
|
|
500
|
-
<span class="cline-any cline-no"> </span>
|
|
501
478
|
<span class="cline-any cline-neutral"> </span>
|
|
502
479
|
<span class="cline-any cline-neutral"> </span>
|
|
503
|
-
<span class="cline-any cline-
|
|
480
|
+
<span class="cline-any cline-no"> </span>
|
|
504
481
|
<span class="cline-any cline-no"> </span>
|
|
505
482
|
<span class="cline-any cline-neutral"> </span>
|
|
506
483
|
<span class="cline-any cline-neutral"> </span>
|
|
507
|
-
<span class="cline-any cline-yes">4x</span>
|
|
508
|
-
<span class="cline-any cline-no"> </span>
|
|
509
484
|
<span class="cline-any cline-neutral"> </span>
|
|
485
|
+
<span class="cline-any cline-yes">12x</span>
|
|
486
|
+
<span class="cline-any cline-yes">8x</span>
|
|
510
487
|
<span class="cline-any cline-neutral"> </span>
|
|
511
488
|
<span class="cline-any cline-yes">4x</span>
|
|
512
489
|
<span class="cline-any cline-neutral"> </span>
|
|
513
490
|
<span class="cline-any cline-neutral"> </span>
|
|
514
491
|
<span class="cline-any cline-neutral"> </span>
|
|
515
492
|
<span class="cline-any cline-neutral"> </span>
|
|
493
|
+
<span class="cline-any cline-neutral"> </span>
|
|
516
494
|
<span class="cline-any cline-no"> </span>
|
|
495
|
+
<span class="cline-any cline-yes">4x</span>
|
|
496
|
+
<span class="cline-any cline-neutral"> </span>
|
|
497
|
+
<span class="cline-any cline-neutral"> </span>
|
|
498
|
+
<span class="cline-any cline-neutral"> </span>
|
|
499
|
+
<span class="cline-any cline-neutral"> </span>
|
|
517
500
|
<span class="cline-any cline-no"> </span>
|
|
518
501
|
<span class="cline-any cline-neutral"> </span>
|
|
519
502
|
<span class="cline-any cline-neutral"> </span>
|
|
520
503
|
<span class="cline-any cline-neutral"> </span>
|
|
504
|
+
<span class="cline-any cline-yes">4x</span>
|
|
505
|
+
<span class="cline-any cline-neutral"> </span>
|
|
506
|
+
<span class="cline-any cline-yes">4x</span>
|
|
507
|
+
<span class="cline-any cline-neutral"> </span>
|
|
521
508
|
<span class="cline-any cline-neutral"> </span>
|
|
522
509
|
<span class="cline-any cline-yes">12x</span>
|
|
523
510
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -587,17 +574,22 @@
|
|
|
587
574
|
<span class="cline-any cline-neutral"> </span>
|
|
588
575
|
<span class="cline-any cline-neutral"> </span>
|
|
589
576
|
<span class="cline-any cline-neutral"> </span>
|
|
590
|
-
<span class="cline-any cline-neutral"> </span
|
|
577
|
+
<span class="cline-any cline-neutral"> </span>
|
|
578
|
+
<span class="cline-any cline-neutral"> </span>
|
|
579
|
+
<span class="cline-any cline-neutral"> </span>
|
|
580
|
+
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import React, { useRef, useEffect, useCallback } from "react";
|
|
591
581
|
import PropTypes from "prop-types";
|
|
592
582
|
|
|
593
|
-
import { v4 as uuidv4 } from "uuid";
|
|
594
583
|
import * as turf from "@turf/turf";
|
|
595
|
-
|
|
596
|
-
import
|
|
584
|
+
|
|
585
|
+
import useMap from "../../hooks/useMap";
|
|
597
586
|
|
|
598
587
|
import { _transitionToGeojson } from "./util/transitionFunctions";
|
|
588
|
+
import getDefaultPaintPropsByType from "./util/getDefaultPaintPropsByType";
|
|
589
|
+
import getDefaulLayerTypeByGeometry from "./util/getDefaultLayerTypeByGeometry";
|
|
599
590
|
|
|
600
591
|
const msPerStep = 50;
|
|
592
|
+
const legalLayerTypes = ["circle", "fill", "line"];
|
|
601
593
|
|
|
602
594
|
/**
|
|
603
595
|
* Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
|
|
@@ -606,58 +598,46 @@ const msPerStep = 50;
|
|
|
606
598
|
*/
|
|
607
599
|
const MlGeoJsonLayer = (props) => {
|
|
608
600
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
609
|
-
const
|
|
610
|
-
const mapState = useMapState({
|
|
611
|
-
mapId: props.mapId,
|
|
612
|
-
watch: {
|
|
613
|
-
viewport: false,
|
|
614
|
-
layers: true,
|
|
615
|
-
sources: false,
|
|
616
|
-
},
|
|
617
|
-
});
|
|
618
|
-
const oldGeojsonRef = useRef(null);
|
|
619
|
-
const mapRef = useRef(null);
|
|
601
|
+
const mapHook = useMap({ mapId: props.mapId, waitForLayer: props.insertBeforeLayer });
|
|
620
602
|
const initializedRef = useRef(false);
|
|
603
|
+
const layerId = useRef(props.layerId || "MlGeoJsonLayer-" + mapHook.componentId);
|
|
604
|
+
const layerTypeRef = useRef(undefined);
|
|
605
|
+
|
|
606
|
+
// transition effect variables
|
|
607
|
+
const oldGeojsonRef = useRef(null);
|
|
621
608
|
const transitionInProgressRef = useRef(false);
|
|
622
609
|
const transitionTimeoutRef = useRef(undefined);
|
|
623
610
|
const currentTransitionStepRef = useRef(false);
|
|
624
611
|
const transitionGeojsonDataRef = useRef([]);
|
|
625
612
|
const transitionGeojsonCommonDataRef = useRef([]);
|
|
626
|
-
const componentId = useRef(
|
|
627
|
-
(props.layerId ? <span class="branch-0 cbranch-no" title="branch not covered" >props.layerId </span>: "MlGeoJsonLayer-") + (props.idSuffix || uuidv4())
|
|
628
|
-
);
|
|
629
|
-
const layerId = useRef(props.layerId || componentId.current);
|
|
630
613
|
|
|
631
614
|
useEffect(() => {
|
|
632
|
-
let _componentId = componentId.current;
|
|
633
615
|
return () => {
|
|
634
616
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
635
617
|
<span class="missing-if-branch" title="if path not taken" >I</span>if (transitionTimeoutRef.current) {
|
|
636
618
|
<span class="cstat-no" title="statement not covered" > clearTimeout(transitionTimeoutRef.current);</span>
|
|
637
619
|
}
|
|
638
|
-
if (mapRef.current) {
|
|
639
|
-
mapRef.current.cleanup(_componentId);
|
|
640
|
-
|
|
641
|
-
mapRef.current = null;
|
|
642
|
-
}
|
|
643
620
|
};
|
|
644
621
|
}, []);
|
|
645
622
|
|
|
646
623
|
useEffect(() => {
|
|
647
|
-
if (!
|
|
624
|
+
if (!mapHook.map || !initializedRef.current) return;
|
|
648
625
|
|
|
649
626
|
<span class="cstat-no" title="statement not covered" > for (var key in props.layout) {</span>
|
|
650
|
-
<span class="cstat-no" title="statement not covered" >
|
|
627
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.setLayoutProperty(layerId.current, key, props.layout[key]);</span>
|
|
651
628
|
}
|
|
652
|
-
}, [props.layout,
|
|
629
|
+
}, [props.layout, mapHook.map, props.mapId]);
|
|
653
630
|
|
|
654
631
|
useEffect(() => {
|
|
655
|
-
if (!
|
|
632
|
+
if (!mapHook.map || !initializedRef.current) return;
|
|
656
633
|
|
|
657
|
-
|
|
658
|
-
<span class="cstat-no" title="statement not covered" >
|
|
634
|
+
let _paint =
|
|
635
|
+
<span class="cstat-no" title="statement not covered" > props.paint || getDefaultPaintPropsByType(layerTypeRef.current, props.defaultPaintOverrides);</span>
|
|
636
|
+
|
|
637
|
+
<span class="cstat-no" title="statement not covered" > for (var key in _paint) {</span>
|
|
638
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.setPaintProperty(layerId.current, key, _paint[key]);</span>
|
|
659
639
|
}
|
|
660
|
-
}, [props.paint,
|
|
640
|
+
}, [props.paint, mapHook.map, props.mapId, props.defaultPaintOverrides]);
|
|
661
641
|
|
|
662
642
|
const transitionToGeojson = useCallback(
|
|
663
643
|
<span class="fstat-no" title="function not covered" > (n</span>ewGeojson) => {
|
|
@@ -670,18 +650,16 @@ const MlGeoJsonLayer = (props) => {
|
|
|
670
650
|
oldGeojsonRef,
|
|
671
651
|
msPerStep,
|
|
672
652
|
currentTransitionStepRef,
|
|
673
|
-
|
|
674
|
-
|
|
653
|
+
mapHook.map,
|
|
654
|
+
layerId.current,
|
|
675
655
|
transitionTimeoutRef
|
|
676
656
|
);
|
|
677
657
|
},
|
|
678
|
-
[props]
|
|
658
|
+
[props, mapHook.map]
|
|
679
659
|
);
|
|
680
660
|
|
|
681
661
|
useEffect(() => {
|
|
682
|
-
if (!
|
|
683
|
-
// the MapLibre-gl instance (mapContext.map) is accessible here
|
|
684
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
662
|
+
if (!mapHook?.map?.getSource(layerId.current) || <span class="branch-1 cbranch-no" title="branch not covered" >!initializedRef.current)</span> return;
|
|
685
663
|
|
|
686
664
|
<span class="cstat-no" title="statement not covered" > if (</span>
|
|
687
665
|
typeof props.transitionTime !== "undefined" &&
|
|
@@ -694,92 +672,96 @@ const MlGeoJsonLayer = (props) => {
|
|
|
694
672
|
<span class="cstat-no" title="statement not covered" > transitionGeojsonCommonDataRef.current = [];</span>
|
|
695
673
|
<span class="cstat-no" title="statement not covered" > transitionToGeojson(props.geojson);</span>
|
|
696
674
|
} else {
|
|
697
|
-
<span class="cstat-no" title="statement not covered" >
|
|
675
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.getSource(layerId.current).setData(props.geojson);</span>
|
|
698
676
|
}
|
|
699
677
|
<span class="cstat-no" title="statement not covered" > oldGeojsonRef.current = props.geojson;</span>
|
|
700
678
|
}, [
|
|
701
679
|
props.geojson,
|
|
702
680
|
props.mapId,
|
|
703
|
-
|
|
681
|
+
mapHook.map,
|
|
704
682
|
props.type,
|
|
705
683
|
transitionToGeojson,
|
|
706
684
|
props.transitionTime,
|
|
707
685
|
]);
|
|
708
686
|
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
// the MapLibre-gl instance (mapContext.map) is accessible here
|
|
712
|
-
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
687
|
+
const createLayer = useCallback(() => {
|
|
688
|
+
let geojson = props.geojson;
|
|
713
689
|
|
|
714
|
-
if (
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
690
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
691
|
+
props.type === "line" &&
|
|
692
|
+
typeof props.transitionTime !== "undefined" &&
|
|
693
|
+
<span class="branch-2 cbranch-no" title="branch not covered" > props.transitionTime </span>&&
|
|
694
|
+
<span class="branch-3 cbranch-no" title="branch not covered" > typeof props.geojson.geometry !== "undefined"</span>
|
|
695
|
+
) {
|
|
696
|
+
var tmpChunks = <span class="cstat-no" title="statement not covered" >turf.lineChunk(props.geojson, 0.01);</span>
|
|
697
|
+
<span class="cstat-no" title="statement not covered" > geojson = tmpChunks.features[0];</span>
|
|
698
|
+
}
|
|
718
699
|
|
|
719
|
-
|
|
720
|
-
<span class="cstat-no" title="statement not covered" > if (layer.id === props.insertBeforeLayer) {</span>
|
|
721
|
-
<span class="cstat-no" title="statement not covered" > layerFound = true;</span>
|
|
722
|
-
}
|
|
723
|
-
});
|
|
724
|
-
<span class="cstat-no" title="statement not covered" > if (!layerFound) {</span>
|
|
725
|
-
<span class="cstat-no" title="statement not covered" > return;</span>
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
initializedRef.current = true;
|
|
729
|
-
let geojson = props.geojson;
|
|
700
|
+
layerTypeRef.current = props.type || <span class="branch-1 cbranch-no" title="branch not covered" >getDefaulLayerTypeByGeometry(props.geojson);</span>
|
|
730
701
|
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
702
|
+
mapHook.map.addLayer(
|
|
703
|
+
{
|
|
704
|
+
id: layerId.current,
|
|
705
|
+
source: {
|
|
706
|
+
type: "geojson",
|
|
707
|
+
data: geojson,
|
|
708
|
+
},
|
|
709
|
+
type: layerTypeRef.current,
|
|
710
|
+
paint:
|
|
711
|
+
props.paint ||
|
|
712
|
+
getDefaultPaintPropsByType(layerTypeRef.current, props.defaultPaintOverrides),
|
|
713
|
+
layout: props.layout || {},
|
|
714
|
+
...props.options,
|
|
715
|
+
},
|
|
716
|
+
props.insertBeforeLayer,
|
|
717
|
+
mapHook.componentId
|
|
718
|
+
);
|
|
740
719
|
|
|
741
|
-
|
|
720
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (typeof props.onHover !== "undefined") {
|
|
721
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.on("mousemove", mapHook.componentId, props.onHover, mapHook.componentId);</span>
|
|
722
|
+
}
|
|
742
723
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
source: {
|
|
747
|
-
type: "geojson",
|
|
748
|
-
data: geojson,
|
|
749
|
-
},
|
|
750
|
-
type: props.type || <span class="branch-1 cbranch-no" title="branch not covered" >"line",</span>
|
|
751
|
-
paint: props.paint || {
|
|
752
|
-
"line-color": "rgb(100,200,100)",
|
|
753
|
-
"line-width": 10,
|
|
754
|
-
},
|
|
755
|
-
layout: props.layout || {},
|
|
756
|
-
},
|
|
757
|
-
props.insertBeforeLayer,
|
|
758
|
-
componentId.current
|
|
759
|
-
);
|
|
724
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (typeof props.onClick !== "undefined") {
|
|
725
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.on("click", mapHook.componentId, props.onClick, mapHook.componentId);</span>
|
|
726
|
+
}
|
|
760
727
|
|
|
761
|
-
|
|
762
|
-
<span class="cstat-no" title="statement not covered" >
|
|
763
|
-
|
|
728
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (typeof props.onLeave !== "undefined") {
|
|
729
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.on("mouseleave", mapHook.componentId, props.onLeave, mapHook.componentId);</span>
|
|
730
|
+
}
|
|
764
731
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
732
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
733
|
+
props.type === "line" &&
|
|
734
|
+
typeof props.transitionTime !== "undefined" &&
|
|
735
|
+
<span class="branch-2 cbranch-no" title="branch not covered" > typeof props.geojson.geometry !== "undefined"</span>
|
|
736
|
+
) {
|
|
737
|
+
<span class="cstat-no" title="statement not covered" > transitionToGeojson(props.geojson);</span>
|
|
738
|
+
<span class="cstat-no" title="statement not covered" > oldGeojsonRef.current = props.geojson;</span>
|
|
739
|
+
}
|
|
740
|
+
}, [mapHook.map, props, transitionToGeojson]);
|
|
768
741
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
}
|
|
742
|
+
useEffect(() => {
|
|
743
|
+
if (!mapHook.mapIsReady || !props.geojson) return;
|
|
772
744
|
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
<span class="branch-2 cbranch-no" title="branch not covered" >
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
<span class="cstat-no" title="statement not covered" >
|
|
780
|
-
|
|
745
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
746
|
+
initializedRef.current &&
|
|
747
|
+
<span class="branch-1 cbranch-no" title="branch not covered" > legalLayerTypes.indexOf(props.type) !== -1 </span>&&
|
|
748
|
+
<span class="branch-2 cbranch-no" title="branch not covered" > layerTypeRef.current </span>&&
|
|
749
|
+
<span class="branch-3 cbranch-no" title="branch not covered" > props.type !== layerTypeRef.current</span>
|
|
750
|
+
) {
|
|
751
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.cleanup(mapHook.componentId);</span>
|
|
752
|
+
} else <span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
753
|
+
initializedRef.current &&
|
|
754
|
+
(<span class="branch-1 cbranch-no" title="branch not covered" >legalLayerTypes.indexOf(props.type) === -1 </span>||
|
|
755
|
+
(<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>)
|
|
756
|
+
) {
|
|
757
|
+
<span class="cstat-no" title="statement not covered" > return;</span>
|
|
781
758
|
}
|
|
782
|
-
|
|
759
|
+
|
|
760
|
+
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
761
|
+
initializedRef.current = true;
|
|
762
|
+
|
|
763
|
+
createLayer();
|
|
764
|
+
}, [mapHook.mapIsReady, createLayer, props]);
|
|
783
765
|
|
|
784
766
|
return <></>;
|
|
785
767
|
};
|
|
@@ -810,6 +792,14 @@ MlGeoJsonLayer.propTypes = {
|
|
|
810
792
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
811
793
|
*/
|
|
812
794
|
paint: PropTypes.object,
|
|
795
|
+
/**
|
|
796
|
+
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
797
|
+
*/
|
|
798
|
+
defaultPaintOverrides: PropTypes.object,
|
|
799
|
+
/**
|
|
800
|
+
* Javascript object that is spread into the addLayer commands first parameter.
|
|
801
|
+
*/
|
|
802
|
+
options: PropTypes.object,
|
|
813
803
|
/**
|
|
814
804
|
* GeoJSON data that is supposed to be rendered by this component.
|
|
815
805
|
*/
|
|
@@ -841,11 +831,6 @@ MlGeoJsonLayer.propTypes = {
|
|
|
841
831
|
* Only works with layer type "line" and LineString GeoJSON data.
|
|
842
832
|
*/
|
|
843
833
|
transitionTime: PropTypes.number,
|
|
844
|
-
/**
|
|
845
|
-
* Id suffix string that is appended to the componentId.
|
|
846
|
-
* Probably removed soon.
|
|
847
|
-
*/
|
|
848
|
-
idSuffix: PropTypes.string,
|
|
849
834
|
};
|
|
850
835
|
|
|
851
836
|
export default MlGeoJsonLayer;
|
|
@@ -855,10 +840,9 @@ export default MlGeoJsonLayer;
|
|
|
855
840
|
</div><!-- /wrapper -->
|
|
856
841
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
857
842
|
Code coverage generated by
|
|
858
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener">istanbul</a>
|
|
859
|
-
at
|
|
843
|
+
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
844
|
+
at Mon Jan 17 2022 10:02:27 GMT+0000 (Coordinated Universal Time)
|
|
860
845
|
</div>
|
|
861
|
-
</div>
|
|
862
846
|
<script src="../../../prettify.js"></script>
|
|
863
847
|
<script>
|
|
864
848
|
window.onload = function () {
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">64.7% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>44/68</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
@@ -37,16 +37,16 @@
|
|
|
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">62.5% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>40/64</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="64.7" class="pic medium">
|
|
84
|
+
<div class="chart"><div class="cover-fill" style="width: 64%"></div><div class="cover-empty" style="width: 36%"></div></div>
|
|
85
85
|
</td>
|
|
86
|
-
<td data-value="
|
|
87
|
-
<td data-value="
|
|
86
|
+
<td data-value="64.7" class="pct medium">64.7%</td>
|
|
87
|
+
<td data-value="68" class="abs medium">44/68</td>
|
|
88
88
|
<td data-value="53.22" class="pct medium">53.22%</td>
|
|
89
89
|
<td data-value="62" class="abs medium">33/62</td>
|
|
90
|
-
<td data-value="
|
|
91
|
-
<td data-value="9" class="abs
|
|
92
|
-
<td data-value="
|
|
93
|
-
<td data-value="
|
|
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="62.5" class="pct medium">62.5%</td>
|
|
93
|
+
<td data-value="64" class="abs medium">40/64</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 Mon Jan 17 2022 10:02:27 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 () {
|
|
@@ -294,10 +294,9 @@ export default MlImageMarkerLayer;
|
|
|
294
294
|
</div><!-- /wrapper -->
|
|
295
295
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
296
296
|
Code coverage generated by
|
|
297
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener">istanbul</a>
|
|
298
|
-
at
|
|
297
|
+
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
298
|
+
at Mon Jan 17 2022 10:02:27 GMT+0000 (Coordinated Universal Time)
|
|
299
299
|
</div>
|
|
300
|
-
</div>
|
|
301
300
|
<script src="../../../prettify.js"></script>
|
|
302
301
|
<script>
|
|
303
302
|
window.onload = function () {
|