@mapcomponents/react-maplibre 0.1.63 → 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/.editorconfig +1 -1
- package/.eslintrc.js +9 -6
- package/.github/workflows/check-catalogue-metadata-schema.yml +19 -0
- package/CHANGELOG.md +27 -2
- package/coverage/clover.xml +671 -1032
- package/coverage/coverage-final.json +24 -21
- package/coverage/lcov-report/index.html +112 -82
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +2 -5
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
- 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 +40 -19
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js.html +1 -1
- 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 +34 -4
- 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 → MlGpxViewer}/index.html +23 -38
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerList.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerListItem.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/index.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/MlSketchTool.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/index.html +1 -1
- 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 +1284 -1959
- package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +51 -25
- 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/MlGPXViewer/util/GeoJsonContext.d.ts +1 -1
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +22 -11
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +4 -95
- 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/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/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 +13 -7
- 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 +1 -1
- package/dist/hooks/useMap.test.d.ts +1 -0
- package/dist/hooks/useSource.d.ts +2 -2
- package/dist/hooks/useWms.d.ts +24 -16
- package/dist/index.d.ts +5 -5
- package/dist/index.esm.js +9310 -14006
- 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 +7 -6
- package/dist/ui_components/Tooltip.d.ts +1 -1
- package/dist/ui_components/TopToolbar.d.ts +4 -3
- 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 -191
- package/{src/components/MlImageMarkerLayer → public}/assets/wg-marker.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.meta.json +1 -2
- package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +25 -2
- package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +1 -2
- package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +0 -1
- 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 +89 -0
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +24 -17
- package/src/components/MlGeoJsonLayer/assets/earthquake.json +109937 -0
- package/src/components/MlGeoJsonLayer/assets/wg_locations.json +65 -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/MlSketchTool.meta.json +1 -2
- 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 +1 -2
- 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 +12 -10
- package/src/ui_components/Tooltip.tsx +17 -0
- package/src/ui_components/TopToolbar.tsx +5 -3
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.html +0 -1222
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +0 -1645
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +0 -757
- package/dist/components/MlGPXViewer/util/MlGPXViewerInstructions.d.ts +0 -1
- package/dist/components/MlGPXViewer/util/SampleLayer.d.ts +0 -0
- package/dist/components/MlGPXViewer/util/demoViewer.d.ts +0 -5
- package/src/components/MlGPXViewer/MlGPXViewer.stories.js +0 -91
- package/src/components/MlGPXViewer/MlGPXViewer.test.js +0 -28
- package/src/components/MlGPXViewer/MlGPXViewer.tsx +0 -379
- package/src/components/MlGPXViewer/util/MlGPXViewerInstructions.js +0 -145
- package/src/components/MlGPXViewer/util/SampleLayer.js +0 -2
- package/src/components/MlGPXViewer/util/demoViewer.js +0 -254
- 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/Tooltip.js +0 -21
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
useCallback,
|
|
4
|
-
useRef,
|
|
5
|
-
useEffect,
|
|
6
|
-
useState,
|
|
7
|
-
} from "react";
|
|
1
|
+
import React, { useContext, useCallback, useRef, useEffect, useState } from 'react';
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
3
|
// @ts-ignore
|
|
9
|
-
import syncMove from
|
|
10
|
-
import
|
|
11
|
-
import MapContext from
|
|
4
|
+
import syncMove from '@mapbox/mapbox-gl-sync-move';
|
|
5
|
+
import './style.css';
|
|
6
|
+
import MapContext from '../../contexts/MapContext';
|
|
12
7
|
|
|
13
|
-
interface MlLayerSwipeProps {
|
|
8
|
+
export interface MlLayerSwipeProps {
|
|
14
9
|
/**
|
|
15
10
|
* Id of the first MapLibre instance.
|
|
16
11
|
*/
|
|
@@ -19,6 +14,10 @@ interface MlLayerSwipeProps {
|
|
|
19
14
|
* Id of the second MapLibre instance.
|
|
20
15
|
*/
|
|
21
16
|
map2Id: string;
|
|
17
|
+
/**
|
|
18
|
+
* object (React.CSSProperties) that is added to the button default style
|
|
19
|
+
*/
|
|
20
|
+
buttonStyle: React.CSSProperties | undefined;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
/**
|
|
@@ -45,33 +44,28 @@ const MlLayerSwipe = (props: MlLayerSwipeProps) => {
|
|
|
45
44
|
}, [mapContext, props.map1Id, props.map2Id]);
|
|
46
45
|
|
|
47
46
|
const cleanup = () => {
|
|
48
|
-
|
|
47
|
+
syncCleanupFunctionRef.current();
|
|
49
48
|
};
|
|
50
49
|
|
|
51
50
|
const onMove = useCallback(
|
|
52
51
|
(e) => {
|
|
53
52
|
if (!mapExists()) return;
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
.getCanvas()
|
|
57
|
-
.getBoundingClientRect();
|
|
54
|
+
const bounds = mapContext.maps[props.map1Id].getCanvas().getBoundingClientRect();
|
|
58
55
|
let clientX =
|
|
59
56
|
e.clientX ||
|
|
60
|
-
(typeof e.touches !==
|
|
57
|
+
(typeof e.touches !== 'undefined' && typeof e.touches[0] !== 'undefined'
|
|
61
58
|
? e.touches[0].clientX
|
|
62
59
|
: 0);
|
|
63
60
|
|
|
64
61
|
clientX -= bounds.x;
|
|
65
|
-
|
|
62
|
+
const swipeX_tmp = parseFloat(((clientX / bounds.width) * 100).toFixed(2));
|
|
66
63
|
|
|
67
64
|
if (swipeXRef.current !== swipeX_tmp) {
|
|
68
65
|
setSwipeX(swipeX_tmp);
|
|
69
66
|
swipeXRef.current = swipeX_tmp;
|
|
70
67
|
|
|
71
|
-
|
|
72
|
-
"rect(0, " +
|
|
73
|
-
(swipeXRef.current * bounds.width) / 100 +
|
|
74
|
-
"px, 999em, 0)";
|
|
68
|
+
const clipA = 'rect(0, ' + (swipeXRef.current * bounds.width) / 100 + 'px, 999em, 0)';
|
|
75
69
|
|
|
76
70
|
mapContext.maps[props.map2Id].getContainer().style.clip = clipA;
|
|
77
71
|
}
|
|
@@ -96,46 +90,47 @@ const MlLayerSwipe = (props: MlLayerSwipeProps) => {
|
|
|
96
90
|
});
|
|
97
91
|
}, [mapContext.mapIds, mapContext, props, onMove, mapExists]);
|
|
98
92
|
|
|
99
|
-
const onDown = (e:
|
|
100
|
-
if (e.
|
|
101
|
-
document.addEventListener(
|
|
102
|
-
document.addEventListener(
|
|
93
|
+
const onDown = (e: React.MouseEvent | React.TouchEvent) => {
|
|
94
|
+
if (e.nativeEvent instanceof TouchEvent) {
|
|
95
|
+
document.addEventListener('touchmove', onMove);
|
|
96
|
+
document.addEventListener('touchend', onTouchEnd);
|
|
103
97
|
} else {
|
|
104
|
-
document.addEventListener(
|
|
105
|
-
document.addEventListener(
|
|
98
|
+
document.addEventListener('mousemove', onMove);
|
|
99
|
+
document.addEventListener('mouseup', onMouseUp);
|
|
106
100
|
}
|
|
107
101
|
};
|
|
108
102
|
|
|
109
103
|
const onTouchEnd = () => {
|
|
110
|
-
document.removeEventListener(
|
|
111
|
-
document.removeEventListener(
|
|
104
|
+
document.removeEventListener('touchmove', onMove);
|
|
105
|
+
document.removeEventListener('touchend', onTouchEnd);
|
|
112
106
|
};
|
|
113
107
|
|
|
114
108
|
const onMouseUp = () => {
|
|
115
|
-
document.removeEventListener(
|
|
116
|
-
document.removeEventListener(
|
|
109
|
+
document.removeEventListener('mousemove', onMove);
|
|
110
|
+
document.removeEventListener('mouseup', onMouseUp);
|
|
117
111
|
};
|
|
118
112
|
|
|
119
113
|
return (
|
|
120
114
|
<div
|
|
121
115
|
style={{
|
|
122
|
-
position:
|
|
123
|
-
left: swipeX +
|
|
124
|
-
top:
|
|
125
|
-
borderRadius:
|
|
126
|
-
width:
|
|
127
|
-
height:
|
|
128
|
-
background:
|
|
129
|
-
border:
|
|
130
|
-
cursor:
|
|
131
|
-
zIndex:
|
|
132
|
-
marginLeft:
|
|
133
|
-
marginTop:
|
|
134
|
-
textAlign:
|
|
135
|
-
lineHeight:
|
|
136
|
-
fontSize:
|
|
137
|
-
color:
|
|
138
|
-
userSelect:
|
|
116
|
+
position: 'absolute',
|
|
117
|
+
left: swipeX + '%',
|
|
118
|
+
top: '50%',
|
|
119
|
+
borderRadius: '50%',
|
|
120
|
+
width: '100px',
|
|
121
|
+
height: '100px',
|
|
122
|
+
background: '#0066ff',
|
|
123
|
+
border: '3px solid #eaebf1',
|
|
124
|
+
cursor: 'pointer',
|
|
125
|
+
zIndex: '110',
|
|
126
|
+
marginLeft: '-50px',
|
|
127
|
+
marginTop: '-50px',
|
|
128
|
+
textAlign: 'center',
|
|
129
|
+
lineHeight: '91px',
|
|
130
|
+
fontSize: '2em',
|
|
131
|
+
color: '#fafafa',
|
|
132
|
+
userSelect: 'none',
|
|
133
|
+
...props.buttonStyle,
|
|
139
134
|
}}
|
|
140
135
|
onTouchStart={onDown}
|
|
141
136
|
onMouseDown={onDown}
|
|
@@ -143,4 +138,8 @@ const MlLayerSwipe = (props: MlLayerSwipeProps) => {
|
|
|
143
138
|
);
|
|
144
139
|
};
|
|
145
140
|
|
|
141
|
+
MlLayerSwipe.defaultProps = {
|
|
142
|
+
buttonStyle: {},
|
|
143
|
+
};
|
|
144
|
+
|
|
146
145
|
export default MlLayerSwipe;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { css } from
|
|
3
|
-
import { Box } from
|
|
4
|
-
import ImageLoader from
|
|
5
|
-
import useMapState from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { css } from '@emotion/css';
|
|
3
|
+
import { Box } from '@mui/system';
|
|
4
|
+
import ImageLoader from '../../../ui_components/ImageLoader';
|
|
5
|
+
import useMapState from '../../../hooks/useMapState';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @component
|
|
@@ -20,7 +20,7 @@ const LayerBox = (props) => {
|
|
|
20
20
|
matchLayerIds: props.layerId,
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
|
-
const width =
|
|
23
|
+
const width = '40px';
|
|
24
24
|
|
|
25
25
|
const defaultClass = css`
|
|
26
26
|
& img:hover {
|
|
@@ -34,22 +34,25 @@ const LayerBox = (props) => {
|
|
|
34
34
|
className={defaultClass}
|
|
35
35
|
sx={{
|
|
36
36
|
width,
|
|
37
|
-
height:
|
|
38
|
-
justifyContent:
|
|
37
|
+
height: '53px',
|
|
38
|
+
justifyContent: 'center',
|
|
39
39
|
py: 0.25,
|
|
40
|
-
px:
|
|
41
|
-
cursor:
|
|
40
|
+
px: '1rem',
|
|
41
|
+
cursor: 'pointer',
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexDirection: 'column',
|
|
44
|
+
alignItems: 'stretch',
|
|
42
45
|
}}
|
|
43
46
|
onClick={() => {
|
|
44
47
|
props?.handleLayerBoxClick?.(props.layerId);
|
|
45
48
|
}}
|
|
46
49
|
>
|
|
47
50
|
<ImageLoader
|
|
48
|
-
|
|
49
|
-
border:
|
|
50
|
-
borderRadius:
|
|
51
|
-
height:
|
|
52
|
-
width:
|
|
51
|
+
sx={{
|
|
52
|
+
border: '2px solid ' + (layers?.[0]?.visible ? '#64c864' : '#fd720f'),
|
|
53
|
+
borderRadius: '8px',
|
|
54
|
+
height: '40px',
|
|
55
|
+
width: '40px',
|
|
53
56
|
}}
|
|
54
57
|
src={props.thumbnail}
|
|
55
58
|
/>
|
|
@@ -57,11 +60,11 @@ const LayerBox = (props) => {
|
|
|
57
60
|
<div
|
|
58
61
|
className="mllayerswitcher-layer-text"
|
|
59
62
|
style={{
|
|
60
|
-
textAlign:
|
|
61
|
-
color:
|
|
62
|
-
fontFamily:
|
|
63
|
+
textAlign: 'center',
|
|
64
|
+
color: 'rgb(112, 117, 122)',
|
|
65
|
+
fontFamily: 'Roboto, Arial',
|
|
63
66
|
width,
|
|
64
|
-
fontSize:
|
|
67
|
+
fontSize: '0.60rem',
|
|
65
68
|
}}
|
|
66
69
|
>
|
|
67
70
|
{props.label}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import MlSpatialElevationProfile from './MlSpatialElevationProfile';
|
|
3
|
+
import MlGpxViewer from '../MlGpxViewer/MlGpxViewer';
|
|
4
|
+
import InfoIcon from '@mui/icons-material/Info';
|
|
5
|
+
import useGpx, { MetadataType } from '../../hooks/useGpx/useGpx';
|
|
6
|
+
import FileCopy from '@mui/icons-material/FileCopy';
|
|
7
|
+
import Dropzone from '../../ui_components/Dropzone';
|
|
8
|
+
import UploadButton from '../../ui_components/UploadButton';
|
|
9
|
+
import MetadataDrawer from '../MlGpxViewer/util/MetadataDrawer';
|
|
10
|
+
import mapContextDecorator from '../../decorators/MapContextDecorator';
|
|
11
|
+
import IconButton from '@mui/material/IconButton';
|
|
12
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
13
|
+
import TopToolbar from '../../ui_components/TopToolbar';
|
|
14
|
+
import useMap from '../../hooks/useMap';
|
|
15
|
+
import MlGpxViewerInstructions from '../MlGpxViewer/util/MlGpxViewerInstructions';
|
|
16
|
+
import { Button } from '@mui/material';
|
|
17
|
+
import MlGpxDemoLoader from '../MlGpxViewer/util/MlGpxDemoLoader';
|
|
18
|
+
|
|
19
|
+
const storyoptions = {
|
|
20
|
+
title: 'MapComponents/MlSpatialElevationProfile',
|
|
21
|
+
component: MlSpatialElevationProfile,
|
|
22
|
+
argTypes: {
|
|
23
|
+
options: {
|
|
24
|
+
control: {
|
|
25
|
+
type: 'object',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
decorators: mapContextDecorator,
|
|
30
|
+
};
|
|
31
|
+
export default storyoptions;
|
|
32
|
+
|
|
33
|
+
const Template = () => {
|
|
34
|
+
const [gpxData, setGpxData] = useState<string | undefined>();
|
|
35
|
+
const parsedGpx = useGpx({ data: gpxData });
|
|
36
|
+
const mediaIsMobile = useMediaQuery('(max-width:900px)');
|
|
37
|
+
const [demoLoaderOpen, setDemoLoaderOpen] = useState(false);
|
|
38
|
+
const [guide, setGuide] = useState(false);
|
|
39
|
+
const [metadataDrawerOpen, setMetadataDrawerOpen] = useState(false);
|
|
40
|
+
const [metadata, setMetadata] = useState<MetadataType[]>([]);
|
|
41
|
+
const mapHook = useMap({ mapId: 'map_1' });
|
|
42
|
+
|
|
43
|
+
const handleClick1 = () => {
|
|
44
|
+
setDemoLoaderOpen(!demoLoaderOpen);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const handleClick2 = () => {
|
|
48
|
+
setGuide(true);
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
setGuide(false);
|
|
51
|
+
}, 9000);
|
|
52
|
+
};
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (!mapHook.map) return;
|
|
55
|
+
if (mapHook.map.map.getPitch() != 60) {
|
|
56
|
+
mapHook.map.map.setPitch(60);
|
|
57
|
+
}
|
|
58
|
+
}, [mapHook.map]);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<>
|
|
62
|
+
<TopToolbar>
|
|
63
|
+
<MlGpxViewerInstructions open={guide} />
|
|
64
|
+
<Button variant="contained" onClick={handleClick2} sx={{ marginRight: '10px' }}>
|
|
65
|
+
Guide me through
|
|
66
|
+
</Button>
|
|
67
|
+
<Button variant="contained" onClick={handleClick1}>
|
|
68
|
+
Demo Mode
|
|
69
|
+
</Button>
|
|
70
|
+
</TopToolbar>
|
|
71
|
+
<MlGpxDemoLoader open={demoLoaderOpen} setOpen={setDemoLoaderOpen} setGpx={setGpxData} />
|
|
72
|
+
|
|
73
|
+
<div
|
|
74
|
+
style={{
|
|
75
|
+
position: 'fixed',
|
|
76
|
+
right: '5px',
|
|
77
|
+
bottom: mediaIsMobile ? '40px' : '25px',
|
|
78
|
+
display: 'flex',
|
|
79
|
+
flexDirection: 'column',
|
|
80
|
+
gap: '5px',
|
|
81
|
+
zIndex: 1000,
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
<UploadButton
|
|
85
|
+
setData={setGpxData}
|
|
86
|
+
buttonComponent={
|
|
87
|
+
<IconButton
|
|
88
|
+
style={{
|
|
89
|
+
backgroundColor: 'rgba(255,255,255,1)',
|
|
90
|
+
}}
|
|
91
|
+
size="large"
|
|
92
|
+
>
|
|
93
|
+
<FileCopy />
|
|
94
|
+
</IconButton>
|
|
95
|
+
}
|
|
96
|
+
/>
|
|
97
|
+
<IconButton
|
|
98
|
+
onClick={() => {
|
|
99
|
+
setMetadataDrawerOpen((prevState) => !prevState);
|
|
100
|
+
}}
|
|
101
|
+
style={{
|
|
102
|
+
backgroundColor: 'rgba(255,255,255,1)',
|
|
103
|
+
}}
|
|
104
|
+
size="large"
|
|
105
|
+
>
|
|
106
|
+
<InfoIcon />
|
|
107
|
+
</IconButton>
|
|
108
|
+
</div>
|
|
109
|
+
<MetadataDrawer metadata={metadata} open={metadataDrawerOpen} />
|
|
110
|
+
<Dropzone setData={(data) => setGpxData(data)} />
|
|
111
|
+
<MlGpxViewer
|
|
112
|
+
gpxData={gpxData}
|
|
113
|
+
onParseGpxData={(parsedGpx) => setMetadata(parsedGpx.metadata ? parsedGpx.metadata : [])}
|
|
114
|
+
/>
|
|
115
|
+
<MlSpatialElevationProfile geojson={parsedGpx.geojson} />
|
|
116
|
+
</>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const ExampleConfig = Template.bind({});
|
|
121
|
+
ExampleConfig.parameters = {};
|
|
@@ -2,8 +2,37 @@ import { layerRemovalTest, sourceRemovalTest } from "../../util";
|
|
|
2
2
|
|
|
3
3
|
import MlSpatialElevationProfile from "./MlSpatialElevationProfile";
|
|
4
4
|
import { uuid_regex } from "../../setupTests";
|
|
5
|
+
const sampleGeojson = {
|
|
6
|
+
"type": "FeatureCollection",
|
|
7
|
+
"features": [
|
|
8
|
+
{
|
|
9
|
+
"type": "Feature",
|
|
10
|
+
"properties": {
|
|
11
|
+
"name": "Rundwanderung auf dem Wiedweg zwischen Seelbach und Oberlahr",
|
|
12
|
+
"desc": "Diese Rundtour gibt mir viele historische Einblicke und zeigt mir einzigartige und mir bisher verborgene Kultur- und Naturschönheiten. Eine rundum spannende und erlebnisreiche Tour.",
|
|
13
|
+
"type": "hikingTourTrail"
|
|
14
|
+
},
|
|
15
|
+
"geometry": {
|
|
16
|
+
"type": "LineString",
|
|
17
|
+
"coordinates": [
|
|
18
|
+
[
|
|
19
|
+
7.526536,
|
|
20
|
+
50.647383,
|
|
21
|
+
267.71535
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
7.526617,
|
|
25
|
+
50.647247,
|
|
26
|
+
267.83347
|
|
27
|
+
],
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
5
33
|
|
|
6
|
-
|
|
34
|
+
// eslint-disable-next-line react/react-in-jsx-scope
|
|
35
|
+
const testComponent = <MlSpatialElevationProfile geojson={sampleGeojson} />;
|
|
7
36
|
|
|
8
37
|
layerRemovalTest(
|
|
9
38
|
"<MlSpatialElevationProfile />",
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import React, { useRef, useMemo } from 'react';
|
|
2
|
+
import { featureCollection } from '@turf/helpers';
|
|
3
|
+
import { Feature, FeatureCollection } from '@turf/turf';
|
|
4
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
+
import useSource from '../../hooks/useSource';
|
|
6
|
+
import useLayer from '../../hooks/useLayer';
|
|
7
|
+
import getElevationData from './util/getElevationData';
|
|
8
|
+
import { Coordinates, DataDrivenPropertyValueSpecification } from 'maplibre-gl';
|
|
9
|
+
|
|
10
|
+
const defaultFillExtrusionColor: (string | number | string[])[] = [
|
|
11
|
+
'interpolate',
|
|
12
|
+
['linear'],
|
|
13
|
+
['get', 'height'],
|
|
14
|
+
0,
|
|
15
|
+
'rgba(0, 0, 255, 0)',
|
|
16
|
+
0.1,
|
|
17
|
+
'royalblue',
|
|
18
|
+
0.3,
|
|
19
|
+
'cyan',
|
|
20
|
+
0.5,
|
|
21
|
+
'lime',
|
|
22
|
+
0.7,
|
|
23
|
+
'yellow',
|
|
24
|
+
1,
|
|
25
|
+
'yellow',
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* MlSpatialElevationProfile returns a Button that will add a standard OSM tile layer to the maplibre-gl instance.
|
|
29
|
+
*
|
|
30
|
+
* @component
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
interface geojson {
|
|
34
|
+
features: Feature | FeatureCollection | undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface MlSpatialElevationProfileProps {
|
|
38
|
+
/**
|
|
39
|
+
* Id of the target MapLibre instance in mapContext
|
|
40
|
+
*/
|
|
41
|
+
mapId?: string;
|
|
42
|
+
/**
|
|
43
|
+
* GeoJSON data that is supposed to be rendered by this component.
|
|
44
|
+
*/
|
|
45
|
+
//geojson: {features: Feature | FeatureCollection | undefined };
|
|
46
|
+
geojson: geojson | FeatureCollection | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Prefix of the component id this component uses when adding elements to the MapLibreGl-instance
|
|
49
|
+
*/
|
|
50
|
+
idPrefix?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Number describes the factor of the height of the elevation
|
|
53
|
+
*/
|
|
54
|
+
elevationFactor?: number;
|
|
55
|
+
/**
|
|
56
|
+
* The layerId of an existing layer this layer should be rendered visually beneath
|
|
57
|
+
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
58
|
+
*/
|
|
59
|
+
insertBeforeLayer?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const MlSpatialElevationProfile = (props: MlSpatialElevationProfileProps) => {
|
|
63
|
+
const sourceName = useRef('elevationprofile-' + uuidv4());
|
|
64
|
+
const layerName = useRef('elevationprofile-layer-' + uuidv4());
|
|
65
|
+
const elevationFactor =
|
|
66
|
+
props.elevationFactor || MlSpatialElevationProfile.defaultProps.elevationFactor;
|
|
67
|
+
|
|
68
|
+
const _geojsonInfo = useMemo(() => {
|
|
69
|
+
if (!props?.geojson?.features) return;
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
71
|
+
// @ts-ignore
|
|
72
|
+
const line = props.geojson.features?.find((element: Feature) => {
|
|
73
|
+
return element.geometry.type === 'LineString';
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
if (!line || !line.geometry) return;
|
|
77
|
+
|
|
78
|
+
const heights = line.geometry.coordinates.map((coordinate: Coordinates) => {
|
|
79
|
+
return coordinate[2];
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const min = Math.min(...heights);
|
|
83
|
+
|
|
84
|
+
let max = Math.max(...heights) - min;
|
|
85
|
+
|
|
86
|
+
max = max === 0 ? 1 : max;
|
|
87
|
+
|
|
88
|
+
return { max, min, line };
|
|
89
|
+
}, [props.geojson]);
|
|
90
|
+
|
|
91
|
+
const _fillExtrusionColor: (string | number | string[])[] = useMemo(() => {
|
|
92
|
+
if (!_geojsonInfo) return defaultFillExtrusionColor;
|
|
93
|
+
|
|
94
|
+
return [
|
|
95
|
+
'interpolate',
|
|
96
|
+
['linear'],
|
|
97
|
+
['get', 'height'],
|
|
98
|
+
0,
|
|
99
|
+
'rgb(0,255,55)',
|
|
100
|
+
_geojsonInfo.max * elevationFactor,
|
|
101
|
+
'rgb(255,0,0)',
|
|
102
|
+
];
|
|
103
|
+
}, [_geojsonInfo, props.elevationFactor]);
|
|
104
|
+
|
|
105
|
+
const _geojson = useMemo(() => {
|
|
106
|
+
if (!props.geojson?.features || !_geojsonInfo) return;
|
|
107
|
+
|
|
108
|
+
const newData = getElevationData(_geojsonInfo, elevationFactor);
|
|
109
|
+
return newData;
|
|
110
|
+
}, [_geojsonInfo, elevationFactor]);
|
|
111
|
+
|
|
112
|
+
useSource({
|
|
113
|
+
mapId: props.mapId,
|
|
114
|
+
sourceId: sourceName.current,
|
|
115
|
+
source: {
|
|
116
|
+
type: 'geojson',
|
|
117
|
+
data: _geojson || featureCollection([]),
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
useLayer({
|
|
122
|
+
layerId: layerName.current,
|
|
123
|
+
source: sourceName.current,
|
|
124
|
+
|
|
125
|
+
options: {
|
|
126
|
+
type: 'fill-extrusion',
|
|
127
|
+
paint: {
|
|
128
|
+
'fill-extrusion-height': ['get', 'height'],
|
|
129
|
+
'fill-extrusion-opacity': 0.9,
|
|
130
|
+
'fill-extrusion-color': (_fillExtrusionColor || defaultFillExtrusionColor) as (DataDrivenPropertyValueSpecification<string>),
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
insertBeforeLayer: props.insertBeforeLayer,
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
return <></>;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
MlSpatialElevationProfile.defaultProps = {
|
|
140
|
+
elevationFactor: 1,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export default MlSpatialElevationProfile;
|