@mapcomponents/react-maplibre 0.1.12 → 0.1.16
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 +893 -760
- package/coverage/coverage-final.json +22 -17
- package/coverage/lcov-report/index.html +183 -123
- package/coverage/lcov-report/{components → src/components}/MapLibreMap/MapLibreMap.js.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MapLibreMap/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/MlCreatePdfButton.js.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/MlFeatureEditor.js.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlFollowGps/MlFollowGps.js.html +148 -136
- package/coverage/lcov-report/{components → src/components}/MlFollowGps/index.html +24 -24
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/MlGPXViewer.js.html +66 -60
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/gpxConverter.js.html +49 -70
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/index.html +25 -25
- package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/MlGeoJsonLayer.js.html +155 -47
- package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/index.html +28 -28
- package/coverage/lcov-report/{components/MlLayer/MlLayer.js.html → src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html} +88 -121
- package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/index.html +28 -28
- package/coverage/lcov-report/{components/MlImageMarkerLayer/MlImageMarkerLayer.js.html → src/components/MlLayer/MlLayer.js.html} +116 -125
- package/coverage/lcov-report/src/components/MlLayer/index.html +117 -0
- package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/MlLayerMagnify.js.html +41 -41
- package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/index.html +24 -24
- package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/MlLayerSwipe.js.html +38 -41
- package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/index.html +24 -24
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +755 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +380 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +117 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +117 -0
- package/coverage/lcov-report/{components → src/components}/MlMarker/MlMarker.js.html +11 -11
- package/coverage/lcov-report/{components → src/components}/MlMarker/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/MlNavigationCompass.js.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlNavigationTools/MlNavigationTools.js.html +50 -41
- package/coverage/lcov-report/{components → src/components}/MlNavigationTools/index.html +18 -18
- package/coverage/lcov-report/{components → src/components}/MlOsmLayer/MlOsmLayer.js.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlOsmLayer/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlScaleReference/MlScaleReference.js.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlScaleReference/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlShareMapState/MlShareMapState.js.html +217 -25
- package/coverage/lcov-report/{components → src/components}/MlShareMapState/index.html +18 -18
- package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/MlThreeJsLayer.js.html +30 -54
- package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/index.html +24 -24
- package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/MlUseMapDebugger.js.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/MlVectorTileLayer.js.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/index.html +10 -10
- package/coverage/lcov-report/{components → src/components}/MlWmsLayer/MlWmsLayer.js.html +13 -13
- package/coverage/lcov-report/{components → src/components}/MlWmsLayer/index.html +14 -14
- package/coverage/lcov-report/{components → src/components}/MlWmsLoader/MlWmsLoader.js.html +31 -19
- package/coverage/lcov-report/{components → src/components}/MlWmsLoader/index.html +16 -16
- package/coverage/lcov-report/src/hooks/index.html +147 -0
- package/coverage/lcov-report/src/hooks/useMap.js.html +296 -0
- package/coverage/lcov-report/{hooks → src/hooks}/useMapState.js.html +91 -91
- package/coverage/lcov-report/{hooks → src/hooks}/useWms.js.html +18 -18
- package/coverage/lcov-report/src/i18n.js.html +167 -0
- package/coverage/lcov-report/src/index.html +117 -0
- package/coverage/lcov-report/src/translations/english.js.html +95 -0
- package/coverage/lcov-report/src/translations/german.js.html +95 -0
- package/coverage/lcov-report/src/translations/index.html +132 -0
- package/coverage/lcov.info +1610 -1314
- package/dist/b556faa3bc6829d2.png +0 -0
- package/dist/index.esm.js +934 -668
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -1
- package/public/assets/dop.png +0 -0
- package/public/assets/historic.png +0 -0
- package/public/assets/osm.png +0 -0
- package/public/thumbnails/MlFollowGps.png +0 -0
- package/public/thumbnails/MlThreeJsLayer.png +0 -0
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +53 -67
- package/src/components/MlComponentTemplate/MlComponentTemplate.js +6 -31
- package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -2
- package/src/components/MlFollowGps/MlFollowGps.js +92 -88
- package/src/components/MlFollowGps/MlFollowGps.meta.json +2 -2
- package/src/components/MlFollowGps/MlFollowGps.test.js +3 -5
- package/src/components/MlFollowGps/assets/marker.png +0 -0
- package/src/components/MlGPXViewer/MlGPXViewer.js +45 -43
- package/src/components/MlGPXViewer/gpxConverter.js +22 -29
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +45 -9
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +21 -57
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +6 -7
- package/src/components/MlLayer/MlLayer.js +28 -6
- package/src/components/MlLayer/MlLayer.test.js +12 -10
- package/src/components/MlLayerMagnify/MlLayerMagnify.js +3 -3
- package/src/components/MlLayerSwipe/MlLayerSwipe.js +4 -5
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.css +17 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.doc.de.md +3 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +223 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.meta_.json +15 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +106 -0
- package/src/components/MlLayerSwitcher/assets/sample_1.json +26 -0
- package/src/components/MlLayerSwitcher/assets/sample_2.json +22 -0
- package/src/components/MlLayerSwitcher/components/LayerBox.js +98 -0
- package/src/components/MlMarker/MlMarker.js +1 -1
- package/src/components/MlNavigationTools/MlNavigationTools.js +29 -26
- package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -1
- package/src/components/MlScaleReference/MlScaleReference.stories.js +25 -21
- package/src/components/MlShareMapState/MlShareMapState.js +73 -9
- package/src/components/MlShareMapState/MlShareMapState.stories.js +24 -1
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +12 -6
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +8 -15
- package/src/components/MlWmsLayer/MlWmsLayer.js +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.js +8 -4
- package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.stories.js +5 -4
- package/src/decorators/EmptyMapContextDecorator.js +11 -6
- package/src/decorators/MapContext3DDecorator.js +25 -20
- package/src/decorators/MapContextDashboardDecorator.js +7 -2
- package/src/decorators/MapContextDecorator.js +7 -3
- package/src/decorators/MapContextKlokantechBasicDecorator.js +8 -4
- package/src/decorators/MultiMapContextDecorator.js +2 -1
- package/src/hooks/useMap.js +33 -62
- package/src/hooks/useMapState.js +3 -3
- package/src/hooks/useWms.js +7 -6
- package/src/i18n.js +28 -0
- package/src/index.js +3 -0
- package/src/translations/english.js +4 -0
- package/src/translations/german.js +4 -0
- package/src/ui_components/ImageLoader.js +73 -0
- package/src/ui_components/Sidebar.js +75 -20
- package/src/ui_components/TopToolbar.js +18 -18
- package/coverage/lcov-report/components/MlLayer/index.html +0 -117
- package/coverage/lcov-report/hooks/index.html +0 -147
- package/coverage/lcov-report/hooks/useMap.js.html +0 -383
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
<html lang="en">
|
|
4
4
|
|
|
5
5
|
<head>
|
|
6
|
-
<title>Code coverage report for hooks/useMapState.js</title>
|
|
6
|
+
<title>Code coverage report for src/hooks/useMapState.js</title>
|
|
7
7
|
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="
|
|
9
|
-
<link rel="stylesheet" href="
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="
|
|
8
|
+
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
+
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
+
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
11
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
12
|
<style type='text/css'>
|
|
13
13
|
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(
|
|
14
|
+
background-image: url(../../sort-arrow-sprite.png);
|
|
15
15
|
}
|
|
16
16
|
</style>
|
|
17
17
|
</head>
|
|
@@ -19,34 +19,34 @@
|
|
|
19
19
|
<body>
|
|
20
20
|
<div class='wrapper'>
|
|
21
21
|
<div class='pad1'>
|
|
22
|
-
<h1><a href="
|
|
22
|
+
<h1><a href="../../index.html">All files</a> / <a href="index.html">src/hooks</a> useMapState.js</h1>
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">74.46% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>35/47</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">36.36% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>8/22</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">71.42% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>
|
|
42
|
+
<span class='fraction'>5/7</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">73.91% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>34/46</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
</div>
|
|
62
62
|
</template>
|
|
63
63
|
</div>
|
|
64
|
-
<div class='status-line
|
|
64
|
+
<div class='status-line medium'></div>
|
|
65
65
|
<pre><table class="coverage">
|
|
66
66
|
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
67
67
|
<a name='L2'></a><a href='#L2'>2</a>
|
|
@@ -240,20 +240,20 @@
|
|
|
240
240
|
<span class="cline-any cline-neutral"> </span>
|
|
241
241
|
<span class="cline-any cline-neutral"> </span>
|
|
242
242
|
<span class="cline-any cline-neutral"> </span>
|
|
243
|
-
<span class="cline-any cline-
|
|
243
|
+
<span class="cline-any cline-yes">49x</span>
|
|
244
244
|
<span class="cline-any cline-neutral"> </span>
|
|
245
|
-
<span class="cline-any cline-
|
|
246
|
-
<span class="cline-any cline-
|
|
245
|
+
<span class="cline-any cline-yes">49x</span>
|
|
246
|
+
<span class="cline-any cline-yes">49x</span>
|
|
247
247
|
<span class="cline-any cline-neutral"> </span>
|
|
248
|
-
<span class="cline-any cline-
|
|
248
|
+
<span class="cline-any cline-yes">49x</span>
|
|
249
249
|
<span class="cline-any cline-neutral"> </span>
|
|
250
|
-
<span class="cline-any cline-
|
|
251
|
-
<span class="cline-any cline-
|
|
250
|
+
<span class="cline-any cline-yes">49x</span>
|
|
251
|
+
<span class="cline-any cline-yes">49x</span>
|
|
252
252
|
<span class="cline-any cline-neutral"> </span>
|
|
253
|
-
<span class="cline-any cline-
|
|
254
|
-
<span class="cline-any cline-
|
|
253
|
+
<span class="cline-any cline-yes">49x</span>
|
|
254
|
+
<span class="cline-any cline-yes">49x</span>
|
|
255
255
|
<span class="cline-any cline-neutral"> </span>
|
|
256
|
-
<span class="cline-any cline-
|
|
256
|
+
<span class="cline-any cline-yes">49x</span>
|
|
257
257
|
<span class="cline-any cline-neutral"> </span>
|
|
258
258
|
<span class="cline-any cline-neutral"> </span>
|
|
259
259
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -262,7 +262,7 @@
|
|
|
262
262
|
<span class="cline-any cline-neutral"> </span>
|
|
263
263
|
<span class="cline-any cline-neutral"> </span>
|
|
264
264
|
<span class="cline-any cline-neutral"> </span>
|
|
265
|
-
<span class="cline-any cline-
|
|
265
|
+
<span class="cline-any cline-yes">49x</span>
|
|
266
266
|
<span class="cline-any cline-neutral"> </span>
|
|
267
267
|
<span class="cline-any cline-no"> </span>
|
|
268
268
|
<span class="cline-any cline-no"> </span>
|
|
@@ -281,33 +281,33 @@
|
|
|
281
281
|
<span class="cline-any cline-neutral"> </span>
|
|
282
282
|
<span class="cline-any cline-neutral"> </span>
|
|
283
283
|
<span class="cline-any cline-neutral"> </span>
|
|
284
|
-
<span class="cline-any cline-
|
|
285
|
-
<span class="cline-any cline-
|
|
286
|
-
<span class="cline-any cline-
|
|
287
|
-
<span class="cline-any cline-
|
|
288
|
-
<span class="cline-any cline-
|
|
289
|
-
<span class="cline-any cline-
|
|
284
|
+
<span class="cline-any cline-yes">49x</span>
|
|
285
|
+
<span class="cline-any cline-yes">14x</span>
|
|
286
|
+
<span class="cline-any cline-yes">14x</span>
|
|
287
|
+
<span class="cline-any cline-yes">14x</span>
|
|
288
|
+
<span class="cline-any cline-yes">14x</span>
|
|
289
|
+
<span class="cline-any cline-yes">14x</span>
|
|
290
290
|
<span class="cline-any cline-neutral"> </span>
|
|
291
291
|
<span class="cline-any cline-neutral"> </span>
|
|
292
292
|
<span class="cline-any cline-neutral"> </span>
|
|
293
|
-
<span class="cline-any cline-
|
|
294
|
-
<span class="cline-any cline-
|
|
293
|
+
<span class="cline-any cline-yes">49x</span>
|
|
294
|
+
<span class="cline-any cline-yes">14x</span>
|
|
295
295
|
<span class="cline-any cline-neutral"> </span>
|
|
296
|
-
<span class="cline-any cline-
|
|
297
|
-
<span class="cline-any cline-
|
|
298
|
-
<span class="cline-any cline-
|
|
299
|
-
<span class="cline-any cline-
|
|
296
|
+
<span class="cline-any cline-yes">14x</span>
|
|
297
|
+
<span class="cline-any cline-yes">6x</span>
|
|
298
|
+
<span class="cline-any cline-yes">6x</span>
|
|
299
|
+
<span class="cline-any cline-yes">6x</span>
|
|
300
300
|
<span class="cline-any cline-neutral"> </span>
|
|
301
|
-
<span class="cline-any cline-
|
|
301
|
+
<span class="cline-any cline-yes">6x</span>
|
|
302
302
|
<span class="cline-any cline-neutral"> </span>
|
|
303
303
|
<span class="cline-any cline-neutral"> </span>
|
|
304
304
|
<span class="cline-any cline-neutral"> </span>
|
|
305
|
-
<span class="cline-any cline-
|
|
306
|
-
<span class="cline-any cline-
|
|
305
|
+
<span class="cline-any cline-yes">49x</span>
|
|
306
|
+
<span class="cline-any cline-yes">28x</span>
|
|
307
307
|
<span class="cline-any cline-neutral"> </span>
|
|
308
308
|
<span class="cline-any cline-neutral"> </span>
|
|
309
|
-
<span class="cline-any cline-
|
|
310
|
-
<span class="cline-any cline-
|
|
309
|
+
<span class="cline-any cline-yes">14x</span>
|
|
310
|
+
<span class="cline-any cline-yes">14x</span>
|
|
311
311
|
<span class="cline-any cline-neutral"> </span>
|
|
312
312
|
<span class="cline-any cline-neutral"> </span>
|
|
313
313
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -319,7 +319,7 @@
|
|
|
319
319
|
<span class="cline-any cline-neutral"> </span>
|
|
320
320
|
<span class="cline-any cline-neutral"> </span>
|
|
321
321
|
<span class="cline-any cline-neutral"> </span>
|
|
322
|
-
<span class="cline-any cline-
|
|
322
|
+
<span class="cline-any cline-yes">14x</span>
|
|
323
323
|
<span class="cline-any cline-no"> </span>
|
|
324
324
|
<span class="cline-any cline-neutral"> </span>
|
|
325
325
|
<span class="cline-any cline-no"> </span>
|
|
@@ -334,10 +334,10 @@
|
|
|
334
334
|
<span class="cline-any cline-neutral"> </span>
|
|
335
335
|
<span class="cline-any cline-neutral"> </span>
|
|
336
336
|
<span class="cline-any cline-neutral"> </span>
|
|
337
|
-
<span class="cline-any cline-
|
|
338
|
-
<span class="cline-any cline-
|
|
337
|
+
<span class="cline-any cline-yes">14x</span>
|
|
338
|
+
<span class="cline-any cline-yes">14x</span>
|
|
339
339
|
<span class="cline-any cline-neutral"> </span>
|
|
340
|
-
<span class="cline-any cline-
|
|
340
|
+
<span class="cline-any cline-yes">14x</span>
|
|
341
341
|
<span class="cline-any cline-neutral"> </span>
|
|
342
342
|
<span class="cline-any cline-neutral"> </span>
|
|
343
343
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -349,13 +349,13 @@
|
|
|
349
349
|
<span class="cline-any cline-neutral"> </span>
|
|
350
350
|
<span class="cline-any cline-neutral"> </span>
|
|
351
351
|
<span class="cline-any cline-neutral"> </span>
|
|
352
|
-
<span class="cline-any cline-
|
|
352
|
+
<span class="cline-any cline-yes">49x</span>
|
|
353
353
|
<span class="cline-any cline-neutral"> </span>
|
|
354
354
|
<span class="cline-any cline-neutral"> </span>
|
|
355
355
|
<span class="cline-any cline-neutral"> </span>
|
|
356
356
|
<span class="cline-any cline-neutral"> </span>
|
|
357
357
|
<span class="cline-any cline-neutral"> </span>
|
|
358
|
-
<span class="cline-any cline-
|
|
358
|
+
<span class="cline-any cline-yes">4x</span>
|
|
359
359
|
<span class="cline-any cline-neutral"> </span>
|
|
360
360
|
<span class="cline-any cline-neutral"> </span>
|
|
361
361
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -367,7 +367,7 @@
|
|
|
367
367
|
<span class="cline-any cline-neutral"> </span>
|
|
368
368
|
<span class="cline-any cline-neutral"> </span>
|
|
369
369
|
<span class="cline-any cline-neutral"> </span>
|
|
370
|
-
<span class="cline-any cline-
|
|
370
|
+
<span class="cline-any cline-yes">4x</span>
|
|
371
371
|
<span class="cline-any cline-neutral"> </span>
|
|
372
372
|
<span class="cline-any cline-neutral"> </span>
|
|
373
373
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -403,22 +403,22 @@ import { MapContext } from "@mapcomponents/react-core";
|
|
|
403
403
|
*
|
|
404
404
|
* @component
|
|
405
405
|
*/
|
|
406
|
-
function
|
|
406
|
+
function useMapState(props) {
|
|
407
407
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
408
|
-
const mapContext =
|
|
408
|
+
const mapContext = useContext(MapContext);
|
|
409
409
|
|
|
410
|
-
const initializedRef =
|
|
411
|
-
const mapRef =
|
|
410
|
+
const initializedRef = useRef(false);
|
|
411
|
+
const mapRef = useRef(undefined);
|
|
412
412
|
|
|
413
|
-
const [center, setCenter] =
|
|
413
|
+
const [center, setCenter] = useState(undefined);
|
|
414
414
|
|
|
415
|
-
const [viewport, setViewport] =
|
|
416
|
-
const viewportRef =
|
|
415
|
+
const [viewport, setViewport] = useState(undefined);
|
|
416
|
+
const viewportRef = useRef(undefined);
|
|
417
417
|
|
|
418
|
-
const [layers, setLayers] =
|
|
419
|
-
const layersRef =
|
|
418
|
+
const [layers, setLayers] = useState(undefined);
|
|
419
|
+
const layersRef = useRef(undefined);
|
|
420
420
|
//const mapRef = useRef(props.map);
|
|
421
|
-
const componentId =
|
|
421
|
+
const componentId = useRef(uuidv4());
|
|
422
422
|
|
|
423
423
|
|
|
424
424
|
/**
|
|
@@ -427,13 +427,13 @@ function <span class="fstat-no" title="function not covered" >useMapState(</span
|
|
|
427
427
|
*
|
|
428
428
|
* @param {object} layer
|
|
429
429
|
*/
|
|
430
|
-
const layerIdFilter =
|
|
430
|
+
const layerIdFilter = useCallback(
|
|
431
431
|
<span class="fstat-no" title="function not covered" > (l</span>ayer) => {
|
|
432
|
-
<span class="cstat-no" title="statement not covered" > if (!props
|
|
432
|
+
<span class="cstat-no" title="statement not covered" > if (!props?.filter?.includeBaseLayers && layer.baseLayer) {</span>
|
|
433
433
|
<span class="cstat-no" title="statement not covered" > return false;</span>
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
-
<span class="cstat-no" title="statement not covered" > if (typeof props.filter
|
|
436
|
+
<span class="cstat-no" title="statement not covered" > if (typeof props.filter?.matchLayerIds !== "undefined") {</span>
|
|
437
437
|
<span class="cstat-no" title="statement not covered" > if (props.filter.matchLayerIds instanceof RegExp) {</span>
|
|
438
438
|
<span class="cstat-no" title="statement not covered" > return props.filter.matchLayerIds.test(layer.id);</span>
|
|
439
439
|
} else {
|
|
@@ -446,33 +446,33 @@ function <span class="fstat-no" title="function not covered" >useMapState(</span
|
|
|
446
446
|
[props.filter]
|
|
447
447
|
);
|
|
448
448
|
|
|
449
|
-
const refreshLayerState =
|
|
450
|
-
let _layerState =
|
|
451
|
-
let _layerStateString =
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
449
|
+
const refreshLayerState = useCallback(() => {
|
|
450
|
+
let _layerState = mapRef.current.wrapper.layerState.filter(layerIdFilter);
|
|
451
|
+
let _layerStateString = JSON.stringify(_layerState);
|
|
452
|
+
if (layersRef.current !== _layerStateString) {
|
|
453
|
+
layersRef.current = _layerStateString;
|
|
454
|
+
setLayers(_layerState);
|
|
455
455
|
}
|
|
456
|
-
},[layerIdFilter]);
|
|
456
|
+
}, [layerIdFilter]);
|
|
457
457
|
|
|
458
|
-
|
|
459
|
-
let _componentId =
|
|
458
|
+
useEffect(() => {
|
|
459
|
+
let _componentId = componentId.current;
|
|
460
460
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
461
|
+
return () => {
|
|
462
|
+
if (mapRef.current) {
|
|
463
|
+
mapRef.current.cleanup(_componentId);
|
|
464
|
+
mapRef.current = undefined;
|
|
465
465
|
}
|
|
466
|
-
|
|
466
|
+
initializedRef.current = false;
|
|
467
467
|
};
|
|
468
468
|
}, []);
|
|
469
469
|
|
|
470
|
-
|
|
471
|
-
|
|
470
|
+
useEffect(() => {
|
|
471
|
+
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
|
|
472
472
|
// the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
473
473
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
474
|
-
|
|
475
|
-
|
|
474
|
+
initializedRef.current = true;
|
|
475
|
+
mapRef.current = mapContext.getMap(props.mapId);
|
|
476
476
|
|
|
477
477
|
/*
|
|
478
478
|
mapRef.current.on(
|
|
@@ -484,7 +484,7 @@ function <span class="fstat-no" title="function not covered" >useMapState(</span
|
|
|
484
484
|
);
|
|
485
485
|
*/
|
|
486
486
|
|
|
487
|
-
<span class="
|
|
487
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (props?.watch?.viewport) {
|
|
488
488
|
<span class="cstat-no" title="statement not covered" > setViewport(mapRef.current.wrapper.viewportState);</span>
|
|
489
489
|
|
|
490
490
|
<span class="cstat-no" title="statement not covered" > mapRef.current.wrapper.on(</span>
|
|
@@ -499,10 +499,10 @@ function <span class="fstat-no" title="function not covered" >useMapState(</span
|
|
|
499
499
|
);
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
-
|
|
503
|
-
|
|
502
|
+
if (props?.watch?.layers) {
|
|
503
|
+
refreshLayerState();
|
|
504
504
|
|
|
505
|
-
|
|
505
|
+
mapRef.current.wrapper.on(
|
|
506
506
|
"layerchange",
|
|
507
507
|
refreshLayerState,
|
|
508
508
|
{
|
|
@@ -514,13 +514,13 @@ function <span class="fstat-no" title="function not covered" >useMapState(</span
|
|
|
514
514
|
}
|
|
515
515
|
}, [mapContext.mapIds, mapContext, props.mapId, refreshLayerState]);
|
|
516
516
|
|
|
517
|
-
|
|
517
|
+
return {
|
|
518
518
|
layers,
|
|
519
519
|
viewport,
|
|
520
520
|
};
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
-
|
|
523
|
+
useMapState.defaultProps = {
|
|
524
524
|
mapId: undefined,
|
|
525
525
|
watch: {
|
|
526
526
|
layers: true,
|
|
@@ -532,7 +532,7 @@ function <span class="fstat-no" title="function not covered" >useMapState(</span
|
|
|
532
532
|
},
|
|
533
533
|
};
|
|
534
534
|
|
|
535
|
-
|
|
535
|
+
useMapState.propTypes = {
|
|
536
536
|
/**
|
|
537
537
|
* Id of the target MapLibre instance in mapContext
|
|
538
538
|
*/
|
|
@@ -565,17 +565,17 @@ export default useMapState;
|
|
|
565
565
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
566
566
|
Code coverage generated by
|
|
567
567
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener">istanbul</a>
|
|
568
|
-
at
|
|
568
|
+
at Thu Dec 23 2021 12:19:00 GMT+0000 (Coordinated Universal Time)
|
|
569
569
|
</div>
|
|
570
570
|
</div>
|
|
571
|
-
<script src="
|
|
571
|
+
<script src="../../prettify.js"></script>
|
|
572
572
|
<script>
|
|
573
573
|
window.onload = function () {
|
|
574
574
|
prettyPrint();
|
|
575
575
|
};
|
|
576
576
|
</script>
|
|
577
|
-
<script src="
|
|
578
|
-
<script src="
|
|
577
|
+
<script src="../../sorter.js"></script>
|
|
578
|
+
<script src="../../block-navigation.js"></script>
|
|
579
579
|
</body>
|
|
580
580
|
</html>
|
|
581
581
|
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
<html lang="en">
|
|
4
4
|
|
|
5
5
|
<head>
|
|
6
|
-
<title>Code coverage report for hooks/useWms.js</title>
|
|
6
|
+
<title>Code coverage report for src/hooks/useWms.js</title>
|
|
7
7
|
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="
|
|
9
|
-
<link rel="stylesheet" href="
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="
|
|
8
|
+
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
+
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
+
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
11
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
12
|
<style type='text/css'>
|
|
13
13
|
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(
|
|
14
|
+
background-image: url(../../sort-arrow-sprite.png);
|
|
15
15
|
}
|
|
16
16
|
</style>
|
|
17
17
|
</head>
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<body>
|
|
20
20
|
<div class='wrapper'>
|
|
21
21
|
<div class='pad1'>
|
|
22
|
-
<h1><a href="
|
|
22
|
+
<h1><a href="../../index.html">All files</a> / <a href="index.html">src/hooks</a> useWms.js</h1>
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
@@ -185,6 +185,7 @@
|
|
|
185
185
|
<span class="cline-any cline-neutral"> </span>
|
|
186
186
|
<span class="cline-any cline-no"> </span>
|
|
187
187
|
<span class="cline-any cline-no"> </span>
|
|
188
|
+
<span class="cline-any cline-neutral"> </span>
|
|
188
189
|
<span class="cline-any cline-no"> </span>
|
|
189
190
|
<span class="cline-any cline-neutral"> </span>
|
|
190
191
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -252,7 +253,6 @@
|
|
|
252
253
|
<span class="cline-any cline-neutral"> </span>
|
|
253
254
|
<span class="cline-any cline-neutral"> </span>
|
|
254
255
|
<span class="cline-any cline-neutral"> </span>
|
|
255
|
-
<span class="cline-any cline-neutral"> </span>
|
|
256
256
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import { useContext, useState, useEffect, useRef } from "react";
|
|
257
257
|
import { v4 as uuidv4 } from "uuid";
|
|
258
258
|
import WMSCapabilities from "wms-capabilities";
|
|
@@ -280,12 +280,13 @@ function <span class="fstat-no" title="function not covered" >useWms(</span>prop
|
|
|
280
280
|
// extract URL parameters from the given URL
|
|
281
281
|
<span class="cstat-no" title="statement not covered" > clearState();</span>
|
|
282
282
|
<span class="cstat-no" title="statement not covered" > setError(undefined);</span>
|
|
283
|
-
|
|
283
|
+
|
|
284
|
+
<span class="cstat-no" title="statement not covered" > if (!url) <span class="cstat-no" title="statement not covered" >return;</span></span>
|
|
284
285
|
|
|
285
286
|
let _propsUrlParams;
|
|
286
|
-
let _wmsUrl = <span class="cstat-no" title="statement not covered" >
|
|
287
|
-
<span class="cstat-no" title="statement not covered" > if (
|
|
288
|
-
<span class="cstat-no" title="statement not covered" > _propsUrlParams =
|
|
287
|
+
let _wmsUrl = <span class="cstat-no" title="statement not covered" >url;</span>
|
|
288
|
+
<span class="cstat-no" title="statement not covered" > if (url.indexOf("?") !== -1) {</span>
|
|
289
|
+
<span class="cstat-no" title="statement not covered" > _propsUrlParams = url.split("?");</span>
|
|
289
290
|
<span class="cstat-no" title="statement not covered" > _wmsUrl = _propsUrlParams[0];</span>
|
|
290
291
|
}
|
|
291
292
|
let _urlParamsFromUrl = <span class="cstat-no" title="statement not covered" >new URLSearchParams(_propsUrlParams?.[1]);</span>
|
|
@@ -317,7 +318,7 @@ function <span class="fstat-no" title="function not covered" >useWms(</span>prop
|
|
|
317
318
|
<span class="cstat-no" title="statement not covered" > console.log(error);</span>
|
|
318
319
|
<span class="cstat-no" title="statement not covered" > setError(error.message);</span>
|
|
319
320
|
});
|
|
320
|
-
}, [
|
|
321
|
+
}, [url, props.urlParameters]);
|
|
321
322
|
|
|
322
323
|
<span class="cstat-no" title="statement not covered" > useEffect(<span class="fstat-no" title="function not covered" >()</span> => {</span>
|
|
323
324
|
<span class="cstat-no" title="statement not covered" > if (!capabilities?.Service) <span class="cstat-no" title="statement not covered" >return;</span></span>
|
|
@@ -347,25 +348,24 @@ function <span class="fstat-no" title="function not covered" >useWms(</span>prop
|
|
|
347
348
|
},
|
|
348
349
|
};
|
|
349
350
|
|
|
350
|
-
export default useWms
|
|
351
|
-
</pre></td></tr></table></pre>
|
|
351
|
+
export default useWms;</pre></td></tr></table></pre>
|
|
352
352
|
|
|
353
353
|
<div class='push'></div><!-- for sticky footer -->
|
|
354
354
|
</div><!-- /wrapper -->
|
|
355
355
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
356
356
|
Code coverage generated by
|
|
357
357
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener">istanbul</a>
|
|
358
|
-
at
|
|
358
|
+
at Thu Dec 23 2021 12:19:00 GMT+0000 (Coordinated Universal Time)
|
|
359
359
|
</div>
|
|
360
360
|
</div>
|
|
361
|
-
<script src="
|
|
361
|
+
<script src="../../prettify.js"></script>
|
|
362
362
|
<script>
|
|
363
363
|
window.onload = function () {
|
|
364
364
|
prettyPrint();
|
|
365
365
|
};
|
|
366
366
|
</script>
|
|
367
|
-
<script src="
|
|
368
|
-
<script src="
|
|
367
|
+
<script src="../../sorter.js"></script>
|
|
368
|
+
<script src="../../block-navigation.js"></script>
|
|
369
369
|
</body>
|
|
370
370
|
</html>
|
|
371
371
|
|