@mapcomponents/react-maplibre 0.1.14 → 0.1.18
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 +42 -0
- package/README.md +22 -6
- package/coverage/clover.xml +448 -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 +168 -133
- 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 +898 -900
- package/dist/index.esm.js +866 -758
- 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 +101 -89
- 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/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 +2 -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">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
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">53.22% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>33/62</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">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
|
|
|
@@ -303,7 +303,21 @@
|
|
|
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>
|
|
310
|
+
<a name='L245'></a><a href='#L245'>245</a>
|
|
311
|
+
<a name='L246'></a><a href='#L246'>246</a>
|
|
312
|
+
<a name='L247'></a><a href='#L247'>247</a>
|
|
313
|
+
<a name='L248'></a><a href='#L248'>248</a>
|
|
314
|
+
<a name='L249'></a><a href='#L249'>249</a>
|
|
315
|
+
<a name='L250'></a><a href='#L250'>250</a>
|
|
316
|
+
<a name='L251'></a><a href='#L251'>251</a>
|
|
317
|
+
<a name='L252'></a><a href='#L252'>252</a>
|
|
318
|
+
<a name='L253'></a><a href='#L253'>253</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
319
|
+
<span class="cline-any cline-neutral"> </span>
|
|
320
|
+
<span class="cline-any cline-neutral"> </span>
|
|
307
321
|
<span class="cline-any cline-neutral"> </span>
|
|
308
322
|
<span class="cline-any cline-neutral"> </span>
|
|
309
323
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -313,6 +327,7 @@
|
|
|
313
327
|
<span class="cline-any cline-neutral"> </span>
|
|
314
328
|
<span class="cline-any cline-neutral"> </span>
|
|
315
329
|
<span class="cline-any cline-yes">2x</span>
|
|
330
|
+
<span class="cline-any cline-yes">2x</span>
|
|
316
331
|
<span class="cline-any cline-neutral"> </span>
|
|
317
332
|
<span class="cline-any cline-neutral"> </span>
|
|
318
333
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -321,36 +336,29 @@
|
|
|
321
336
|
<span class="cline-any cline-neutral"> </span>
|
|
322
337
|
<span class="cline-any cline-yes">2x</span>
|
|
323
338
|
<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>
|
|
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>
|
|
342
|
+
<span class="cline-any cline-yes">12x</span>
|
|
334
343
|
<span class="cline-any cline-neutral"> </span>
|
|
335
344
|
<span class="cline-any cline-neutral"> </span>
|
|
336
|
-
<span class="cline-any cline-yes">
|
|
345
|
+
<span class="cline-any cline-yes">12x</span>
|
|
346
|
+
<span class="cline-any cline-yes">12x</span>
|
|
347
|
+
<span class="cline-any cline-yes">12x</span>
|
|
348
|
+
<span class="cline-any cline-yes">12x</span>
|
|
349
|
+
<span class="cline-any cline-yes">12x</span>
|
|
350
|
+
<span class="cline-any cline-yes">12x</span>
|
|
337
351
|
<span class="cline-any cline-neutral"> </span>
|
|
338
|
-
<span class="cline-any cline-yes">
|
|
339
|
-
<span class="cline-any cline-yes">4x</span>
|
|
352
|
+
<span class="cline-any cline-yes">12x</span>
|
|
340
353
|
<span class="cline-any cline-yes">4x</span>
|
|
341
354
|
<span class="cline-any cline-neutral"> </span>
|
|
342
355
|
<span class="cline-any cline-yes">2x</span>
|
|
343
356
|
<span class="cline-any cline-no"> </span>
|
|
344
357
|
<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
358
|
<span class="cline-any cline-neutral"> </span>
|
|
350
359
|
<span class="cline-any cline-neutral"> </span>
|
|
351
360
|
<span class="cline-any cline-neutral"> </span>
|
|
352
|
-
<span class="cline-any cline-
|
|
353
|
-
<span class="cline-any cline-yes">8x</span>
|
|
361
|
+
<span class="cline-any cline-yes">12x</span>
|
|
354
362
|
<span class="cline-any cline-yes">8x</span>
|
|
355
363
|
<span class="cline-any cline-neutral"> </span>
|
|
356
364
|
<span class="cline-any cline-no"> </span>
|
|
@@ -358,15 +366,18 @@
|
|
|
358
366
|
<span class="cline-any cline-neutral"> </span>
|
|
359
367
|
<span class="cline-any cline-neutral"> </span>
|
|
360
368
|
<span class="cline-any cline-neutral"> </span>
|
|
369
|
+
<span class="cline-any cline-yes">12x</span>
|
|
361
370
|
<span class="cline-any cline-yes">8x</span>
|
|
362
|
-
<span class="cline-any cline-
|
|
371
|
+
<span class="cline-any cline-neutral"> </span>
|
|
372
|
+
<span class="cline-any cline-neutral"> </span>
|
|
373
|
+
<span class="cline-any cline-no"> </span>
|
|
363
374
|
<span class="cline-any cline-neutral"> </span>
|
|
364
375
|
<span class="cline-any cline-no"> </span>
|
|
365
376
|
<span class="cline-any cline-no"> </span>
|
|
366
377
|
<span class="cline-any cline-neutral"> </span>
|
|
367
378
|
<span class="cline-any cline-neutral"> </span>
|
|
368
379
|
<span class="cline-any cline-neutral"> </span>
|
|
369
|
-
<span class="cline-any cline-yes">
|
|
380
|
+
<span class="cline-any cline-yes">12x</span>
|
|
370
381
|
<span class="cline-any cline-neutral"> </span>
|
|
371
382
|
<span class="cline-any cline-no"> </span>
|
|
372
383
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -385,10 +396,8 @@
|
|
|
385
396
|
<span class="cline-any cline-neutral"> </span>
|
|
386
397
|
<span class="cline-any cline-neutral"> </span>
|
|
387
398
|
<span class="cline-any cline-neutral"> </span>
|
|
399
|
+
<span class="cline-any cline-yes">12x</span>
|
|
388
400
|
<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
401
|
<span class="cline-any cline-neutral"> </span>
|
|
393
402
|
<span class="cline-any cline-no"> </span>
|
|
394
403
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -413,13 +422,7 @@
|
|
|
413
422
|
<span class="cline-any cline-neutral"> </span>
|
|
414
423
|
<span class="cline-any cline-neutral"> </span>
|
|
415
424
|
<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>
|
|
425
|
+
<span class="cline-any cline-yes">12x</span>
|
|
423
426
|
<span class="cline-any cline-yes">4x</span>
|
|
424
427
|
<span class="cline-any cline-neutral"> </span>
|
|
425
428
|
<span class="cline-any cline-yes">4x</span>
|
|
@@ -451,6 +454,9 @@
|
|
|
451
454
|
<span class="cline-any cline-neutral"> </span>
|
|
452
455
|
<span class="cline-any cline-neutral"> </span>
|
|
453
456
|
<span class="cline-any cline-neutral"> </span>
|
|
457
|
+
<span class="cline-any cline-yes">4x</span>
|
|
458
|
+
<span class="cline-any cline-no"> </span>
|
|
459
|
+
<span class="cline-any cline-neutral"> </span>
|
|
454
460
|
<span class="cline-any cline-neutral"> </span>
|
|
455
461
|
<span class="cline-any cline-yes">4x</span>
|
|
456
462
|
<span class="cline-any cline-no"> </span>
|
|
@@ -461,26 +467,43 @@
|
|
|
461
467
|
<span class="cline-any cline-neutral"> </span>
|
|
462
468
|
<span class="cline-any cline-neutral"> </span>
|
|
463
469
|
<span class="cline-any cline-yes">4x</span>
|
|
470
|
+
<span class="cline-any cline-neutral"> </span>
|
|
471
|
+
<span class="cline-any cline-neutral"> </span>
|
|
472
|
+
<span class="cline-any cline-neutral"> </span>
|
|
473
|
+
<span class="cline-any cline-neutral"> </span>
|
|
474
|
+
<span class="cline-any cline-no"> </span>
|
|
464
475
|
<span class="cline-any cline-no"> </span>
|
|
465
476
|
<span class="cline-any cline-neutral"> </span>
|
|
466
477
|
<span class="cline-any cline-neutral"> </span>
|
|
478
|
+
<span class="cline-any cline-neutral"> </span>
|
|
479
|
+
<span class="cline-any cline-yes">12x</span>
|
|
480
|
+
<span class="cline-any cline-yes">8x</span>
|
|
481
|
+
<span class="cline-any cline-neutral"> </span>
|
|
467
482
|
<span class="cline-any cline-yes">4x</span>
|
|
468
483
|
<span class="cline-any cline-neutral"> </span>
|
|
469
484
|
<span class="cline-any cline-neutral"> </span>
|
|
470
485
|
<span class="cline-any cline-neutral"> </span>
|
|
471
486
|
<span class="cline-any cline-neutral"> </span>
|
|
487
|
+
<span class="cline-any cline-neutral"> </span>
|
|
472
488
|
<span class="cline-any cline-no"> </span>
|
|
489
|
+
<span class="cline-any cline-yes">4x</span>
|
|
490
|
+
<span class="cline-any cline-neutral"> </span>
|
|
491
|
+
<span class="cline-any cline-neutral"> </span>
|
|
492
|
+
<span class="cline-any cline-neutral"> </span>
|
|
493
|
+
<span class="cline-any cline-neutral"> </span>
|
|
473
494
|
<span class="cline-any cline-no"> </span>
|
|
474
495
|
<span class="cline-any cline-neutral"> </span>
|
|
475
496
|
<span class="cline-any cline-neutral"> </span>
|
|
476
497
|
<span class="cline-any cline-neutral"> </span>
|
|
498
|
+
<span class="cline-any cline-yes">4x</span>
|
|
477
499
|
<span class="cline-any cline-neutral"> </span>
|
|
478
|
-
<span class="cline-any cline-yes">
|
|
500
|
+
<span class="cline-any cline-yes">4x</span>
|
|
479
501
|
<span class="cline-any cline-neutral"> </span>
|
|
480
502
|
<span class="cline-any cline-neutral"> </span>
|
|
481
|
-
<span class="cline-any cline-yes">
|
|
503
|
+
<span class="cline-any cline-yes">12x</span>
|
|
482
504
|
<span class="cline-any cline-neutral"> </span>
|
|
483
505
|
<span class="cline-any cline-neutral"> </span>
|
|
506
|
+
<span class="cline-any cline-yes">2x</span>
|
|
484
507
|
<span class="cline-any cline-neutral"> </span>
|
|
485
508
|
<span class="cline-any cline-neutral"> </span>
|
|
486
509
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -543,16 +566,20 @@
|
|
|
543
566
|
<span class="cline-any cline-neutral"> </span>
|
|
544
567
|
<span class="cline-any cline-neutral"> </span>
|
|
545
568
|
<span class="cline-any cline-neutral"> </span>
|
|
546
|
-
<span class="cline-any cline-neutral"> </span
|
|
569
|
+
<span class="cline-any cline-neutral"> </span>
|
|
570
|
+
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import React, { useRef, useEffect, useCallback } from "react";
|
|
547
571
|
import PropTypes from "prop-types";
|
|
548
572
|
|
|
549
|
-
import { v4 as uuidv4 } from "uuid";
|
|
550
573
|
import * as turf from "@turf/turf";
|
|
551
|
-
|
|
574
|
+
|
|
575
|
+
import useMap from "../../hooks/useMap";
|
|
552
576
|
|
|
553
577
|
import { _transitionToGeojson } from "./util/transitionFunctions";
|
|
578
|
+
import getDefaultPaintPropsByType from "./util/getDefaultPaintPropsByType";
|
|
579
|
+
import getDefaulLayerTypeByGeometry from "./util/getDefaultLayerTypeByGeometry";
|
|
554
580
|
|
|
555
581
|
const msPerStep = 50;
|
|
582
|
+
const legalLayerTypes = ["circle", "fill", "line"];
|
|
556
583
|
|
|
557
584
|
/**
|
|
558
585
|
* Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
|
|
@@ -561,50 +588,46 @@ const msPerStep = 50;
|
|
|
561
588
|
*/
|
|
562
589
|
const MlGeoJsonLayer = (props) => {
|
|
563
590
|
// 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);
|
|
591
|
+
const mapHook = useMap({ mapId: props.mapId, waitForLayer: props.insertBeforeLayer });
|
|
567
592
|
const initializedRef = useRef(false);
|
|
593
|
+
const layerId = useRef(props.layerId || "MlGeoJsonLayer-" + mapHook.componentId);
|
|
594
|
+
const layerTypeRef = useRef(undefined);
|
|
595
|
+
|
|
596
|
+
// transition effect variables
|
|
597
|
+
const oldGeojsonRef = useRef(null);
|
|
568
598
|
const transitionInProgressRef = useRef(false);
|
|
569
599
|
const transitionTimeoutRef = useRef(undefined);
|
|
570
600
|
const currentTransitionStepRef = useRef(false);
|
|
571
601
|
const transitionGeojsonDataRef = useRef([]);
|
|
572
602
|
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
603
|
|
|
578
604
|
useEffect(() => {
|
|
579
|
-
let _componentId = componentId.current;
|
|
580
605
|
return () => {
|
|
581
606
|
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
582
607
|
<span class="missing-if-branch" title="if path not taken" >I</span>if (transitionTimeoutRef.current) {
|
|
583
608
|
<span class="cstat-no" title="statement not covered" > clearTimeout(transitionTimeoutRef.current);</span>
|
|
584
609
|
}
|
|
585
|
-
if (mapRef.current) {
|
|
586
|
-
mapRef.current.cleanup(_componentId);
|
|
587
|
-
|
|
588
|
-
mapRef.current = null;
|
|
589
|
-
}
|
|
590
610
|
};
|
|
591
611
|
}, []);
|
|
592
612
|
|
|
593
613
|
useEffect(() => {
|
|
594
|
-
if (!
|
|
614
|
+
if (!mapHook.map || !initializedRef.current) return;
|
|
595
615
|
|
|
596
616
|
<span class="cstat-no" title="statement not covered" > for (var key in props.layout) {</span>
|
|
597
|
-
<span class="cstat-no" title="statement not covered" >
|
|
617
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.setLayoutProperty(layerId.current, key, props.layout[key]);</span>
|
|
598
618
|
}
|
|
599
|
-
}, [props.layout,
|
|
619
|
+
}, [props.layout, mapHook.map, props.mapId]);
|
|
600
620
|
|
|
601
621
|
useEffect(() => {
|
|
602
|
-
if (!
|
|
622
|
+
if (!mapHook.map || !initializedRef.current) return;
|
|
603
623
|
|
|
604
|
-
|
|
605
|
-
<span class="cstat-no" title="statement not covered" >
|
|
624
|
+
let _paint =
|
|
625
|
+
<span class="cstat-no" title="statement not covered" > props.paint || getDefaultPaintPropsByType(layerTypeRef.current, props.defaultPaintOverrides);</span>
|
|
626
|
+
|
|
627
|
+
<span class="cstat-no" title="statement not covered" > for (var key in _paint) {</span>
|
|
628
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.setPaintProperty(layerId.current, key, _paint[key]);</span>
|
|
606
629
|
}
|
|
607
|
-
}, [props.paint,
|
|
630
|
+
}, [props.paint, mapHook.map, props.mapId, props.defaultPaintOverrides]);
|
|
608
631
|
|
|
609
632
|
const transitionToGeojson = useCallback(
|
|
610
633
|
<span class="fstat-no" title="function not covered" > (n</span>ewGeojson) => {
|
|
@@ -617,18 +640,16 @@ const MlGeoJsonLayer = (props) => {
|
|
|
617
640
|
oldGeojsonRef,
|
|
618
641
|
msPerStep,
|
|
619
642
|
currentTransitionStepRef,
|
|
620
|
-
|
|
621
|
-
|
|
643
|
+
mapHook.map,
|
|
644
|
+
layerId.current,
|
|
622
645
|
transitionTimeoutRef
|
|
623
646
|
);
|
|
624
647
|
},
|
|
625
|
-
[props]
|
|
648
|
+
[props, mapHook.map]
|
|
626
649
|
);
|
|
627
650
|
|
|
628
651
|
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
|
|
652
|
+
if (!mapHook?.map?.getSource(layerId.current) || <span class="branch-1 cbranch-no" title="branch not covered" >!initializedRef.current)</span> return;
|
|
632
653
|
|
|
633
654
|
<span class="cstat-no" title="statement not covered" > if (</span>
|
|
634
655
|
typeof props.transitionTime !== "undefined" &&
|
|
@@ -641,79 +662,95 @@ const MlGeoJsonLayer = (props) => {
|
|
|
641
662
|
<span class="cstat-no" title="statement not covered" > transitionGeojsonCommonDataRef.current = [];</span>
|
|
642
663
|
<span class="cstat-no" title="statement not covered" > transitionToGeojson(props.geojson);</span>
|
|
643
664
|
} else {
|
|
644
|
-
<span class="cstat-no" title="statement not covered" >
|
|
665
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.getSource(layerId.current).setData(props.geojson);</span>
|
|
645
666
|
}
|
|
646
667
|
<span class="cstat-no" title="statement not covered" > oldGeojsonRef.current = props.geojson;</span>
|
|
647
668
|
}, [
|
|
648
669
|
props.geojson,
|
|
649
670
|
props.mapId,
|
|
650
|
-
|
|
671
|
+
mapHook.map,
|
|
651
672
|
props.type,
|
|
652
673
|
transitionToGeojson,
|
|
653
674
|
props.transitionTime,
|
|
654
675
|
]);
|
|
655
676
|
|
|
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;
|
|
677
|
+
const createLayer = useCallback(() => {
|
|
678
|
+
let geojson = props.geojson;
|
|
664
679
|
|
|
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
|
-
|
|
680
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
681
|
+
props.type === "line" &&
|
|
682
|
+
typeof props.transitionTime !== "undefined" &&
|
|
683
|
+
<span class="branch-2 cbranch-no" title="branch not covered" > props.transitionTime </span>&&
|
|
684
|
+
<span class="branch-3 cbranch-no" title="branch not covered" > typeof props.geojson.geometry !== "undefined"</span>
|
|
685
|
+
) {
|
|
686
|
+
var tmpChunks = <span class="cstat-no" title="statement not covered" >turf.lineChunk(props.geojson, 0.01);</span>
|
|
687
|
+
<span class="cstat-no" title="statement not covered" > geojson = tmpChunks.features[0];</span>
|
|
688
|
+
}
|
|
674
689
|
|
|
675
|
-
|
|
690
|
+
layerTypeRef.current = props.type || <span class="branch-1 cbranch-no" title="branch not covered" >getDefaulLayerTypeByGeometry(props.geojson);</span>
|
|
676
691
|
|
|
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 || {},
|
|
692
|
+
mapHook.map.addLayer(
|
|
693
|
+
{
|
|
694
|
+
id: layerId.current,
|
|
695
|
+
source: {
|
|
696
|
+
type: "geojson",
|
|
697
|
+
data: geojson,
|
|
690
698
|
},
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
699
|
+
type: layerTypeRef.current,
|
|
700
|
+
paint:
|
|
701
|
+
props.paint ||
|
|
702
|
+
getDefaultPaintPropsByType(layerTypeRef.current, props.defaultPaintOverrides),
|
|
703
|
+
layout: props.layout || {},
|
|
704
|
+
},
|
|
705
|
+
props.insertBeforeLayer,
|
|
706
|
+
mapHook.componentId
|
|
707
|
+
);
|
|
694
708
|
|
|
695
|
-
|
|
696
|
-
<span class="cstat-no" title="statement not covered" >
|
|
697
|
-
|
|
709
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (typeof props.onHover !== "undefined") {
|
|
710
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.on("mousemove", mapHook.componentId, props.onHover, mapHook.componentId);</span>
|
|
711
|
+
}
|
|
698
712
|
|
|
699
|
-
|
|
700
|
-
<span class="cstat-no" title="statement not covered" >
|
|
701
|
-
|
|
713
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (typeof props.onClick !== "undefined") {
|
|
714
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.on("click", mapHook.componentId, props.onClick, mapHook.componentId);</span>
|
|
715
|
+
}
|
|
702
716
|
|
|
703
|
-
|
|
704
|
-
<span class="cstat-no" title="statement not covered" >
|
|
705
|
-
|
|
717
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (typeof props.onLeave !== "undefined") {
|
|
718
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.on("mouseleave", mapHook.componentId, props.onLeave, mapHook.componentId);</span>
|
|
719
|
+
}
|
|
706
720
|
|
|
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
|
-
}
|
|
721
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
722
|
+
props.type === "line" &&
|
|
723
|
+
typeof props.transitionTime !== "undefined" &&
|
|
724
|
+
<span class="branch-2 cbranch-no" title="branch not covered" > typeof props.geojson.geometry !== "undefined"</span>
|
|
725
|
+
) {
|
|
726
|
+
<span class="cstat-no" title="statement not covered" > transitionToGeojson(props.geojson);</span>
|
|
727
|
+
<span class="cstat-no" title="statement not covered" > oldGeojsonRef.current = props.geojson;</span>
|
|
715
728
|
}
|
|
716
|
-
}, [
|
|
729
|
+
}, [mapHook.map, props, transitionToGeojson]);
|
|
730
|
+
|
|
731
|
+
useEffect(() => {
|
|
732
|
+
if (!mapHook.mapIsReady || !props.geojson) return;
|
|
733
|
+
|
|
734
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
735
|
+
initializedRef.current &&
|
|
736
|
+
<span class="branch-1 cbranch-no" title="branch not covered" > legalLayerTypes.indexOf(props.type) !== -1 </span>&&
|
|
737
|
+
<span class="branch-2 cbranch-no" title="branch not covered" > layerTypeRef.current </span>&&
|
|
738
|
+
<span class="branch-3 cbranch-no" title="branch not covered" > props.type !== layerTypeRef.current</span>
|
|
739
|
+
) {
|
|
740
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.cleanup(mapHook.componentId);</span>
|
|
741
|
+
} else <span class="missing-if-branch" title="if path not taken" >I</span>if (
|
|
742
|
+
initializedRef.current &&
|
|
743
|
+
(<span class="branch-1 cbranch-no" title="branch not covered" >legalLayerTypes.indexOf(props.type) === -1 </span>||
|
|
744
|
+
(<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>)
|
|
745
|
+
) {
|
|
746
|
+
<span class="cstat-no" title="statement not covered" > return;</span>
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
750
|
+
initializedRef.current = true;
|
|
751
|
+
|
|
752
|
+
createLayer();
|
|
753
|
+
}, [mapHook.mapIsReady, createLayer, props]);
|
|
717
754
|
|
|
718
755
|
return <></>;
|
|
719
756
|
};
|
|
@@ -744,6 +781,10 @@ MlGeoJsonLayer.propTypes = {
|
|
|
744
781
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
745
782
|
*/
|
|
746
783
|
paint: PropTypes.object,
|
|
784
|
+
/**
|
|
785
|
+
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
786
|
+
*/
|
|
787
|
+
defaultPaintOverrides: PropTypes.object,
|
|
747
788
|
/**
|
|
748
789
|
* GeoJSON data that is supposed to be rendered by this component.
|
|
749
790
|
*/
|
|
@@ -775,11 +816,6 @@ MlGeoJsonLayer.propTypes = {
|
|
|
775
816
|
* Only works with layer type "line" and LineString GeoJSON data.
|
|
776
817
|
*/
|
|
777
818
|
transitionTime: PropTypes.number,
|
|
778
|
-
/**
|
|
779
|
-
* Id suffix string that is appended to the componentId.
|
|
780
|
-
* Probably removed soon.
|
|
781
|
-
*/
|
|
782
|
-
idSuffix: PropTypes.string,
|
|
783
819
|
};
|
|
784
820
|
|
|
785
821
|
export default MlGeoJsonLayer;
|
|
@@ -789,10 +825,9 @@ export default MlGeoJsonLayer;
|
|
|
789
825
|
</div><!-- /wrapper -->
|
|
790
826
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
791
827
|
Code coverage generated by
|
|
792
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener">istanbul</a>
|
|
793
|
-
at
|
|
828
|
+
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
829
|
+
at Thu Jan 13 2022 12:08:19 GMT+0000 (Coordinated Universal Time)
|
|
794
830
|
</div>
|
|
795
|
-
</div>
|
|
796
831
|
<script src="../../../prettify.js"></script>
|
|
797
832
|
<script>
|
|
798
833
|
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">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
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">53.22% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>33/62</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">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="
|
|
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="64.7" class="pct medium">64.7%</td>
|
|
87
|
+
<td data-value="68" class="abs medium">44/68</td>
|
|
88
|
+
<td data-value="53.22" class="pct medium">53.22%</td>
|
|
89
|
+
<td data-value="62" class="abs medium">33/62</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="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 Thu Jan 13 2022 12:08:19 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 () {
|