@mapcomponents/react-maplibre 0.1.56 → 0.1.58
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/.eslintignore +11 -0
- package/.eslintrc.js +20 -0
- package/.github/workflows/check-formatting.yml +46 -0
- package/.prettierignore +11 -0
- package/.prettierrc.json +6 -0
- package/CHANGELOG.md +20 -0
- package/coverage/clover.xml +232 -80
- package/coverage/coverage-final.json +43 -37
- package/coverage/lcov-report/index.html +71 -26
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +83 -83
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +66 -66
- package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +30 -30
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +202 -0
- package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +116 -0
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +99 -99
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +66 -66
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +221 -221
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.html +308 -308
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +497 -497
- package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +85 -85
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx.html +469 -0
- package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/index.html +116 -0
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +140 -140
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +37 -37
- package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +179 -179
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +113 -113
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +181 -181
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +58 -58
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +108 -108
- package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +39 -39
- package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +183 -183
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +163 -163
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +50 -50
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +30 -30
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +89 -89
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +11 -11
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +204 -204
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +180 -180
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +163 -163
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +136 -136
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +53 -53
- package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +123 -123
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +35 -35
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +155 -155
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +255 -255
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +66 -66
- package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
- package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +48 -48
- package/coverage/lcov-report/src/contexts/index.html +1 -1
- package/coverage/lcov-report/src/hooks/exportMap/index.html +131 -0
- package/coverage/lcov-report/src/hooks/exportMap/index.ts.html +175 -0
- package/coverage/lcov-report/src/hooks/exportMap/lib.ts.html +646 -0
- package/coverage/lcov-report/src/hooks/index.html +48 -18
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +230 -188
- package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +232 -0
- package/coverage/lcov-report/src/hooks/useMap.ts.html +72 -69
- package/coverage/lcov-report/src/hooks/useMapState.ts.html +145 -145
- package/coverage/lcov-report/src/hooks/useSource.ts.html +337 -0
- package/coverage/lcov-report/src/hooks/useWms.js.html +72 -72
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +14 -2
- package/coverage/lcov.info +450 -153
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.d.ts +24 -0
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.stories.d.ts +13 -0
- package/dist/components/MlCreatePdfForm/lib/PdfContext.d.ts +21 -0
- package/dist/components/MlCreatePdfForm/lib/PdfForm.d.ts +10 -0
- package/dist/components/MlCreatePdfForm/lib/PdfPreview.d.ts +13 -0
- package/dist/components/MlCreatePdfForm/lib/pdf.templates.d.ts +11 -0
- package/dist/components/MlFeatureEditor/lib/create_vertex.d.ts +1 -1
- package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.d.ts +22 -0
- package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.d.ts +10 -0
- package/dist/components/MlLayerSwipe/MlLayerSwipe.d.ts +1 -1
- package/dist/components/MlWmsLayer/MlWmsLayer.d.ts +2 -2
- package/dist/decorators/MapContextDecoratorHooks.d.ts +2 -0
- package/dist/decorators/ThemeWrapper.d.ts +1 -0
- package/dist/hooks/exportMap/index.d.ts +11 -0
- package/dist/hooks/exportMap/lib.d.ts +36 -0
- package/dist/hooks/useLayer.d.ts +6 -5
- package/dist/hooks/useLayerEvent.d.ts +2 -0
- package/dist/hooks/useMap.d.ts +1 -1
- package/dist/hooks/useMapState.stories.d.ts +2 -2
- package/dist/hooks/useSource.d.ts +17 -0
- package/dist/hooks/useSources.stories.d.ts +13 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +479 -190
- package/dist/index.esm.js.map +1 -1
- package/eslintErrorTest.js +10 -0
- package/package.json +7 -1
- package/public/thumbnails/MlCreatePdfForm.png +0 -0
- package/src/components/MapLibreMap/MapLibreMap.stories.js +72 -72
- package/src/components/MapLibreMap/MapLibreMap.test.js +60 -60
- package/src/components/MapLibreMap/MapLibreMap.tsx +82 -82
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.test.js +343 -343
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +619 -619
- package/src/components/MlBasicComponent.js +25 -25
- package/src/components/MlCenterPosition/MlCenterPosition.stories.js +6 -6
- package/src/components/MlCenterPosition/MlCenterPosition.tsx +65 -65
- package/src/components/MlComponentTemplate/MlComponentTemplate.stories.js +5 -5
- package/src/components/MlComponentTemplate/MlComponentTemplate.tsx +23 -23
- package/src/components/MlCreatePdfButton/{MlCreatePdfButton.meta.json → MlCreatePdfButton.meta_.json} +0 -0
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.stories.js +16 -16
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx +29 -29
- package/src/components/MlCreatePdfButton/lib/createPdf.ts +175 -175
- package/src/components/MlCreatePdfButton/lib/nominatimMap.ts +51 -51
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.doc.de.md +3 -0
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.meta.json +15 -0
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.stories.tsx +152 -0
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx +39 -0
- package/src/components/MlCreatePdfForm/lib/PdfContext.tsx +53 -0
- package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +161 -0
- package/src/components/MlCreatePdfForm/lib/PdfPreview.tsx +399 -0
- package/src/components/MlCreatePdfForm/lib/pdf.templates.ts +82 -0
- package/src/components/MlFeatureEditor/MlFeatureEditor.stories.js +55 -55
- package/src/components/MlFeatureEditor/MlFeatureEditor.test.js +105 -105
- package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +119 -119
- package/src/components/MlFeatureEditor/custom-direct-select-mode.js +208 -208
- package/src/components/MlFeatureEditor/custom-polygon-mode.js +148 -148
- package/src/components/MlFeatureEditor/custom-select-mode.js +314 -314
- package/src/components/MlFeatureEditor/lib/common_selectors.js +34 -34
- package/src/components/MlFeatureEditor/lib/constants.js +61 -61
- package/src/components/MlFeatureEditor/lib/constrain_feature_movement.js +51 -51
- package/src/components/MlFeatureEditor/lib/create_midpoint.js +30 -30
- package/src/components/MlFeatureEditor/lib/create_supplementary_points.js +82 -82
- package/src/components/MlFeatureEditor/lib/create_vertex.js +16 -16
- package/src/components/MlFeatureEditor/lib/double_click_zoom.js +23 -23
- package/src/components/MlFeatureEditor/lib/euclidean_distance.js +3 -3
- package/src/components/MlFeatureEditor/lib/features_at.js +23 -23
- package/src/components/MlFeatureEditor/lib/get_features_and_set_cursor.js +15 -15
- package/src/components/MlFeatureEditor/lib/is_click.js +8 -8
- package/src/components/MlFeatureEditor/lib/is_event_at_coordinates.js +2 -2
- package/src/components/MlFeatureEditor/lib/is_tap.js +6 -6
- package/src/components/MlFeatureEditor/lib/map_event_to_bounding_box.js +4 -4
- package/src/components/MlFeatureEditor/lib/mode_handler.js +105 -105
- package/src/components/MlFeatureEditor/lib/mouse_event_point.js +5 -5
- package/src/components/MlFeatureEditor/lib/move_features.js +33 -33
- package/src/components/MlFeatureEditor/lib/sort_features.js +25 -25
- package/src/components/MlFeatureEditor/lib/string_set.js +36 -36
- package/src/components/MlFeatureEditor/lib/string_sets_are_equal.js +2 -2
- package/src/components/MlFeatureEditor/lib/theme.js +230 -230
- package/src/components/MlFeatureEditor/lib/to_dense_array.js +1 -1
- package/src/components/MlFeatureEditor/lib/utils.js +40 -40
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.stories.js +9 -9
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.test.js +4 -4
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx +65 -65
- package/src/components/MlFollowGps/MlFollowGps.stories.js +6 -6
- package/src/components/MlFollowGps/MlFollowGps.test.js +44 -44
- package/src/components/MlFollowGps/MlFollowGps.tsx +220 -220
- package/src/components/MlGPXViewer/MlGPXViewer.stories.js +15 -15
- package/src/components/MlGPXViewer/MlGPXViewer.test.js +12 -12
- package/src/components/MlGPXViewer/MlGPXViewer.tsx +345 -345
- package/src/components/MlGPXViewer/gpxConverter.js +496 -496
- package/src/components/MlGPXViewer/util/GeoJsonContext.ts +4 -4
- package/src/components/MlGPXViewer/util/GeoJsonProvider.tsx +16 -16
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +34 -34
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.test.js +8 -8
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +84 -84
- package/src/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.ts +21 -21
- package/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.ts +27 -27
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.doc.de.md +3 -0
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.meta_.json +15 -0
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.js +19 -0
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx +128 -0
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.js +28 -28
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +8 -8
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx +162 -162
- package/src/components/MlLayer/MlLayer.stories.js +5 -5
- package/src/components/MlLayer/MlLayer.test.js +86 -86
- package/src/components/MlLayer/MlLayer.tsx +36 -36
- package/src/components/MlLayerMagnify/MlLayerMagnify.stories.js +21 -21
- package/src/components/MlLayerMagnify/MlLayerMagnify.test.js +54 -54
- package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +201 -201
- package/src/components/MlLayerSwipe/MlLayerSwipe.stories.js +20 -20
- package/src/components/MlLayerSwipe/MlLayerSwipe.test.js +54 -54
- package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +130 -130
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +194 -194
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +85 -85
- package/src/components/MlLayerSwitcher/components/LayerBox.js +57 -57
- package/src/components/MlMarker/MlMarker.stories.js +7 -7
- package/src/components/MlMarker/MlMarker.tsx +119 -119
- package/src/components/MlMeasureTool/MlMeasureTool.stories.js +64 -64
- package/src/components/MlMeasureTool/MlMeasureTool.tsx +38 -38
- package/src/components/MlNavigationCompass/MlNavigationCompass.stories.js +45 -45
- package/src/components/MlNavigationCompass/MlNavigationCompass.test.js +40 -40
- package/src/components/MlNavigationCompass/MlNavigationCompass.tsx +192 -192
- package/src/components/MlNavigationTools/MlNavigationTools.stories.js +18 -18
- package/src/components/MlNavigationTools/MlNavigationTools.tsx +173 -173
- package/src/components/MlOsmLayer/MlOsmLayer.js +49 -49
- package/src/components/MlOsmLayer/MlOsmLayer.stories_.js +29 -29
- package/src/components/MlOsmLayer/MlOsmLayer.test.js +8 -8
- package/src/components/MlScaleReference/MlScaleReference.js +82 -82
- package/src/components/MlScaleReference/MlScaleReference.stories.js +33 -35
- package/src/components/MlShareMapState/MlShareMapState.js +203 -203
- package/src/components/MlShareMapState/MlShareMapState.stories.js +68 -68
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js +201 -201
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +35 -35
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.test.js +8 -8
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +186 -186
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.stories.js +21 -21
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.test.js +24 -24
- package/src/components/MlThreeJsLayer/lib/GLTFLoader.js +3327 -3327
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.stories.js +31 -30
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.test.js +8 -8
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx +146 -146
- package/src/components/MlTransitionGeoJsonLayer/util/transitionFunctions.js +207 -207
- package/src/components/MlUseMapDebugger/MlUseMapDebugger.js +52 -52
- package/src/components/MlUseMapDebugger/MlUseMapDebugger.stories.js +13 -13
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.stories.js +27 -27
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.test.js +27 -27
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx +137 -137
- package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js +34 -34
- package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.js +7 -7
- package/src/components/MlWmsLayer/MlWmsLayer.stories.js +26 -26
- package/src/components/MlWmsLayer/MlWmsLayer.test.js +8 -8
- package/src/components/MlWmsLayer/MlWmsLayer.tsx +167 -167
- package/src/components/MlWmsLoader/MlWmsLoader.stories.js +27 -27
- package/src/components/MlWmsLoader/MlWmsLoader.tsx +254 -254
- package/src/contexts/MapComponentsProvider.test.js +229 -229
- package/src/contexts/MapContext.tsx +65 -65
- package/src/contexts/SimpleDataProvider.js +47 -47
- package/src/contexts/SimpleDataProvider.test.js +29 -29
- package/src/custom.d.tsx +14 -14
- package/src/decorators/MapContextDecorator.js +23 -25
- package/src/decorators/MapContextDecoratorHooks.js +34 -0
- package/src/decorators/MultiMapContextDecorator.js +63 -63
- package/src/decorators/NoNavToolsDecorator.js +17 -17
- package/src/decorators/ThemeWrapper.jsx +9 -0
- package/src/hooks/assets/pointWG.json +13 -0
- package/src/hooks/exportMap/index.ts +30 -0
- package/src/hooks/exportMap/lib.ts +187 -0
- package/src/hooks/useLayer.test.js +188 -188
- package/src/hooks/useLayer.ts +194 -180
- package/src/hooks/useLayerEvent.js +49 -0
- package/src/hooks/useMap.ts +67 -66
- package/src/hooks/useMapState.stories.js +78 -78
- package/src/hooks/useMapState.ts +161 -161
- package/src/hooks/useSource.ts +84 -0
- package/src/hooks/useSources.stories.js +232 -0
- package/src/hooks/useWms.js +71 -71
- package/src/index.ts +4 -0
- package/src/setupTests.js +86 -86
- package/src/ui_components/ImageLoader.js +62 -62
- package/src/ui_components/Legend.js +34 -34
- package/src/ui_components/LoadingOverlay.js +29 -29
- package/src/ui_components/LoadingOverlayContext.js +68 -68
- package/src/ui_components/Sidebar.js +80 -80
- package/src/ui_components/Tooltip.js +9 -9
- package/src/ui_components/TopToolbar.js +23 -23
- package/src/util/layerRemovalTest.js +111 -111
- package/src/util/sourceRemovalTest.js +103 -103
|
@@ -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">43.64% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>103/236</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">39.47% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>60/152</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">
|
|
40
|
+
<span class="strong">43.24% </span>
|
|
41
41
|
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>16/
|
|
42
|
+
<span class='fraction'>16/37</span>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">44.39% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>99/223</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 low'></div>
|
|
65
65
|
<div class="pad1">
|
|
66
66
|
<table class="coverage-summary">
|
|
67
67
|
<thead>
|
|
@@ -80,17 +80,32 @@
|
|
|
80
80
|
</thead>
|
|
81
81
|
<tbody><tr>
|
|
82
82
|
<td class="file medium" data-value="useLayer.ts"><a href="useLayer.ts.html">useLayer.ts</a></td>
|
|
83
|
-
<td data-value="
|
|
84
|
-
<div class="chart"><div class="cover-fill" style="width:
|
|
83
|
+
<td data-value="74.24" class="pic medium">
|
|
84
|
+
<div class="chart"><div class="cover-fill" style="width: 74%"></div><div class="cover-empty" style="width: 26%"></div></div>
|
|
85
85
|
</td>
|
|
86
|
-
<td data-value="
|
|
87
|
-
<td data-value="
|
|
88
|
-
<td data-value="
|
|
89
|
-
<td data-value="
|
|
86
|
+
<td data-value="74.24" class="pct medium">74.24%</td>
|
|
87
|
+
<td data-value="66" class="abs medium">49/66</td>
|
|
88
|
+
<td data-value="64.7" class="pct medium">64.7%</td>
|
|
89
|
+
<td data-value="68" class="abs medium">44/68</td>
|
|
90
90
|
<td data-value="87.5" class="pct high">87.5%</td>
|
|
91
91
|
<td data-value="8" class="abs high">7/8</td>
|
|
92
|
-
<td data-value="
|
|
93
|
-
<td data-value="
|
|
92
|
+
<td data-value="74.6" class="pct medium">74.6%</td>
|
|
93
|
+
<td data-value="63" class="abs medium">47/63</td>
|
|
94
|
+
</tr>
|
|
95
|
+
|
|
96
|
+
<tr>
|
|
97
|
+
<td class="file low" data-value="useLayerEvent.js"><a href="useLayerEvent.js.html">useLayerEvent.js</a></td>
|
|
98
|
+
<td data-value="0" class="pic low">
|
|
99
|
+
<div class="chart"><div class="cover-fill" style="width: 0%"></div><div class="cover-empty" style="width: 100%"></div></div>
|
|
100
|
+
</td>
|
|
101
|
+
<td data-value="0" class="pct low">0%</td>
|
|
102
|
+
<td data-value="23" class="abs low">0/23</td>
|
|
103
|
+
<td data-value="0" class="pct low">0%</td>
|
|
104
|
+
<td data-value="16" class="abs low">0/16</td>
|
|
105
|
+
<td data-value="0" class="pct low">0%</td>
|
|
106
|
+
<td data-value="3" class="abs low">0/3</td>
|
|
107
|
+
<td data-value="0" class="pct low">0%</td>
|
|
108
|
+
<td data-value="21" class="abs low">0/21</td>
|
|
94
109
|
</tr>
|
|
95
110
|
|
|
96
111
|
<tr>
|
|
@@ -123,6 +138,21 @@
|
|
|
123
138
|
<td data-value="48" class="abs medium">27/48</td>
|
|
124
139
|
</tr>
|
|
125
140
|
|
|
141
|
+
<tr>
|
|
142
|
+
<td class="file low" data-value="useSource.ts"><a href="useSource.ts.html">useSource.ts</a></td>
|
|
143
|
+
<td data-value="0" class="pic low">
|
|
144
|
+
<div class="chart"><div class="cover-fill" style="width: 0%"></div><div class="cover-empty" style="width: 100%"></div></div>
|
|
145
|
+
</td>
|
|
146
|
+
<td data-value="0" class="pct low">0%</td>
|
|
147
|
+
<td data-value="29" class="abs low">0/29</td>
|
|
148
|
+
<td data-value="0" class="pct low">0%</td>
|
|
149
|
+
<td data-value="20" class="abs low">0/20</td>
|
|
150
|
+
<td data-value="0" class="pct low">0%</td>
|
|
151
|
+
<td data-value="6" class="abs low">0/6</td>
|
|
152
|
+
<td data-value="0" class="pct low">0%</td>
|
|
153
|
+
<td data-value="26" class="abs low">0/26</td>
|
|
154
|
+
</tr>
|
|
155
|
+
|
|
126
156
|
<tr>
|
|
127
157
|
<td class="file low" data-value="useWms.js"><a href="useWms.js.html">useWms.js</a></td>
|
|
128
158
|
<td data-value="2.7" class="pic low">
|
|
@@ -146,7 +176,7 @@
|
|
|
146
176
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
147
177
|
Code coverage generated by
|
|
148
178
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
149
|
-
at
|
|
179
|
+
at Tue Oct 04 2022 11:59:51 GMT+0000 (Coordinated Universal Time)
|
|
150
180
|
</div>
|
|
151
181
|
<script src="../../prettify.js"></script>
|
|
152
182
|
<script>
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">
|
|
26
|
+
<span class="strong">74.24% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>49/66</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">64.7% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>44/68</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">74.6% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>47/63</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -261,7 +261,22 @@
|
|
|
261
261
|
<a name='L196'></a><a href='#L196'>196</a>
|
|
262
262
|
<a name='L197'></a><a href='#L197'>197</a>
|
|
263
263
|
<a name='L198'></a><a href='#L198'>198</a>
|
|
264
|
-
<a name='L199'></a><a href='#L199'>199</a
|
|
264
|
+
<a name='L199'></a><a href='#L199'>199</a>
|
|
265
|
+
<a name='L200'></a><a href='#L200'>200</a>
|
|
266
|
+
<a name='L201'></a><a href='#L201'>201</a>
|
|
267
|
+
<a name='L202'></a><a href='#L202'>202</a>
|
|
268
|
+
<a name='L203'></a><a href='#L203'>203</a>
|
|
269
|
+
<a name='L204'></a><a href='#L204'>204</a>
|
|
270
|
+
<a name='L205'></a><a href='#L205'>205</a>
|
|
271
|
+
<a name='L206'></a><a href='#L206'>206</a>
|
|
272
|
+
<a name='L207'></a><a href='#L207'>207</a>
|
|
273
|
+
<a name='L208'></a><a href='#L208'>208</a>
|
|
274
|
+
<a name='L209'></a><a href='#L209'>209</a>
|
|
275
|
+
<a name='L210'></a><a href='#L210'>210</a>
|
|
276
|
+
<a name='L211'></a><a href='#L211'>211</a>
|
|
277
|
+
<a name='L212'></a><a href='#L212'>212</a>
|
|
278
|
+
<a name='L213'></a><a href='#L213'>213</a></td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
|
279
|
+
<span class="cline-any cline-neutral"> </span>
|
|
265
280
|
<span class="cline-any cline-neutral"> </span>
|
|
266
281
|
<span class="cline-any cline-neutral"> </span>
|
|
267
282
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -331,6 +346,13 @@
|
|
|
331
346
|
<span class="cline-any cline-yes">26x</span>
|
|
332
347
|
<span class="cline-any cline-no"> </span>
|
|
333
348
|
<span class="cline-any cline-neutral"> </span>
|
|
349
|
+
<span class="cline-any cline-neutral"> </span>
|
|
350
|
+
<span class="cline-any cline-yes">26x</span>
|
|
351
|
+
<span class="cline-any cline-no"> </span>
|
|
352
|
+
<span class="cline-any cline-no"> </span>
|
|
353
|
+
<span class="cline-any cline-neutral"> </span>
|
|
354
|
+
<span class="cline-any cline-neutral"> </span>
|
|
355
|
+
<span class="cline-any cline-neutral"> </span>
|
|
334
356
|
<span class="cline-any cline-yes">26x</span>
|
|
335
357
|
<span class="cline-any cline-neutral"> </span>
|
|
336
358
|
<span class="cline-any cline-yes">26x</span>
|
|
@@ -354,6 +376,11 @@
|
|
|
354
376
|
<span class="cline-any cline-neutral"> </span>
|
|
355
377
|
<span class="cline-any cline-neutral"> </span>
|
|
356
378
|
<span class="cline-any cline-neutral"> </span>
|
|
379
|
+
<span class="cline-any cline-neutral"> </span>
|
|
380
|
+
<span class="cline-any cline-neutral"> </span>
|
|
381
|
+
<span class="cline-any cline-neutral"> </span>
|
|
382
|
+
<span class="cline-any cline-neutral"> </span>
|
|
383
|
+
<span class="cline-any cline-neutral"> </span>
|
|
357
384
|
<span class="cline-any cline-yes">26x</span>
|
|
358
385
|
<span class="cline-any cline-neutral"> </span>
|
|
359
386
|
<span class="cline-any cline-yes">26x</span>
|
|
@@ -404,6 +431,7 @@
|
|
|
404
431
|
<span class="cline-any cline-yes">49x</span>
|
|
405
432
|
<span class="cline-any cline-neutral"> </span>
|
|
406
433
|
<span class="cline-any cline-neutral"> </span>
|
|
434
|
+
<span class="cline-any cline-neutral"> </span>
|
|
407
435
|
<span class="cline-any cline-yes">12x</span>
|
|
408
436
|
<span class="cline-any cline-neutral"> </span>
|
|
409
437
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -459,201 +487,215 @@
|
|
|
459
487
|
<span class="cline-any cline-neutral"> </span>
|
|
460
488
|
<span class="cline-any cline-neutral"> </span>
|
|
461
489
|
<span class="cline-any cline-neutral"> </span>
|
|
462
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import { useState, useEffect, useCallback, useRef } from
|
|
490
|
+
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import { useState, useEffect, useCallback, useRef } from 'react';
|
|
463
491
|
|
|
464
|
-
import useMap, { useMapType } from
|
|
492
|
+
import useMap, { useMapType } from './useMap';
|
|
465
493
|
|
|
466
|
-
import { LayerSpecification } from
|
|
494
|
+
import { SourceSpecification, LayerSpecification } from 'maplibre-gl';
|
|
467
495
|
|
|
468
|
-
import MapLibreGlWrapper from
|
|
496
|
+
import MapLibreGlWrapper from '../components/MapLibreMap/lib/MapLibreGlWrapper';
|
|
469
497
|
|
|
470
|
-
import { MapLayerMouseEvent } from
|
|
471
|
-
import { GeoJSONObject } from
|
|
498
|
+
import { MapLayerMouseEvent } from 'maplibre-gl';
|
|
499
|
+
import { GeoJSONObject } from '@turf/turf';
|
|
472
500
|
|
|
473
501
|
type useLayerType = {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
502
|
+
map: MapLibreGlWrapper | undefined;
|
|
503
|
+
layer: LayerSpecification;
|
|
504
|
+
layerId: string;
|
|
505
|
+
componentId: string;
|
|
506
|
+
mapHook: useMapType;
|
|
479
507
|
};
|
|
480
508
|
|
|
481
509
|
interface useLayerProps {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
510
|
+
mapId?: string;
|
|
511
|
+
layerId?: string;
|
|
512
|
+
idPrefix?: string;
|
|
513
|
+
insertBeforeLayer?: string;
|
|
514
|
+
insertBeforeFirstSymbolLayer?: boolean;
|
|
515
|
+
geojson?: GeoJSONObject;
|
|
516
|
+
source?: SourceSpecification | string;
|
|
517
|
+
options: Partial<LayerSpecification>;
|
|
518
|
+
onHover?: MapLayerMouseEvent;
|
|
519
|
+
onClick?: MapLayerMouseEvent;
|
|
520
|
+
onLeave?: MapLayerMouseEvent;
|
|
492
521
|
}
|
|
493
522
|
|
|
494
523
|
const legalLayerTypes = [
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
524
|
+
'fill',
|
|
525
|
+
'line',
|
|
526
|
+
'symbol',
|
|
527
|
+
'circle',
|
|
528
|
+
'heatmap',
|
|
529
|
+
'fill-extrusion',
|
|
530
|
+
'raster',
|
|
531
|
+
'hillshade',
|
|
532
|
+
'background',
|
|
504
533
|
];
|
|
505
534
|
|
|
506
535
|
function useLayer(props: useLayerProps): useLayerType {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
<span class="cstat-no" title="statement not covered" >
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
&
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
<span class="cstat-no" title="statement not covered" >
|
|
635
|
-
|
|
636
|
-
<span class="cstat-no" title="statement not covered" >
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
536
|
+
const mapHook = useMap({
|
|
537
|
+
mapId: props.mapId,
|
|
538
|
+
waitForLayer: props.insertBeforeLayer,
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
const layerTypeRef = useRef<string>('');
|
|
542
|
+
const layerPaintConfRef = useRef<string>('');
|
|
543
|
+
const layerLayoutConfRef = useRef<string>('');
|
|
544
|
+
|
|
545
|
+
const [layer, setLayer] = useState<any>();
|
|
546
|
+
|
|
547
|
+
const initializedRef = useRef<boolean>(false);
|
|
548
|
+
const layerId = useRef(
|
|
549
|
+
props.layerId || (props.idPrefix ? props.idPrefix : <span class="branch-1 cbranch-no" title="branch not covered" >'Layer-')</span> + mapHook.componentId
|
|
550
|
+
);
|
|
551
|
+
|
|
552
|
+
const createLayer = useCallback(() => {
|
|
553
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (!mapHook.map) <span class="cstat-no" title="statement not covered" >return;</span>
|
|
554
|
+
|
|
555
|
+
if (mapHook.map.map.getLayer(layerId.current)) {
|
|
556
|
+
mapHook.cleanup();
|
|
557
|
+
}
|
|
558
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (mapHook.map.map.getSource(layerId.current)) {
|
|
559
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.map.removeSource(layerId.current);</span>
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (typeof props.source === 'string') {
|
|
563
|
+
<span class="cstat-no" title="statement not covered" > if (props.source === '' || !mapHook.map.map.getSource(props.source)) {</span>
|
|
564
|
+
<span class="cstat-no" title="statement not covered" > return;</span>
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
initializedRef.current = true;
|
|
569
|
+
|
|
570
|
+
mapHook.map.addLayer(
|
|
571
|
+
{
|
|
572
|
+
...props.options,
|
|
573
|
+
...(props.geojson && !props.source
|
|
574
|
+
? {
|
|
575
|
+
source: {
|
|
576
|
+
type: 'geojson',
|
|
577
|
+
data: props.geojson,
|
|
578
|
+
},
|
|
579
|
+
}
|
|
580
|
+
: {}),
|
|
581
|
+
...(props.source
|
|
582
|
+
? <span class="branch-0 cbranch-no" title="branch not covered" >{</span>
|
|
583
|
+
source: props.source,
|
|
584
|
+
}
|
|
585
|
+
: {}),
|
|
586
|
+
id: layerId.current,
|
|
587
|
+
},
|
|
588
|
+
props.insertBeforeLayer
|
|
589
|
+
? <span class="branch-0 cbranch-no" title="branch not covered" >props.insertBeforeLayer</span>
|
|
590
|
+
: props.insertBeforeFirstSymbolLayer
|
|
591
|
+
? mapHook.map.firstSymbolLayer
|
|
592
|
+
: undefined,
|
|
593
|
+
mapHook.componentId
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
setLayer(mapHook.map.map.getLayer(layerId.current));
|
|
597
|
+
|
|
598
|
+
if (typeof props.onHover !== 'undefined') {
|
|
599
|
+
mapHook.map.on('mousemove', layerId.current, props.onHover, mapHook.componentId);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
if (typeof props.onClick !== 'undefined') {
|
|
603
|
+
mapHook.map.on('click', layerId.current, props.onClick, mapHook.componentId);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
if (typeof props.onLeave !== 'undefined') {
|
|
607
|
+
mapHook.map.on('mouseleave', layerId.current, props.onLeave, mapHook.componentId);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// recreate layer if style has changed
|
|
611
|
+
mapHook.map.on(
|
|
612
|
+
'styledata',
|
|
613
|
+
<span class="fstat-no" title="function not covered" > ()</span> => {
|
|
614
|
+
<span class="cstat-no" title="statement not covered" > if (initializedRef.current && !mapHook.map?.map.getLayer(layerId.current)) {</span>
|
|
615
|
+
<span class="cstat-no" title="statement not covered" > console.log('Recreate Layer');</span>
|
|
616
|
+
<span class="cstat-no" title="statement not covered" > createLayer();</span>
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
mapHook.componentId
|
|
620
|
+
);
|
|
621
|
+
|
|
622
|
+
layerPaintConfRef.current = JSON.stringify(props.options?.paint);
|
|
623
|
+
layerLayoutConfRef.current = JSON.stringify(props.options?.layout);
|
|
624
|
+
layerTypeRef.current = props.options.type as LayerSpecification['type'];
|
|
625
|
+
}, [props, mapHook.map]);
|
|
626
|
+
|
|
627
|
+
useEffect(() => {
|
|
628
|
+
if (!mapHook.map) return;
|
|
629
|
+
|
|
630
|
+
if (
|
|
631
|
+
initializedRef.current &&
|
|
632
|
+
(legalLayerTypes.indexOf(props.options.type as LayerSpecification['type']) === -1 ||
|
|
633
|
+
(legalLayerTypes.indexOf(props.options.type as LayerSpecification['type']) !== -1 &&
|
|
634
|
+
props.options.type === layerTypeRef.current))
|
|
635
|
+
) {
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
createLayer();
|
|
640
|
+
}, [mapHook.map, props.options, createLayer]);
|
|
641
|
+
|
|
642
|
+
useEffect(() => {
|
|
643
|
+
if (!initializedRef.current || !mapHook.map?.map?.getSource(layerId.current)) return;
|
|
644
|
+
|
|
645
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
646
|
+
//@ts-ignore setData only exists on GeoJsonSource
|
|
647
|
+
mapHook.map.map.getSource(layerId.current)?.setData?.(props.geojson);
|
|
648
|
+
}, [props.geojson, mapHook.map, props.options.type]);
|
|
649
|
+
|
|
650
|
+
useEffect(() => {
|
|
651
|
+
if (
|
|
652
|
+
!mapHook.map ||
|
|
653
|
+
!mapHook.map?.map?.getLayer?.(layerId.current) ||
|
|
654
|
+
!initializedRef.current ||
|
|
655
|
+
props.options.type !== layerTypeRef.current
|
|
656
|
+
)
|
|
657
|
+
return;
|
|
658
|
+
|
|
659
|
+
let key;
|
|
660
|
+
|
|
661
|
+
const layoutString = JSON.stringify(props.options.layout);
|
|
662
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (props.options.layout && layoutString !== layerLayoutConfRef.current) {
|
|
663
|
+
const oldLayout = <span class="cstat-no" title="statement not covered" >JSON.parse(layerLayoutConfRef.current);</span>
|
|
664
|
+
|
|
665
|
+
<span class="cstat-no" title="statement not covered" > for (key in props.options.layout) {</span>
|
|
666
|
+
<span class="cstat-no" title="statement not covered" > if (props.options.layout?.[key] && props.options.layout[key] !== oldLayout[key]) {</span>
|
|
667
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);</span>
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
<span class="cstat-no" title="statement not covered" > layerLayoutConfRef.current = layoutString;</span>
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
const paintString = JSON.stringify(props.options.paint);
|
|
674
|
+
<span class="missing-if-branch" title="if path not taken" >I</span>if (paintString !== layerPaintConfRef.current) {
|
|
675
|
+
const oldPaint = <span class="cstat-no" title="statement not covered" >JSON.parse(layerPaintConfRef.current);</span>
|
|
676
|
+
<span class="cstat-no" title="statement not covered" > for (key in props.options.paint) {</span>
|
|
677
|
+
<span class="cstat-no" title="statement not covered" > if (props.options.paint?.[key] && props.options.paint[key] !== oldPaint[key]) {</span>
|
|
678
|
+
<span class="cstat-no" title="statement not covered" > mapHook.map.map.setPaintProperty(layerId.current, key, props.options.paint[key]);</span>
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
<span class="cstat-no" title="statement not covered" > layerPaintConfRef.current = paintString;</span>
|
|
682
|
+
}
|
|
683
|
+
}, [props.options, mapHook.map]);
|
|
684
|
+
|
|
685
|
+
useEffect(() => {
|
|
686
|
+
return () => {
|
|
687
|
+
initializedRef.current = false;
|
|
688
|
+
mapHook.cleanup();
|
|
689
|
+
};
|
|
690
|
+
}, []);
|
|
691
|
+
|
|
692
|
+
return {
|
|
693
|
+
map: mapHook.map,
|
|
694
|
+
layer: layer,
|
|
695
|
+
layerId: layerId.current,
|
|
696
|
+
componentId: mapHook.componentId,
|
|
697
|
+
mapHook: mapHook,
|
|
698
|
+
};
|
|
657
699
|
}
|
|
658
700
|
|
|
659
701
|
export default useLayer;
|
|
@@ -664,7 +706,7 @@ export default useLayer;
|
|
|
664
706
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
665
707
|
Code coverage generated by
|
|
666
708
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
667
|
-
at
|
|
709
|
+
at Tue Oct 04 2022 11:59:51 GMT+0000 (Coordinated Universal Time)
|
|
668
710
|
</div>
|
|
669
711
|
<script src="../../prettify.js"></script>
|
|
670
712
|
<script>
|