@mapcomponents/react-maplibre 0.1.62 → 0.1.64
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/.babelrc +21 -2
- package/.editorconfig +1 -1
- package/.eslintrc.js +11 -1
- package/.github/workflows/check-catalogue-metadata-schema.yml +19 -0
- package/.storybook/main.js +0 -1
- package/.storybook/preview.js +0 -2
- package/CHANGELOG.md +43 -0
- package/coverage/clover.xml +864 -1037
- package/coverage/coverage-final.json +32 -21
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +170 -95
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +24 -24
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +5 -5
- package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +2 -2
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx.html +148 -0
- package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +22 -7
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +72 -42
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +15 -15
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +86 -35
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/{MlSpatialElevationProfile/MlSpatialElevationProfile.js.html → MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js.html} +215 -320
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js.html +649 -0
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.tsx.html +112 -0
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.tsx.html +115 -0
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/index.html +161 -0
- package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGpxViewer/MlGpxViewer.tsx.html +394 -0
- package/coverage/lcov-report/src/components/MlGpxViewer/index.html +116 -0
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +63 -285
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +21 -21
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +58 -76
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +58 -61
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +11 -11
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +30 -21
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/ColorPicker.tsx.html +214 -0
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerList.tsx.html +121 -0
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerListItem.tsx.html +412 -0
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx.html +463 -0
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/index.html +161 -0
- package/coverage/lcov-report/src/components/{MlGPXViewer/MlGPXViewer.tsx.html → MlSketchTool/MlSketchTool.tsx.html} +271 -589
- package/coverage/lcov-report/src/components/{MlGPXViewer → MlSketchTool}/index.html +22 -37
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.tsx.html +514 -0
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +21 -21
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +20 -206
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +10 -7
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +5 -5
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +111 -57
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +19 -19
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +201 -144
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +9 -9
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +23 -23
- package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
- package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
- package/coverage/lcov-report/src/contexts/index.html +1 -1
- package/coverage/lcov-report/src/hooks/index.html +50 -50
- package/coverage/lcov-report/src/hooks/useCameraFollowPath/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useCameraFollowPath/useCameraFollowPath.tsx.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/index.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/lib.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useGpx/index.html +116 -0
- package/coverage/lcov-report/src/hooks/useGpx/useGpx.tsx.html +295 -0
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +132 -66
- package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayerHoverPopup/index.html +116 -0
- package/coverage/lcov-report/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx.html +331 -0
- package/coverage/lcov-report/src/hooks/useMap.ts.html +47 -47
- package/coverage/lcov-report/src/hooks/useMapState.ts.html +54 -54
- package/coverage/lcov-report/src/hooks/useSource.ts.html +57 -57
- package/coverage/lcov-report/src/hooks/{useWms.js.html → useWms.ts.html} +54 -15
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +6 -6
- package/coverage/lcov.info +1724 -1974
- package/cypress/support/commands.ts +37 -0
- package/cypress/support/component-index.html +12 -0
- package/cypress/support/component.ts +46 -0
- package/cypress.config.ts +101 -0
- package/dist/components/MapLibreMap/MapLibreMap.d.ts +1 -1
- package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +53 -27
- package/dist/components/MlCenterPosition/MlCenterPosition.d.ts +3 -2
- package/dist/components/MlCenterPosition/MlCenterPosition.stories.d.ts +35 -16
- package/dist/components/MlComponentTemplate/MlComponentTemplate.d.ts +1 -1
- package/dist/components/MlComponentTemplate/MlComponentTemplate.stories.d.ts +12 -9
- package/dist/components/MlCreatePdfButton/MlCreatePdfButton.d.ts +1 -1
- package/dist/components/MlCreatePdfButton/MlCreatePdfButton.stories.d.ts +12 -9
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.cy.d.ts +1 -0
- package/dist/components/MlCreatePdfForm/lib/PdfPreview.d.ts +1 -1
- package/dist/components/MlFeatureEditor/MlFeatureEditor.d.ts +10 -4
- package/dist/components/MlFeatureEditor/lib/double_click_zoom.d.ts +0 -2
- package/dist/components/MlFeatureEditor/lib/theme.d.ts +1 -1
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +23 -12
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +12 -11
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.d.ts +2 -0
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.d.ts +2 -0
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.d.ts +3 -0
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.d.ts +3 -0
- package/dist/components/MlGpxViewer/MlGpxViewer.d.ts +30 -0
- package/dist/components/MlGpxViewer/MlGpxViewer.stories.d.ts +17 -0
- package/dist/components/MlGpxViewer/MlGpxViewer.test.d.ts +1 -0
- package/dist/components/MlGpxViewer/util/GeoJsonContext.d.ts +10 -0
- package/dist/components/MlGpxViewer/util/GeoJsonProvider.d.ts +4 -0
- package/dist/components/MlGpxViewer/util/MetadataDrawer.d.ts +7 -0
- package/dist/components/MlGpxViewer/util/MlGpxDemoLoader.d.ts +10 -0
- package/dist/components/MlGpxViewer/util/MlGpxViewerInstructions.d.ts +3 -0
- package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.d.ts +11 -2
- package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.d.ts +7 -9
- package/dist/components/MlLayerMagnify/MlLayerMagnify.d.ts +8 -2
- package/dist/components/MlLayerMagnify/MlLayerMagnify.stories.d.ts +13 -9
- package/dist/components/MlLayerSwipe/MlLayerSwipe.d.ts +13 -3
- package/dist/components/MlLayerSwipe/MlLayerSwipe.stories.d.ts +12 -10
- package/dist/components/MlSketchTool/LayerList/ColorPicker.d.ts +9 -0
- package/dist/components/MlSketchTool/LayerList/LayerList.d.ts +5 -0
- package/dist/components/MlSketchTool/LayerList/LayerListItem.d.ts +11 -0
- package/dist/components/MlSketchTool/LayerList/LayerPropertyForm.d.ts +9 -0
- package/dist/components/MlSketchTool/MlSketchTool.d.ts +29 -0
- package/dist/components/MlSketchTool/MlSketchTool.stories.d.ts +10 -0
- package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.d.ts +33 -14
- package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.d.ts +18 -15
- package/dist/components/MlSpatialElevationProfile/util/getElevationData.d.ts +14 -0
- package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +3 -67
- package/dist/components/MlWmsLayer/MlWmsLayer.d.ts +7 -4
- package/dist/components/MlWmsLoader/MlWmsLoader.d.ts +17 -10
- package/dist/components/MlWmsLoader/MlWmsLoader.stories.d.ts +23 -12
- package/dist/components/MlWmsLoader/utils/MlWmsLoaderInstructions.d.ts +3 -0
- package/dist/components/MlWmsLoader/utils/WMSLinks.d.ts +6 -0
- package/dist/contexts/SimpleDataProvider.d.ts +1 -1
- package/dist/custom.d.d.ts +1 -1
- package/dist/decorators/ThemeWrapper.d.ts +3 -1
- package/dist/hooks/useGpx/lib/gpxConverter.d.ts +11 -0
- package/dist/hooks/useGpx/useGpx.d.ts +26 -0
- package/dist/hooks/useGpx/useGpx.stories.d.ts +10 -0
- package/dist/hooks/useLayer.d.ts +14 -8
- package/dist/hooks/useLayerHoverPopup/useLayerHoverPopup.d.ts +23 -0
- package/dist/hooks/useLayerHoverPopup/useLayerHoverPopup.stories.d.ts +10 -0
- package/dist/hooks/useMap.d.ts +2 -2
- package/dist/hooks/useMap.test.d.ts +1 -0
- package/dist/hooks/useMapState.d.ts +3 -3
- package/dist/hooks/useSource.d.ts +3 -3
- package/dist/hooks/useWms.d.ts +24 -16
- package/dist/index.d.ts +5 -5
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +9327 -14844
- package/dist/index.esm.js.map +1 -1
- package/dist/setupTests.d.ts +6 -5
- package/dist/ui_components/Dropzone.d.ts +5 -0
- package/dist/ui_components/ImageLoader.d.ts +8 -1
- package/dist/ui_components/LoadingOverlayContext.d.ts +11 -11
- package/dist/ui_components/Sidebar.d.ts +10 -1
- package/dist/ui_components/Tooltip.d.ts +1 -1
- package/dist/ui_components/TopToolbar.d.ts +7 -1
- package/dist/ui_components/UploadButton.d.ts +6 -0
- package/dist/util/BubbleForInstructions.d.ts +2 -0
- package/dist/util/Instructions.d.ts +13 -0
- package/package.json +195 -185
- package/public/assets/sample1.gpx +3003 -0
- package/public/assets/sample2.gpx +1264 -0
- package/public/assets/sample3.gpx +912 -0
- package/{src/components/MlImageMarkerLayer → public}/assets/wg-marker.png +0 -0
- package/public/index.html +0 -4
- package/public/thumbnails/MlSketchTool.png +0 -0
- package/public/thumbnails/useCameraFollowPath.png +0 -0
- package/scripts/build-catalogue-meta.js +35 -11
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +230 -188
- package/src/components/MlCenterPosition/MlCenterPosition.meta_.json +1 -2
- package/src/components/MlCenterPosition/MlCenterPosition.stories.tsx +20 -0
- package/src/components/MlCenterPosition/MlCenterPosition.tsx +4 -4
- package/src/components/MlComponentTemplate/MlComponentTemplate.meta_.json +1 -2
- package/src/components/MlComponentTemplate/{MlComponentTemplate.stories.js → MlComponentTemplate.stories.tsx} +2 -2
- package/src/components/MlComponentTemplate/MlComponentTemplate.tsx +1 -1
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta_.json +1 -2
- package/src/components/MlCreatePdfButton/{MlCreatePdfButton.stories.js → MlCreatePdfButton.stories.tsx} +1 -1
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx +1 -1
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx +21 -0
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.meta.json +1 -2
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.stories.tsx +1 -3
- package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +25 -2
- package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -3
- package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +39 -29
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.meta.json +1 -2
- package/src/components/MlFollowGps/MlFollowGps.meta.json +1 -2
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -2
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.tsx +191 -0
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +47 -30
- package/src/components/MlGeoJsonLayer/assets/earthquake.json +109937 -0
- package/src/components/MlGeoJsonLayer/assets/sample_1.json +138 -24
- package/src/components/MlGeoJsonLayer/assets/sample_2.json +140 -20
- package/src/components/MlGeoJsonLayer/assets/wg_locations.json +65 -0
- package/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js +189 -0
- package/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js +188 -0
- package/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.tsx +9 -0
- package/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.tsx +10 -0
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.meta_.json +1 -2
- package/src/components/{MlGPXViewer/MlGPXViewer.doc.de.md → MlGpxViewer/MlGpxViewer.doc.de.md} +0 -0
- package/src/components/{MlGPXViewer/MlGPXViewer.doc.en.md → MlGpxViewer/MlGpxViewer.doc.en.md} +0 -0
- package/src/components/{MlGPXViewer/MlGPXViewer.meta.json → MlGpxViewer/MlGpxViewer.meta.json} +2 -3
- package/src/components/MlGpxViewer/MlGpxViewer.stories.tsx +109 -0
- package/src/components/MlGpxViewer/MlGpxViewer.test.js +53 -0
- package/src/components/MlGpxViewer/MlGpxViewer.tsx +103 -0
- package/src/components/{MlGPXViewer → MlGpxViewer}/util/GeoJsonContext.ts +0 -0
- package/src/components/{MlGPXViewer → MlGpxViewer}/util/GeoJsonProvider.tsx +0 -0
- package/src/components/MlGpxViewer/util/MetadataDrawer.tsx +38 -0
- package/src/components/MlGpxViewer/util/MlGpxDemoLoader.tsx +128 -0
- package/src/components/MlGpxViewer/util/MlGpxViewerInstructions.tsx +68 -0
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.meta_.json +1 -2
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.tsx +41 -0
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +27 -8
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx +41 -115
- package/src/components/MlLayer/MlLayer.meta_.json +1 -2
- package/src/components/MlLayerMagnify/MlLayerMagnify.meta.json +1 -2
- package/src/components/MlLayerMagnify/MlLayerMagnify.stories.tsx +44 -0
- package/src/components/MlLayerMagnify/{MlLayerMagnify.test.js → MlLayerMagnify.test.tsx} +15 -18
- package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +55 -61
- package/src/components/MlLayerSwipe/MlLayerSwipe.meta.json +1 -2
- package/src/components/MlLayerSwipe/{MlLayerSwipe.stories.js → MlLayerSwipe.stories.tsx} +9 -11
- package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +47 -48
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.meta_.json +1 -2
- package/src/components/MlLayerSwitcher/components/LayerBox.js +22 -19
- package/src/components/MlMarker/MlMarker.meta_.json +1 -2
- package/src/components/MlMeasureTool/MlMeasureTool.meta.json +1 -2
- package/src/components/MlNavigationCompass/MlNavigationCompass.meta.json +1 -2
- package/src/components/MlNavigationTools/MlNavigationTools.meta.json +1 -2
- package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -2
- package/src/components/MlShareMapState/MlShareMapState.meta_.json +1 -2
- package/src/components/MlSketchTool/LayerList/ColorPicker.tsx +43 -0
- package/src/components/MlSketchTool/LayerList/LayerList.tsx +12 -0
- package/src/components/MlSketchTool/LayerList/LayerListItem.tsx +109 -0
- package/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx +126 -0
- package/src/components/MlSketchTool/MlSketchTool.doc.de.md +3 -0
- package/src/components/MlSketchTool/MlSketchTool.meta.json +14 -0
- package/src/components/MlSketchTool/MlSketchTool.stories.js +26 -0
- package/src/components/MlSketchTool/MlSketchTool.tsx +271 -0
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.meta.json +1 -2
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.tsx +121 -0
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.test.js +30 -1
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.tsx +143 -0
- package/src/components/MlSpatialElevationProfile/util/getElevationData.tsx +103 -0
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.meta.json +1 -2
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.meta.json +3 -4
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.stories.js +2 -3
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx +17 -79
- package/src/components/MlUseMapDebugger/MlUseMapDebugger.meta_.json +1 -2
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.meta.json +1 -2
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx +3 -2
- package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.meta_.json +1 -2
- package/src/components/MlWmsLayer/MlWmsLayer.tsx +59 -41
- package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -2
- package/src/components/MlWmsLoader/MlWmsLoader.stories.tsx +89 -0
- package/src/components/MlWmsLoader/MlWmsLoader.tsx +141 -122
- package/src/components/MlWmsLoader/utils/MlWmsLoaderInstructions.tsx +50 -0
- package/src/components/MlWmsLoader/utils/WMSLinks.tsx +128 -0
- package/src/decorators/MapContextDecorator.js +1 -1
- package/src/decorators/MapContextDecoratorHooks.js +1 -1
- package/src/decorators/ThemeWrapper.tsx +9 -0
- package/src/hooks/useCameraFollowPath/useCameraFollowPath.meta.json +1 -2
- package/src/{components/MlGPXViewer → hooks/useGpx/lib}/gpxConverter.js +1 -0
- package/src/hooks/useGpx/useGpx.doc.de.md +3 -0
- package/src/hooks/useGpx/useGpx.meta_.json +15 -0
- package/src/{components/MlCenterPosition/MlCenterPosition.stories.js → hooks/useGpx/useGpx.stories.js} +4 -5
- package/src/hooks/useGpx/useGpx.tsx +70 -0
- package/src/hooks/useLayer.ts +32 -10
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.doc.de.md +3 -0
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.meta_.json +15 -0
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.stories.js +20 -0
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx +82 -0
- package/src/hooks/useMap.test.tsx +48 -0
- package/src/hooks/useMap.ts +8 -8
- package/src/hooks/useSource.ts +4 -4
- package/src/hooks/{useWms.js → useWms.ts} +24 -11
- package/src/index.ts +5 -5
- package/src/setupTests.js +18 -15
- package/src/ui_components/Dropzone.tsx +104 -0
- package/src/ui_components/{ImageLoader.js → ImageLoader.tsx} +30 -25
- package/src/ui_components/{LoadingOverlayContext.js → LoadingOverlayContext.tsx} +12 -15
- package/src/ui_components/Sidebar.tsx +82 -0
- package/src/ui_components/Tooltip.tsx +17 -0
- package/src/ui_components/TopToolbar.tsx +26 -0
- package/src/ui_components/UploadButton.tsx +57 -0
- package/src/util/BubbleForInstructions.js +46 -0
- package/src/util/Instructions.tsx +60 -0
- package/tsconfig.json +39 -58
- package/config/getHttpsConfig.js +0 -66
- package/config/modules.js +0 -134
- package/config/pnpTs.js +0 -35
- package/config/webpack.config.js +0 -757
- package/config/webpackDevServer.config.js +0 -130
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +0 -1645
- package/scripts/start.js +0 -166
- package/src/components/MlGPXViewer/MlGPXViewer.stories.js +0 -31
- package/src/components/MlGPXViewer/MlGPXViewer.test.js +0 -28
- package/src/components/MlGPXViewer/MlGPXViewer.tsx +0 -377
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +0 -66
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.js +0 -45
- package/src/components/MlLayerMagnify/MlLayerMagnify.stories.js +0 -41
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js +0 -224
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +0 -57
- package/src/components/MlWmsLoader/MlWmsLoader.stories.js +0 -47
- package/src/decorators/ThemeWrapper.jsx +0 -9
- package/src/ui_components/Legend.js +0 -44
- package/src/ui_components/LoadingOverlay.js +0 -41
- package/src/ui_components/Sidebar.js +0 -100
- package/src/ui_components/Tooltip.js +0 -21
- package/src/ui_components/TopToolbar.js +0 -29
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import useGpx from "./useGpx";
|
|
4
4
|
|
|
5
5
|
import mapContextDecorator from "../../decorators/MapContextDecorator";
|
|
6
6
|
|
|
7
7
|
const storyoptions = {
|
|
8
|
-
title: "MapComponents/
|
|
9
|
-
component:
|
|
8
|
+
title: "MapComponents/useGpx",
|
|
9
|
+
component: useGpx,
|
|
10
10
|
argTypes: {
|
|
11
11
|
},
|
|
12
12
|
decorators: mapContextDecorator,
|
|
13
|
-
parameters: { docs: { source: { type: 'code' } } }
|
|
14
13
|
};
|
|
15
14
|
export default storyoptions;
|
|
16
15
|
|
|
17
|
-
const Template = (
|
|
16
|
+
const Template = () => <useGpx />;
|
|
18
17
|
|
|
19
18
|
export const ExampleConfig = Template.bind({});
|
|
20
19
|
ExampleConfig.parameters = {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import toGeoJSON from './lib/gpxConverter';
|
|
3
|
+
import { FeatureCollection } from '@turf/turf';
|
|
4
|
+
|
|
5
|
+
interface useGpxProps {
|
|
6
|
+
/**
|
|
7
|
+
* a string containing GPX data that is supposed to be parsed and converted to GeoJSON by this hook
|
|
8
|
+
*/
|
|
9
|
+
data?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface MetadataType {
|
|
13
|
+
title: string;
|
|
14
|
+
value: string;
|
|
15
|
+
id: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* useGpx hook converts GPX data to GeoJSON
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
const useGpx = (props: useGpxProps) => {
|
|
23
|
+
const [geojson, setGeojson] = useState<FeatureCollection | undefined>();
|
|
24
|
+
const [metadata, setMetadata] = useState<MetadataType[]>([]);
|
|
25
|
+
|
|
26
|
+
const parseGpx = (gpxAsString: string) => {
|
|
27
|
+
try {
|
|
28
|
+
setMetadata([]);
|
|
29
|
+
const domParser = new DOMParser();
|
|
30
|
+
const gpxDoc = domParser.parseFromString(gpxAsString, 'application/xml');
|
|
31
|
+
const metadata = gpxDoc.querySelector('metadata');
|
|
32
|
+
metadata?.childNodes.forEach((node: Element) => {
|
|
33
|
+
let value = node.textContent;
|
|
34
|
+
const title = node.nodeName;
|
|
35
|
+
|
|
36
|
+
if (node.nodeName === 'link') {
|
|
37
|
+
value = node.getAttribute('href');
|
|
38
|
+
}
|
|
39
|
+
if (value?.trim().length) {
|
|
40
|
+
const metaDataEntry = {
|
|
41
|
+
title: title,
|
|
42
|
+
value: value,
|
|
43
|
+
id: new Date().getTime(),
|
|
44
|
+
};
|
|
45
|
+
setMetadata((prevState) => [...prevState, metaDataEntry]);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
const data = toGeoJSON.gpx(gpxDoc);
|
|
49
|
+
setGeojson(data as FeatureCollection);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.log(e);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!props.data) return;
|
|
57
|
+
|
|
58
|
+
parseGpx(props.data);
|
|
59
|
+
}, [props.data]);
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
geojson,
|
|
63
|
+
metadata,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
useGpx.defaultProps = {
|
|
68
|
+
data: undefined,
|
|
69
|
+
};
|
|
70
|
+
export default useGpx;
|
package/src/hooks/useLayer.ts
CHANGED
|
@@ -2,22 +2,37 @@ import { useState, useEffect, useCallback, useRef } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import useMap, { useMapType } from './useMap';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
SourceSpecification,
|
|
7
|
+
LayerSpecification,
|
|
8
|
+
MapMouseEvent,
|
|
9
|
+
GeoJSONFeature,
|
|
10
|
+
Style,
|
|
11
|
+
MapEventType,
|
|
12
|
+
Map
|
|
13
|
+
} from 'maplibre-gl';
|
|
6
14
|
|
|
7
15
|
import MapLibreGlWrapper from '../components/MapLibreMap/lib/MapLibreGlWrapper';
|
|
8
16
|
|
|
9
|
-
import { MapLayerMouseEvent } from 'maplibre-gl';
|
|
10
17
|
import { GeoJSONObject } from '@turf/turf';
|
|
11
18
|
|
|
19
|
+
type getLayerType = Style['getLayer'];
|
|
20
|
+
|
|
12
21
|
type useLayerType = {
|
|
13
22
|
map: MapLibreGlWrapper | undefined;
|
|
14
|
-
layer:
|
|
23
|
+
layer: ReturnType<getLayerType> | undefined;
|
|
15
24
|
layerId: string;
|
|
16
25
|
componentId: string;
|
|
17
26
|
mapHook: useMapType;
|
|
18
27
|
};
|
|
19
28
|
|
|
20
|
-
|
|
29
|
+
export type MapEventHandler = (
|
|
30
|
+
ev: MapMouseEvent & {
|
|
31
|
+
features?: GeoJSONFeature[] | undefined;
|
|
32
|
+
} & Record<string, unknown>
|
|
33
|
+
) => void;
|
|
34
|
+
|
|
35
|
+
export interface useLayerProps {
|
|
21
36
|
mapId?: string;
|
|
22
37
|
layerId?: string;
|
|
23
38
|
idPrefix?: string;
|
|
@@ -26,9 +41,9 @@ interface useLayerProps {
|
|
|
26
41
|
geojson?: GeoJSONObject;
|
|
27
42
|
source?: SourceSpecification | string;
|
|
28
43
|
options: Partial<LayerSpecification>;
|
|
29
|
-
onHover?:
|
|
30
|
-
onClick?:
|
|
31
|
-
onLeave?:
|
|
44
|
+
onHover?: (ev: MapEventType & unknown) => Map | void;
|
|
45
|
+
onClick?: (ev: MapEventType & unknown) => Map | void;
|
|
46
|
+
onLeave?: (ev: MapEventType & unknown) => Map | void;
|
|
32
47
|
}
|
|
33
48
|
|
|
34
49
|
const legalLayerTypes = [
|
|
@@ -53,7 +68,7 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
53
68
|
const layerPaintConfRef = useRef<string>('');
|
|
54
69
|
const layerLayoutConfRef = useRef<string>('');
|
|
55
70
|
|
|
56
|
-
const [layer, setLayer] = useState<
|
|
71
|
+
const [layer, setLayer] = useState<ReturnType<getLayerType>>();
|
|
57
72
|
|
|
58
73
|
const initializedRef = useRef<boolean>(false);
|
|
59
74
|
const layerId = useRef(
|
|
@@ -75,6 +90,9 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
75
90
|
return;
|
|
76
91
|
}
|
|
77
92
|
}
|
|
93
|
+
if(typeof props.options.type === 'undefined'){
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
78
96
|
|
|
79
97
|
initializedRef.current = true;
|
|
80
98
|
|
|
@@ -95,7 +113,7 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
95
113
|
}
|
|
96
114
|
: {}),
|
|
97
115
|
id: layerId.current,
|
|
98
|
-
},
|
|
116
|
+
} as LayerSpecification,
|
|
99
117
|
props.insertBeforeLayer
|
|
100
118
|
? props.insertBeforeLayer
|
|
101
119
|
: props.insertBeforeFirstSymbolLayer
|
|
@@ -104,7 +122,7 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
104
122
|
mapHook.componentId
|
|
105
123
|
);
|
|
106
124
|
|
|
107
|
-
setLayer(mapHook.map
|
|
125
|
+
setLayer(() => mapHook.map?.map.getLayer(layerId.current));
|
|
108
126
|
|
|
109
127
|
if (typeof props.onHover !== 'undefined') {
|
|
110
128
|
mapHook.map.on('mousemove', layerId.current, props.onHover, mapHook.componentId);
|
|
@@ -209,4 +227,8 @@ function useLayer(props: useLayerProps): useLayerType {
|
|
|
209
227
|
};
|
|
210
228
|
}
|
|
211
229
|
|
|
230
|
+
useLayer.defaultProps = {
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
212
234
|
export default useLayer;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import useLayerHoverPopup from "./useLayerHoverPopup";
|
|
4
|
+
|
|
5
|
+
import mapContextDecorator from "../../decorators/MapContextDecorator";
|
|
6
|
+
|
|
7
|
+
const storyoptions = {
|
|
8
|
+
title: "MapComponents/useLayerHoverPopup",
|
|
9
|
+
component: useLayerHoverPopup,
|
|
10
|
+
argTypes: {
|
|
11
|
+
},
|
|
12
|
+
decorators: mapContextDecorator,
|
|
13
|
+
};
|
|
14
|
+
export default storyoptions;
|
|
15
|
+
|
|
16
|
+
const Template = () => <useLayerHoverPopup />;
|
|
17
|
+
|
|
18
|
+
export const ExampleConfig = Template.bind({});
|
|
19
|
+
ExampleConfig.parameters = {};
|
|
20
|
+
ExampleConfig.args = {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import useMap from '../../hooks/useMap';
|
|
3
|
+
import {
|
|
4
|
+
GeoJSONFeature,
|
|
5
|
+
Popup,
|
|
6
|
+
MapEventType,
|
|
7
|
+
} from 'maplibre-gl';
|
|
8
|
+
|
|
9
|
+
interface useLayerHoverPopupProps {
|
|
10
|
+
/**
|
|
11
|
+
* Id of the target MapLibre instance in mapContext
|
|
12
|
+
*/
|
|
13
|
+
mapId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Id of an existing layer in the mapLibre instance this event will be registered to
|
|
16
|
+
*/
|
|
17
|
+
layerId?: string;
|
|
18
|
+
getPopupContent: (feature: GeoJSONFeature) => string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* useLayerHoverPopup hook registers a mouseenter event to display feature properties in a MapLibre popup if a feature on the configured layer is hovered
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
const useLayerHoverPopup = (props: useLayerHoverPopupProps) => {
|
|
26
|
+
const mapHook = useMap({
|
|
27
|
+
mapId: props.mapId,
|
|
28
|
+
waitForLayer: props.layerId,
|
|
29
|
+
});
|
|
30
|
+
const popup = useRef(
|
|
31
|
+
new Popup({
|
|
32
|
+
closeButton: false,
|
|
33
|
+
closeOnClick: true,
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!mapHook.map || !props.layerId) return;
|
|
39
|
+
mapHook.map.on(
|
|
40
|
+
'mouseenter',
|
|
41
|
+
props.layerId,
|
|
42
|
+
(
|
|
43
|
+
e: MapEventType & {
|
|
44
|
+
features?: GeoJSONFeature[] | undefined;
|
|
45
|
+
lngLat: { lng: number; lat: number };
|
|
46
|
+
}
|
|
47
|
+
) => {
|
|
48
|
+
if (!mapHook.map) return;
|
|
49
|
+
// Change the cursor style as a UI indicator.
|
|
50
|
+
|
|
51
|
+
const coordinates = e?.features?.[0].geometry.coordinates.slice();
|
|
52
|
+
//const description = e.features[0].properties.desc;
|
|
53
|
+
let content = '';
|
|
54
|
+
if (e?.features?.[0] && typeof props.getPopupContent === 'function') {
|
|
55
|
+
content = props.getPopupContent(e.features[0]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (coordinates?.[0]) {
|
|
59
|
+
// Ensure that if the map is zoomed out such that multiple
|
|
60
|
+
// copies of the feature are visible, the popup appears
|
|
61
|
+
// over the copy being pointed to.
|
|
62
|
+
while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
|
|
63
|
+
coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Populate the popup and set its coordinates
|
|
67
|
+
|
|
68
|
+
// based on the feature found.
|
|
69
|
+
popup.current.setLngLat(coordinates).setHTML(content).addTo(mapHook.map.map);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
mapHook.componentId
|
|
73
|
+
);
|
|
74
|
+
}, [mapHook.map]);
|
|
75
|
+
|
|
76
|
+
return <></>;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
useLayerHoverPopup.defaultProps = {
|
|
80
|
+
mapId: undefined,
|
|
81
|
+
};
|
|
82
|
+
export default useLayerHoverPopup;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import { MapComponentsProvider } from '../contexts/MapContext';
|
|
4
|
+
import MapLibreMap from '../components/MapLibreMap/MapLibreMap';
|
|
5
|
+
|
|
6
|
+
import useMap from './useMap';
|
|
7
|
+
|
|
8
|
+
const UseMapTestComponent = () => {
|
|
9
|
+
const mapHook = useMap();
|
|
10
|
+
|
|
11
|
+
return <>{mapHook.map && 'Map is ready'}</>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const TestComponent = () => {
|
|
15
|
+
const [includeComponent, setIncludeComponent] = useState(true);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<button
|
|
20
|
+
className="toggle_includeComponent"
|
|
21
|
+
onClick={() => {
|
|
22
|
+
setIncludeComponent(!includeComponent);
|
|
23
|
+
}}
|
|
24
|
+
>
|
|
25
|
+
toggle
|
|
26
|
+
</button>
|
|
27
|
+
<div className="useMapContainer">
|
|
28
|
+
{includeComponent && <UseMapTestComponent />}
|
|
29
|
+
</div>
|
|
30
|
+
<MapLibreMap />
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
describe('useMap hook', () => {
|
|
36
|
+
it("should retrieve a MapLibre instance even if no attributes are passed", async () => {
|
|
37
|
+
const wrapper = mount(
|
|
38
|
+
<MapComponentsProvider>
|
|
39
|
+
<TestComponent />
|
|
40
|
+
</MapComponentsProvider>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
expect(wrapper.find('.useMapContainer').text()).toEqual("Map is ready");
|
|
47
|
+
});
|
|
48
|
+
});
|
package/src/hooks/useMap.ts
CHANGED
|
@@ -12,16 +12,16 @@ type useMapType = {
|
|
|
12
12
|
cleanup: () => void;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
function useMap(props
|
|
15
|
+
function useMap(props?: { mapId?: string; waitForLayer?: string }): useMapType {
|
|
16
16
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
17
17
|
const mapContext: MapContextType = useContext(MapContext);
|
|
18
18
|
const [map, setMap] = useState<MapLibreGlWrapper>();
|
|
19
19
|
|
|
20
20
|
const mapState = useMapState({
|
|
21
|
-
mapId: props
|
|
21
|
+
mapId: props?.mapId,
|
|
22
22
|
watch: {
|
|
23
23
|
viewport: false,
|
|
24
|
-
layers: props
|
|
24
|
+
layers: props?.waitForLayer ? true : false,
|
|
25
25
|
sources: false,
|
|
26
26
|
},
|
|
27
27
|
filter: {
|
|
@@ -53,15 +53,15 @@ function useMap(props: { mapId?: string; waitForLayer?: string }): useMapType {
|
|
|
53
53
|
}, []);
|
|
54
54
|
|
|
55
55
|
useEffect(() => {
|
|
56
|
-
if (!mapContext.mapExists(props
|
|
56
|
+
if (!mapContext.mapExists(props?.mapId) || initializedRef.current) return;
|
|
57
57
|
|
|
58
58
|
// check if waitForLayer (string, layer id of the layer this hook is supposed to wait for)
|
|
59
59
|
// exists as layer in the MapLibre instance
|
|
60
|
-
if (props
|
|
60
|
+
if (props?.waitForLayer) {
|
|
61
61
|
let layerFound = false;
|
|
62
62
|
|
|
63
63
|
mapState?.layers?.forEach((layer: any) => {
|
|
64
|
-
if (layer.id === props
|
|
64
|
+
if (layer.id === props?.waitForLayer) {
|
|
65
65
|
layerFound = true;
|
|
66
66
|
}
|
|
67
67
|
});
|
|
@@ -72,10 +72,10 @@ function useMap(props: { mapId?: string; waitForLayer?: string }): useMapType {
|
|
|
72
72
|
// the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
|
|
73
73
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
74
74
|
initializedRef.current = true;
|
|
75
|
-
mapRef.current = mapContext.getMap(props
|
|
75
|
+
mapRef.current = mapContext.getMap(props?.mapId);
|
|
76
76
|
setMap(mapRef.current);
|
|
77
77
|
setMapIsReady(true);
|
|
78
|
-
}, [mapContext.mapIds, mapState.layers, mapContext, props
|
|
78
|
+
}, [mapContext.mapIds, mapState.layers, mapContext, props]);
|
|
79
79
|
|
|
80
80
|
return {
|
|
81
81
|
map: map,
|
package/src/hooks/useSource.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useEffect, useRef, useCallback, useState } from "react";
|
|
2
2
|
import useMap, { useMapType } from "./useMap";
|
|
3
3
|
import MapLibreGlWrapper from "../components/MapLibreMap/lib/MapLibreGlWrapper";
|
|
4
|
-
import { SourceSpecification } from "maplibre-gl";
|
|
4
|
+
import { Source, SourceSpecification } from "maplibre-gl";
|
|
5
5
|
|
|
6
6
|
type useSourceType = {
|
|
7
7
|
map: MapLibreGlWrapper | undefined;
|
|
8
|
-
source:
|
|
8
|
+
source: Source | undefined;
|
|
9
9
|
componentId: string;
|
|
10
10
|
mapHook: useMapType;
|
|
11
11
|
};
|
|
@@ -22,7 +22,7 @@ function useSource(props: useSourceProps): useSourceType {
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const initializedRef = useRef<boolean>(false);
|
|
25
|
-
const [source, setSource] = useState<
|
|
25
|
+
const [source, setSource] = useState<Source>();
|
|
26
26
|
const sourceId = useRef(
|
|
27
27
|
props.sourceId || (props.idPrefix ? props.idPrefix : "Source-") + mapHook.componentId
|
|
28
28
|
);
|
|
@@ -37,7 +37,7 @@ function useSource(props: useSourceProps): useSourceType {
|
|
|
37
37
|
|
|
38
38
|
mapHook.map?.addSource(sourceId.current, {
|
|
39
39
|
...props.source,
|
|
40
|
-
});
|
|
40
|
+
}, mapHook.componentId);
|
|
41
41
|
|
|
42
42
|
setSource(mapHook.map.map.getSource(sourceId.current));
|
|
43
43
|
}, [props, mapHook.map]);
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import { useState, useEffect } from "react";
|
|
2
|
-
import WMSCapabilities from "wms-capabilities";
|
|
2
|
+
import WMSCapabilities, { WMSCapabilitiesJSON } from "wms-capabilities";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export interface useWmsProps{
|
|
5
|
+
url?:string;
|
|
6
|
+
urlParameters?:{[key: string]: string};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface useWmsReturnType{
|
|
10
|
+
capabilities:WMSCapabilitiesJSON | null | undefined;
|
|
11
|
+
getFeatureInfoUrl:string | undefined;
|
|
12
|
+
wmsUrl:string | undefined;
|
|
13
|
+
error:string | undefined;
|
|
14
|
+
setUrl:(value:string|undefined) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function useWms(props:useWmsProps):useWmsReturnType {
|
|
5
18
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
6
|
-
const [getFeatureInfoUrl, setGetFeatureInfoUrl] = useState(
|
|
19
|
+
const [getFeatureInfoUrl, setGetFeatureInfoUrl] = useState<string>();
|
|
7
20
|
const [url, setUrl] = useState(props.url);
|
|
8
21
|
const [wmsUrl, setWmsUrl] = useState("");
|
|
9
|
-
const [capabilities, setCapabilities] = useState(
|
|
10
|
-
const [error, setError] = useState(
|
|
22
|
+
const [capabilities, setCapabilities] = useState<WMSCapabilitiesJSON | null | undefined>();
|
|
23
|
+
const [error, setError] = useState();
|
|
11
24
|
|
|
12
25
|
const clearState = () => {
|
|
13
26
|
setGetFeatureInfoUrl(undefined);
|
|
@@ -29,16 +42,16 @@ function useWms(props) {
|
|
|
29
42
|
_propsUrlParams = url.split("?");
|
|
30
43
|
_wmsUrl = _propsUrlParams[0];
|
|
31
44
|
}
|
|
32
|
-
|
|
45
|
+
const _urlParamsFromUrl = new URLSearchParams(_propsUrlParams?.[1]);
|
|
33
46
|
|
|
34
|
-
|
|
47
|
+
const urlParamsObj = {
|
|
35
48
|
...Object.fromEntries(_urlParamsFromUrl),
|
|
36
49
|
...props.urlParameters,
|
|
37
50
|
};
|
|
38
51
|
// create URLSearchParams object to assemble the URL Parameters
|
|
39
|
-
|
|
52
|
+
const urlParams = new URLSearchParams(urlParamsObj);
|
|
40
53
|
|
|
41
|
-
|
|
54
|
+
const urlParamsStr =
|
|
42
55
|
decodeURIComponent(urlParams.toString()) + "".replace(/%2F/g, "/").replace(/%3A/g, ":");
|
|
43
56
|
|
|
44
57
|
fetch(_wmsUrl + "?" + urlParamsStr)
|
|
@@ -49,8 +62,8 @@ function useWms(props) {
|
|
|
49
62
|
return res.text();
|
|
50
63
|
}
|
|
51
64
|
})
|
|
52
|
-
.then((data) => {
|
|
53
|
-
setCapabilities(new WMSCapabilities(data).toJSON());
|
|
65
|
+
.then((data:string) => {
|
|
66
|
+
setCapabilities(new WMSCapabilities(data, window.DOMParser).toJSON());
|
|
54
67
|
})
|
|
55
68
|
.catch((error) => {
|
|
56
69
|
//reset local state
|
package/src/index.ts
CHANGED
|
@@ -22,11 +22,11 @@ export { default as MlLayerSwipe } from "./components/MlLayerSwipe/MlLayerSwipe"
|
|
|
22
22
|
export { default as MlTransitionGeoJsonLayer } from "./components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer";
|
|
23
23
|
export { default as MlMarker } from "./components/MlMarker/MlMarker";
|
|
24
24
|
|
|
25
|
-
export { default as
|
|
26
|
-
export { default as GeoJsonProvider } from "./components/
|
|
27
|
-
export { default as GeoJsonContext } from "./components/
|
|
25
|
+
export { default as MlGpxViewer } from "./components/MlGpxViewer/MlGpxViewer";
|
|
26
|
+
export { default as GeoJsonProvider } from "./components/MlGpxViewer/util/GeoJsonProvider";
|
|
27
|
+
export { default as GeoJsonContext } from "./components/MlGpxViewer/util/GeoJsonContext";
|
|
28
28
|
|
|
29
|
-
export { default as MlSpatialElevationProfile } from "./components/MlSpatialElevationProfile/MlSpatialElevationProfile
|
|
29
|
+
export { default as MlSpatialElevationProfile } from "./components/MlSpatialElevationProfile/MlSpatialElevationProfile";
|
|
30
30
|
|
|
31
31
|
export { default as MlOsmLayer } from "./components/MlOsmLayer/MlOsmLayer.js";
|
|
32
32
|
export { default as MlBasicComponent } from "./components/MlBasicComponent.js";
|
|
@@ -34,7 +34,7 @@ export { default as MlBasicComponent } from "./components/MlBasicComponent.js";
|
|
|
34
34
|
export { default as useLayer } from "./hooks/useLayer";
|
|
35
35
|
export { default as useMapState } from "./hooks/useMapState";
|
|
36
36
|
export { default as useMap } from "./hooks/useMap";
|
|
37
|
-
export { default as useWms } from "./hooks/useWms
|
|
37
|
+
export { default as useWms } from "./hooks/useWms";
|
|
38
38
|
export { default as useSource } from "./hooks/useSource";
|
|
39
39
|
export { default as useExportMap } from "./hooks/useExportMap";
|
|
40
40
|
export { default as useCameraFollowPath } from "./hooks/useCameraFollowPath/useCameraFollowPath";
|
package/src/setupTests.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import Adapter from
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
import 'jest-enzyme';
|
|
3
|
+
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { configure } from 'enzyme';
|
|
6
6
|
|
|
7
|
-
var uuid_regex =
|
|
7
|
+
var uuid_regex = '[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}';
|
|
8
8
|
export { uuid_regex };
|
|
9
9
|
|
|
10
10
|
// MapLibre-gl mockup
|
|
@@ -13,30 +13,35 @@ var mockMapLibreMethods = {
|
|
|
13
13
|
off: jest.fn(),
|
|
14
14
|
addControl: jest.fn(),
|
|
15
15
|
removeControl: jest.fn(),
|
|
16
|
+
fitBounds: jest.fn(),
|
|
16
17
|
hasControl: jest.fn(() => true),
|
|
17
|
-
getCanvas: () => document.createElement(
|
|
18
|
+
getCanvas: () => document.createElement('canvas'),
|
|
18
19
|
getContainer: () => ({
|
|
19
20
|
style: {},
|
|
20
21
|
}),
|
|
21
22
|
};
|
|
22
23
|
export { mockMapLibreMethods };
|
|
23
24
|
|
|
24
|
-
jest.mock(
|
|
25
|
-
const originalModule = jest.requireActual(
|
|
25
|
+
jest.mock('maplibre-gl/dist/maplibre-gl', () => {
|
|
26
|
+
const originalModule = jest.requireActual('maplibre-gl/dist/maplibre-gl');
|
|
26
27
|
|
|
27
28
|
return {
|
|
28
29
|
...originalModule,
|
|
29
30
|
GeolocateControl: jest.fn(),
|
|
30
31
|
Map: function () {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
31
33
|
var self = this;
|
|
32
34
|
this.layers = [];
|
|
33
35
|
this.sources = [];
|
|
36
|
+
this.style = { sourceCaches: {} };
|
|
34
37
|
|
|
35
38
|
let styleFunctions = {
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
36
40
|
addSource: (id, source) => {
|
|
37
|
-
if (typeof id.id !==
|
|
41
|
+
if (typeof id.id !== 'undefined') {
|
|
38
42
|
self.sources.push(id);
|
|
39
|
-
|
|
43
|
+
self.style.sourceCaches[id] = {};
|
|
44
|
+
} else if (typeof id !== 'undefined') {
|
|
40
45
|
self.sources.push(id);
|
|
41
46
|
}
|
|
42
47
|
},
|
|
@@ -50,15 +55,13 @@ jest.mock("maplibre-gl/dist/maplibre-gl", () => {
|
|
|
50
55
|
const sourcePosition = self.sources.indexOf(id);
|
|
51
56
|
if (sourcePosition !== -1) {
|
|
52
57
|
self.sources.splice(sourcePosition, 1);
|
|
58
|
+
delete self.style.sourceCaches[id];
|
|
53
59
|
}
|
|
54
60
|
},
|
|
55
61
|
addLayer: (layer) => {
|
|
56
|
-
if (typeof layer.id !==
|
|
62
|
+
if (typeof layer.id !== 'undefined') {
|
|
57
63
|
self.layers.push(layer.id);
|
|
58
|
-
if (
|
|
59
|
-
typeof layer.source !== "undefined" &&
|
|
60
|
-
typeof layer.source === "object"
|
|
61
|
-
) {
|
|
64
|
+
if (typeof layer.source !== 'undefined' && typeof layer.source === 'object') {
|
|
62
65
|
self.sources.push(layer.id);
|
|
63
66
|
}
|
|
64
67
|
}
|