@mapcomponents/react-maplibre 0.1.63 → 0.1.65
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 +37 -2
- package/coverage/clover.xml +688 -1032
- package/coverage/coverage-final.json +25 -21
- package/coverage/lcov-report/index.html +127 -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 +2 -2
- 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 +2 -2
- 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/useLayerFilter/index.html +116 -0
- package/coverage/lcov-report/src/hooks/useLayerFilter/useLayerFilter.ts.html +184 -0
- 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 +1320 -1960
- 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/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.d.ts +1 -1
- package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.d.ts +12 -9
- 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/MlSketchTool.d.ts +1 -1
- package/dist/components/MlSketchTool/MlSketchTool.stories.d.ts +13 -9
- 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/MlThreeJsLayer/MlThreeJsLayer.stories.d.ts +20 -15
- package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +3 -67
- package/dist/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.d.ts +20 -12
- 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/useLayerFilter/useLayerFilter.d.ts +8 -0
- package/dist/hooks/useLayerFilter/useLayerFilter.stories.d.ts +9 -0
- 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/MlGeojsonLayerWithSource/{MlGeojsonLayerWithSource.stories.js → MlGeojsonLayerWithSource.stories.tsx} +0 -0
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx +1 -1
- 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 +71 -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/MlSketchTool/{MlSketchTool.stories.js → MlSketchTool.stories.tsx} +1 -1
- package/src/components/MlSketchTool/MlSketchTool.tsx +1 -1
- 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/MlThreeJsLayer/MlThreeJsLayer.stories.tsx +37 -0
- 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/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.tsx +22 -0
- 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/MlLayer/MlLayer.stories.js → hooks/useGpx/useGpx.stories.js} +4 -4
- package/src/hooks/useGpx/useGpx.tsx +70 -0
- package/src/hooks/useLayer.ts +32 -10
- package/src/hooks/useLayerFilter/useLayerFilter.doc.de.md +3 -0
- package/src/hooks/useLayerFilter/useLayerFilter.meta_.json +14 -0
- package/src/hooks/useLayerFilter/useLayerFilter.stories.tsx +40 -0
- package/src/hooks/useLayerFilter/useLayerFilter.ts +33 -0
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.doc.de.md +3 -0
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.meta_.json +15 -0
- package/src/{components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.js → hooks/useLayerHoverPopup/useLayerHoverPopup.stories.js} +4 -6
- 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/MlCenterPosition/MlCenterPosition.stories.js +0 -21
- 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/MlThreeJsLayer/MlThreeJsLayer.stories.js +0 -39
- 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,254 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useRef, useEffect, useState, useCallback } from 'react';
|
|
2
|
-
import { bbox } from '@turf/turf';
|
|
3
|
-
import Divider from '@mui/material/Divider';
|
|
4
|
-
import Typography from '@mui/material/Typography';
|
|
5
|
-
import CloseIcon from '@mui/icons-material/Close';
|
|
6
|
-
import Drawer from '@mui/material/Drawer';
|
|
7
|
-
import IconButton from '@mui/material/IconButton';
|
|
8
|
-
import Box from '@mui/material/Box';
|
|
9
|
-
import Button from '@mui/material/Button';
|
|
10
|
-
import Modal from '@mui/material/Modal';
|
|
11
|
-
import InfoIcon from '@mui/icons-material/Info';
|
|
12
|
-
import FileCopy from '@mui/icons-material/FileCopy';
|
|
13
|
-
import List from '@mui/material/List';
|
|
14
|
-
import ListItem from '@mui/material/ListItem';
|
|
15
|
-
import ListItemText from '@mui/material/ListItemText';
|
|
16
|
-
import GeoJsonContext from './GeoJsonContext';
|
|
17
|
-
import toGeoJSON from '../gpxConverter';
|
|
18
|
-
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
19
|
-
import useMap from '../../../hooks/useMap';
|
|
20
|
-
import Grid from '@mui/material/Grid';
|
|
21
|
-
import { ListItemButton } from '@mui/material';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const modalStyle = {
|
|
25
|
-
position: 'absolute',
|
|
26
|
-
top: '50%',
|
|
27
|
-
left: '60%',
|
|
28
|
-
width: 350,
|
|
29
|
-
height: 280,
|
|
30
|
-
bgcolor: 'background.paper',
|
|
31
|
-
boxShadow: 24,
|
|
32
|
-
p: 4,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const mobileStyle = {
|
|
36
|
-
position: 'absolute',
|
|
37
|
-
top: '30%',
|
|
38
|
-
left: '20%',
|
|
39
|
-
width: 200,
|
|
40
|
-
height: 300,
|
|
41
|
-
bgcolor: 'background.paper',
|
|
42
|
-
boxShadow: 24,
|
|
43
|
-
p: 4,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* MlSpatialElevationProfileDemoViewer returns a button to load a Demo GPX Track into the map.
|
|
48
|
-
*/
|
|
49
|
-
const MlGPXDemoLoader = (props) => {
|
|
50
|
-
|
|
51
|
-
const [openModal, setOpenModal] = useState(false);
|
|
52
|
-
const [infoOpen, setInfoOpen] = useState(false);
|
|
53
|
-
const [metaData, setMetaData] = useState([]);
|
|
54
|
-
const [selectedSample, setSelectedSample] = useState();
|
|
55
|
-
const mapHook = useMap({ mapId: 'map_1' });
|
|
56
|
-
const dataSource = useContext(GeoJsonContext);
|
|
57
|
-
const sourceName = 'import-source';
|
|
58
|
-
const [file, setFile] = useState();
|
|
59
|
-
const reader = useRef(new FileReader());
|
|
60
|
-
reader.current.onload = (payload) => {
|
|
61
|
-
if (!payload) return;
|
|
62
|
-
setFile(payload.currentTarget.result);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const mediaIsMobile = useMediaQuery('(max-width:900px)');
|
|
66
|
-
|
|
67
|
-
const toogleDrawer = () => {
|
|
68
|
-
setInfoOpen(!infoOpen);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const handleClick = () => {
|
|
72
|
-
setOpenModal(true);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const handleSelect = (e) => {
|
|
76
|
-
|
|
77
|
-
if (e.target.innerText === 'mountain_trail.gpx') {
|
|
78
|
-
setSelectedSample('assets/sample1.gpx');
|
|
79
|
-
} else if (e.target.innerText === 'bycycle_tour.gpx') {
|
|
80
|
-
setSelectedSample('assets/sample2.gpx');
|
|
81
|
-
} else {
|
|
82
|
-
setSelectedSample('assets/sample3.gpx');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
e.target.style.backgroundColor = 'lightgray';
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
useEffect(() => {
|
|
89
|
-
if (!selectedSample) return;
|
|
90
|
-
fetch(selectedSample)
|
|
91
|
-
.then(function (response) {
|
|
92
|
-
return response.blob();
|
|
93
|
-
})
|
|
94
|
-
.then(function (gpx) {
|
|
95
|
-
reader.current.readAsText(gpx);
|
|
96
|
-
});
|
|
97
|
-
}, [selectedSample]);
|
|
98
|
-
|
|
99
|
-
const handleLoad = useCallback(() => {
|
|
100
|
-
addGPXToMap(file);
|
|
101
|
-
setOpenModal(false);
|
|
102
|
-
}, [file]);
|
|
103
|
-
|
|
104
|
-
const handleClose = () => {
|
|
105
|
-
setOpenModal(false);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
const addGPXToMap = (gpxAsString) => {
|
|
109
|
-
if (!mapHook.map || !dataSource.setData) return;
|
|
110
|
-
try {
|
|
111
|
-
setMetaData([]);
|
|
112
|
-
const domParser = new DOMParser();
|
|
113
|
-
const gpxDoc = domParser.parseFromString(gpxAsString, 'application/xml');
|
|
114
|
-
const metadata = gpxDoc.querySelector('metadata');
|
|
115
|
-
metadata?.childNodes.forEach((node) => {
|
|
116
|
-
let value = node.textContent;
|
|
117
|
-
const title = node.nodeName;
|
|
118
|
-
|
|
119
|
-
if (node.nodeName === 'link') {
|
|
120
|
-
value = node.getAttribute('href');
|
|
121
|
-
}
|
|
122
|
-
if (value?.trim().length) {
|
|
123
|
-
const metaDatEntry = {
|
|
124
|
-
title: title,
|
|
125
|
-
value: value,
|
|
126
|
-
id: new Date().getTime(),
|
|
127
|
-
};
|
|
128
|
-
setMetaData((prevState) => [...prevState, metaDatEntry]);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
const data = toGeoJSON.gpx(gpxDoc);
|
|
132
|
-
dataSource.setData(data);
|
|
133
|
-
mapHook.map.map.getSource(sourceName).setData(data);
|
|
134
|
-
const bounds = bbox(data);
|
|
135
|
-
mapHook.map.map.fitBounds(bounds);
|
|
136
|
-
} catch (e) {
|
|
137
|
-
console.log(e);
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<>
|
|
143
|
-
<Modal
|
|
144
|
-
open={openModal}
|
|
145
|
-
onClose={handleClose}
|
|
146
|
-
aria-labelledby="modal-modal-title"
|
|
147
|
-
aria-describedby="modal-modal-description"
|
|
148
|
-
>
|
|
149
|
-
<Box sx={mediaIsMobile ? mobileStyle : modalStyle}>
|
|
150
|
-
<Grid container>
|
|
151
|
-
<Grid xs={10}>
|
|
152
|
-
<Typography id="modal-modal-title" variant="h6">
|
|
153
|
-
GPX demo files
|
|
154
|
-
</Typography>
|
|
155
|
-
</Grid>
|
|
156
|
-
<Grid xs={2}>
|
|
157
|
-
<Button onClick={handleClose}>
|
|
158
|
-
<CloseIcon sx={{ color: 'black' }} />
|
|
159
|
-
</Button>
|
|
160
|
-
</Grid>
|
|
161
|
-
</Grid>
|
|
162
|
-
<Divider />
|
|
163
|
-
|
|
164
|
-
<List>
|
|
165
|
-
<ListItem>
|
|
166
|
-
<ListItemButton value="sample1" onClick={handleSelect}>
|
|
167
|
-
<ListItemText> mountain_trail.gpx </ListItemText>
|
|
168
|
-
</ListItemButton>
|
|
169
|
-
</ListItem>
|
|
170
|
-
<Divider variant="inset" component="li" />
|
|
171
|
-
<ListItem>
|
|
172
|
-
<ListItemButton value="sample2" onClick={handleSelect}>
|
|
173
|
-
<ListItemText> bycycle_tour.gpx </ListItemText>
|
|
174
|
-
</ListItemButton>
|
|
175
|
-
</ListItem>
|
|
176
|
-
<Divider variant="inset" component="li" />
|
|
177
|
-
<ListItem>
|
|
178
|
-
<ListItemButton value="sample3" onClick={handleSelect}>
|
|
179
|
-
<ListItemText>treckking.gpx </ListItemText>
|
|
180
|
-
</ListItemButton>
|
|
181
|
-
</ListItem>
|
|
182
|
-
<Divider variant="inset" component="li" />
|
|
183
|
-
</List>
|
|
184
|
-
|
|
185
|
-
<Grid>
|
|
186
|
-
<Button
|
|
187
|
-
variant="outlined"
|
|
188
|
-
onClick={handleLoad}
|
|
189
|
-
sx={{ display: 'block', marginLeft: 'auto' }}
|
|
190
|
-
>
|
|
191
|
-
Load
|
|
192
|
-
</Button>
|
|
193
|
-
</Grid>
|
|
194
|
-
</Box>
|
|
195
|
-
</Modal>
|
|
196
|
-
|
|
197
|
-
<Drawer variant="persistent" anchor="left" open={infoOpen}>
|
|
198
|
-
<Typography
|
|
199
|
-
variant="h6"
|
|
200
|
-
style={{
|
|
201
|
-
textAlign: "center",
|
|
202
|
-
padding: "1em",
|
|
203
|
-
}}
|
|
204
|
-
noWrap
|
|
205
|
-
>
|
|
206
|
-
Informationen zur Route
|
|
207
|
-
</Typography>
|
|
208
|
-
<Divider />
|
|
209
|
-
<List>
|
|
210
|
-
{metaData.map((item) => (
|
|
211
|
-
<ListItem key={`item--${item.id}`}>
|
|
212
|
-
<ListItemText primary={item.value} />
|
|
213
|
-
</ListItem>
|
|
214
|
-
))}
|
|
215
|
-
</List>
|
|
216
|
-
</Drawer>
|
|
217
|
-
|
|
218
|
-
{props.enabled && (
|
|
219
|
-
<div
|
|
220
|
-
style={{
|
|
221
|
-
position: 'fixed',
|
|
222
|
-
right: '5px',
|
|
223
|
-
bottom: mediaIsMobile ? '40px' : '25px',
|
|
224
|
-
display: 'flex',
|
|
225
|
-
flexDirection: 'column',
|
|
226
|
-
gap: '5px',
|
|
227
|
-
zIndex: 3000,
|
|
228
|
-
}}
|
|
229
|
-
>
|
|
230
|
-
<IconButton
|
|
231
|
-
onClick={handleClick}
|
|
232
|
-
style={{
|
|
233
|
-
backgroundColor: '#cbd300',
|
|
234
|
-
}}
|
|
235
|
-
size="large"
|
|
236
|
-
>
|
|
237
|
-
<FileCopy />
|
|
238
|
-
</IconButton>
|
|
239
|
-
<IconButton
|
|
240
|
-
onClick={toogleDrawer}
|
|
241
|
-
style={{
|
|
242
|
-
backgroundColor: '#cbd300',
|
|
243
|
-
}}
|
|
244
|
-
size="large"
|
|
245
|
-
>
|
|
246
|
-
<InfoIcon />
|
|
247
|
-
</IconButton>
|
|
248
|
-
</div>
|
|
249
|
-
)}
|
|
250
|
-
</>
|
|
251
|
-
);
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
export default MlGPXDemoLoader;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import MlImageMarkerLayer from "./MlImageMarkerLayer";
|
|
4
|
-
|
|
5
|
-
import mapContextDecorator from "../../decorators/MapContextDecorator";
|
|
6
|
-
import wgMarker from "./assets/wg-marker.png";
|
|
7
|
-
|
|
8
|
-
const storyoptions = {
|
|
9
|
-
title: "MapComponents/MlImageMarkerLayer",
|
|
10
|
-
component: MlImageMarkerLayer,
|
|
11
|
-
argTypes: { },
|
|
12
|
-
decorators: mapContextDecorator,
|
|
13
|
-
};
|
|
14
|
-
export default storyoptions;
|
|
15
|
-
|
|
16
|
-
const Template = (args) => (
|
|
17
|
-
<MlImageMarkerLayer
|
|
18
|
-
options={{
|
|
19
|
-
type: "symbol",
|
|
20
|
-
source: {
|
|
21
|
-
type: "geojson",
|
|
22
|
-
data: {
|
|
23
|
-
type: "Feature",
|
|
24
|
-
properties: {
|
|
25
|
-
id: "test",
|
|
26
|
-
},
|
|
27
|
-
geometry: {
|
|
28
|
-
type: "Point",
|
|
29
|
-
coordinates: [7.0847929969609424, 50.73855193187643],
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
layout: {
|
|
34
|
-
"icon-allow-overlap": true,
|
|
35
|
-
"icon-size": 0.14,
|
|
36
|
-
"icon-offset": [0, -180],
|
|
37
|
-
},
|
|
38
|
-
}}
|
|
39
|
-
imgSrc={wgMarker}
|
|
40
|
-
/>
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
export const ExampleConfig = Template.bind({});
|
|
44
|
-
ExampleConfig.parameters = {};
|
|
45
|
-
ExampleConfig.args = {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import MlLayerMagnify from "./MlLayerMagnify";
|
|
4
|
-
import MlWmsLayer from "../MlWmsLayer/MlWmsLayer";
|
|
5
|
-
|
|
6
|
-
import multiMapContextDecorator from "../../decorators/MultiMapContextDecorator";
|
|
7
|
-
|
|
8
|
-
const storyoptions = {
|
|
9
|
-
title: "MapComponents/MlLayerMagnify",
|
|
10
|
-
component: MlLayerMagnify,
|
|
11
|
-
argTypes: {
|
|
12
|
-
},
|
|
13
|
-
decorators: multiMapContextDecorator,
|
|
14
|
-
};
|
|
15
|
-
export default storyoptions;
|
|
16
|
-
|
|
17
|
-
const Template = (args) => (
|
|
18
|
-
<>
|
|
19
|
-
<MlWmsLayer
|
|
20
|
-
url="https://www.wms.nrw.de/geobasis/wms_nw_uraufnahme"
|
|
21
|
-
urlParameters={{
|
|
22
|
-
layers: "nw_uraufnahme_rw",
|
|
23
|
-
}}
|
|
24
|
-
sourceOptions={{
|
|
25
|
-
minzoom: 13,
|
|
26
|
-
maxzoom: 20,
|
|
27
|
-
}}
|
|
28
|
-
mapId={args.wmsLayerMapId}
|
|
29
|
-
/>
|
|
30
|
-
<MlLayerMagnify map1Id="map_1" map2Id="map_2" magnifierRadius={args.magnifierRadius} />
|
|
31
|
-
</>
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
export const ExampleConfig = Template.bind({});
|
|
35
|
-
ExampleConfig.parameters = {
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
ExampleConfig.args = {
|
|
39
|
-
wmsLayerMapId: "map_2",
|
|
40
|
-
magnifierRadius: 200,
|
|
41
|
-
};
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import React, { useCallback, useRef, useContext, useEffect } from "react";
|
|
2
|
-
import MapContext from "../../contexts/MapContext";
|
|
3
|
-
import GeoJsonContext from "../MlGPXViewer/util/GeoJsonContext";
|
|
4
|
-
import { polygon, lineString } from "@turf/helpers";
|
|
5
|
-
import { distance, lineOffset } from "@turf/turf";
|
|
6
|
-
import { v4 as uuidv4 } from "uuid";
|
|
7
|
-
import PropTypes from "prop-types";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* MlSpatialElevationProfile returns a Button that will add a standard OSM tile layer to the maplibre-gl instance.
|
|
11
|
-
*
|
|
12
|
-
* @component
|
|
13
|
-
*/
|
|
14
|
-
const MlSpatialElevationProfile = (props) => {
|
|
15
|
-
const mapContext = useContext(MapContext);
|
|
16
|
-
|
|
17
|
-
const componentId = useRef(
|
|
18
|
-
(props.idPrefix ? props.idPrefix : "MlSpatialElevationProfile-") + uuidv4()
|
|
19
|
-
);
|
|
20
|
-
const mapRef = useRef(null);
|
|
21
|
-
const initializedRef = useRef(false);
|
|
22
|
-
|
|
23
|
-
const dataSource = useContext(GeoJsonContext);
|
|
24
|
-
const sourceName = useRef("elevationprofile-" + uuidv4());
|
|
25
|
-
const layerName = useRef("elevationprofile-layer-" + uuidv4());
|
|
26
|
-
|
|
27
|
-
const createStep = useCallback(
|
|
28
|
-
(x, y, z, x2, y2) => {
|
|
29
|
-
//const summand = 0.0002;
|
|
30
|
-
const line = lineString([
|
|
31
|
-
[x, y],
|
|
32
|
-
[x2, y2],
|
|
33
|
-
]);
|
|
34
|
-
const offsetLine = lineOffset(line, 5, { units: "meters" });
|
|
35
|
-
const x3 = offsetLine.geometry.coordinates[0][0];
|
|
36
|
-
const y3 = offsetLine.geometry.coordinates[0][1];
|
|
37
|
-
const x4 = offsetLine.geometry.coordinates[1][0];
|
|
38
|
-
const y4 = offsetLine.geometry.coordinates[1][1];
|
|
39
|
-
|
|
40
|
-
return polygon(
|
|
41
|
-
[
|
|
42
|
-
[
|
|
43
|
-
[x, y],
|
|
44
|
-
[x2, y2],
|
|
45
|
-
|
|
46
|
-
[x4, y4],
|
|
47
|
-
[x3, y3],
|
|
48
|
-
[x, y],
|
|
49
|
-
],
|
|
50
|
-
],
|
|
51
|
-
{ height: z * props.elevationFactor }
|
|
52
|
-
);
|
|
53
|
-
},
|
|
54
|
-
[props.elevationFactor]
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
let _componentId = componentId.current;
|
|
59
|
-
return () => {
|
|
60
|
-
// This is the cleanup function, it is called when this react component is removed from react-dom
|
|
61
|
-
if (mapRef.current) {
|
|
62
|
-
mapRef.current.cleanup(_componentId);
|
|
63
|
-
|
|
64
|
-
mapRef.current = null;
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}, []);
|
|
68
|
-
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
|
|
71
|
-
|
|
72
|
-
initializedRef.current = true;
|
|
73
|
-
mapRef.current = mapContext.getMap(props.mapId);
|
|
74
|
-
|
|
75
|
-
mapRef.current.addSource(
|
|
76
|
-
sourceName.current,
|
|
77
|
-
{
|
|
78
|
-
type: "geojson",
|
|
79
|
-
data: dataSource.data,
|
|
80
|
-
},
|
|
81
|
-
componentId.current
|
|
82
|
-
);
|
|
83
|
-
mapRef.current.addLayer(
|
|
84
|
-
{
|
|
85
|
-
id: layerName.current,
|
|
86
|
-
source: sourceName.current,
|
|
87
|
-
type: "fill-extrusion",
|
|
88
|
-
paint: {
|
|
89
|
-
"fill-extrusion-height": ["get", "height"],
|
|
90
|
-
"fill-extrusion-opacity": 0.9,
|
|
91
|
-
"fill-extrusion-color": [
|
|
92
|
-
"interpolate",
|
|
93
|
-
["linear"],
|
|
94
|
-
["get", "height"],
|
|
95
|
-
0,
|
|
96
|
-
"rgba(0, 0, 255, 0)",
|
|
97
|
-
0.1,
|
|
98
|
-
"royalblue",
|
|
99
|
-
0.3,
|
|
100
|
-
"cyan",
|
|
101
|
-
0.5,
|
|
102
|
-
"lime",
|
|
103
|
-
0.7,
|
|
104
|
-
"yellow",
|
|
105
|
-
1,
|
|
106
|
-
"yellow",
|
|
107
|
-
],
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
props.insertBeforeLayer,
|
|
111
|
-
componentId.current
|
|
112
|
-
);
|
|
113
|
-
}, [mapContext.mapIds, props.insertBeforeLayer, props.mapId, dataSource, mapContext]);
|
|
114
|
-
|
|
115
|
-
useEffect(() => {
|
|
116
|
-
if (!mapRef.current || !mapRef.current.getLayer(layerName.current)) return;
|
|
117
|
-
const { data } = dataSource;
|
|
118
|
-
if (!data || !data.features) return;
|
|
119
|
-
|
|
120
|
-
const line = data.features.find((element) => {
|
|
121
|
-
return element.geometry.type === "LineString";
|
|
122
|
-
});
|
|
123
|
-
if (!line || !line.geometry) return;
|
|
124
|
-
const heights = line.geometry.coordinates.map((coordinate, index) => {
|
|
125
|
-
return coordinate[2];
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const min = Math.min(...heights);
|
|
129
|
-
|
|
130
|
-
let max = Math.max(...heights) - min;
|
|
131
|
-
|
|
132
|
-
max = max === 0 ? 1 : max;
|
|
133
|
-
|
|
134
|
-
mapRef.current.setPaintProperty(layerName.current, "fill-extrusion-color", [
|
|
135
|
-
"interpolate",
|
|
136
|
-
["linear"],
|
|
137
|
-
["get", "height"],
|
|
138
|
-
0,
|
|
139
|
-
"rgb(0,255,55)",
|
|
140
|
-
max * props.elevationFactor,
|
|
141
|
-
"rgb(255,0,0)",
|
|
142
|
-
]);
|
|
143
|
-
const lerp = (x, y, a) => x * (1 - a) + y * a;
|
|
144
|
-
const points = [];
|
|
145
|
-
|
|
146
|
-
line.geometry.coordinates.forEach((coordinate, index) => {
|
|
147
|
-
//const point = createPoint(coordinate[0],coordinate[1],coordinate[2]-min);
|
|
148
|
-
//points.push(point);
|
|
149
|
-
if (line.geometry.coordinates[index + 1]) {
|
|
150
|
-
const wayLength = distance(
|
|
151
|
-
[coordinate[0], coordinate[1]],
|
|
152
|
-
[line.geometry.coordinates[index + 1][0], line.geometry.coordinates[index + 1][1]],
|
|
153
|
-
{ units: "kilometers" }
|
|
154
|
-
);
|
|
155
|
-
let listLength = ~~((wayLength * 1000) / 10);
|
|
156
|
-
listLength = listLength < 1 ? 1 : listLength;
|
|
157
|
-
for (let i = 0; i < listLength; i++) {
|
|
158
|
-
const x = lerp(
|
|
159
|
-
line.geometry.coordinates[index][0],
|
|
160
|
-
line.geometry.coordinates[index + 1][0],
|
|
161
|
-
i / listLength
|
|
162
|
-
);
|
|
163
|
-
const y = lerp(
|
|
164
|
-
line.geometry.coordinates[index][1],
|
|
165
|
-
line.geometry.coordinates[index + 1][1],
|
|
166
|
-
i / listLength
|
|
167
|
-
);
|
|
168
|
-
const z = lerp(
|
|
169
|
-
line.geometry.coordinates[index][2] - min,
|
|
170
|
-
line.geometry.coordinates[index + 1][2] - min,
|
|
171
|
-
i / listLength
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
const x2 = lerp(
|
|
175
|
-
line.geometry.coordinates[index][0],
|
|
176
|
-
line.geometry.coordinates[index + 1][0],
|
|
177
|
-
(i + 1) / listLength
|
|
178
|
-
);
|
|
179
|
-
const y2 = lerp(
|
|
180
|
-
line.geometry.coordinates[index][1],
|
|
181
|
-
line.geometry.coordinates[index + 1][1],
|
|
182
|
-
(i + 1) / listLength
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
const point = createStep(x, y, z, x2, y2);
|
|
186
|
-
points.push(point);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
const newData = dataSource.getEmptyFeatureCollection();
|
|
192
|
-
newData.features = points;
|
|
193
|
-
|
|
194
|
-
mapRef.current.getSource(sourceName.current)?.setData(newData);
|
|
195
|
-
}, [dataSource.data, createStep, dataSource, props.elevationFactor, mapContext]);
|
|
196
|
-
|
|
197
|
-
return <></>;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
MlSpatialElevationProfile.defaultProps = {
|
|
201
|
-
elevationFactor: 1,
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
MlSpatialElevationProfile.propTypes = {
|
|
205
|
-
/**
|
|
206
|
-
* Id of the target MapLibre instance in mapContext
|
|
207
|
-
*/
|
|
208
|
-
mapId: PropTypes.string,
|
|
209
|
-
/**
|
|
210
|
-
* Prefix of the component id this component uses when adding elements to the MapLibreGl-instance
|
|
211
|
-
*/
|
|
212
|
-
idPrefix: PropTypes.string,
|
|
213
|
-
/**
|
|
214
|
-
* Number describes the factor of the height of the elevation
|
|
215
|
-
*/
|
|
216
|
-
elevationFactor: PropTypes.number,
|
|
217
|
-
/**
|
|
218
|
-
* The layerId of an existing layer this layer should be rendered visually beneath
|
|
219
|
-
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
220
|
-
*/
|
|
221
|
-
insertBeforeLayer: PropTypes.string,
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
export default MlSpatialElevationProfile;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import MlSpatialElevationProfile from "./MlSpatialElevationProfile";
|
|
4
|
-
import MlGPXViewer from "../MlGPXViewer/MlGPXViewer";
|
|
5
|
-
|
|
6
|
-
import mapContextDecorator from "../../decorators/MapContextDecorator";
|
|
7
|
-
import GeoJsonProvider from "../MlGPXViewer/util/GeoJsonProvider";
|
|
8
|
-
import FileDownloadIcon from "@mui/icons-material/FileDownload";
|
|
9
|
-
import IconButton from "@mui/material/IconButton";
|
|
10
|
-
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
11
|
-
|
|
12
|
-
const storyoptions = {
|
|
13
|
-
title: "MapComponents/MlSpatialElevationProfile",
|
|
14
|
-
component: MlSpatialElevationProfile,
|
|
15
|
-
argTypes: {
|
|
16
|
-
options: {
|
|
17
|
-
control: {
|
|
18
|
-
type: "object",
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
decorators: mapContextDecorator,
|
|
23
|
-
};
|
|
24
|
-
export default storyoptions;
|
|
25
|
-
|
|
26
|
-
const Template = (args) => {
|
|
27
|
-
|
|
28
|
-
const mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
29
|
-
|
|
30
|
-
return(
|
|
31
|
-
<>
|
|
32
|
-
<IconButton
|
|
33
|
-
style={{
|
|
34
|
-
position: "absolute",
|
|
35
|
-
right: "5px",
|
|
36
|
-
bottom: mediaIsMobile ? "145px" : "125px",
|
|
37
|
-
backgroundColor: "rgba(255,255,255,1)",
|
|
38
|
-
|
|
39
|
-
zIndex: 1000,
|
|
40
|
-
}}
|
|
41
|
-
title="Download sample-data"
|
|
42
|
-
size="large"
|
|
43
|
-
href="assets/sample.gpx"
|
|
44
|
-
target="blank"
|
|
45
|
-
>
|
|
46
|
-
<FileDownloadIcon />
|
|
47
|
-
</IconButton>
|
|
48
|
-
<GeoJsonProvider>
|
|
49
|
-
<MlGPXViewer />
|
|
50
|
-
<MlSpatialElevationProfile />
|
|
51
|
-
</GeoJsonProvider>
|
|
52
|
-
</>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const ExampleConfig = Template.bind({});
|
|
57
|
-
ExampleConfig.parameters = {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
|
|
3
|
-
import TopToolbar from "../../ui_components/TopToolbar";
|
|
4
|
-
import MlThreeJsLayer from "./MlThreeJsLayer";
|
|
5
|
-
|
|
6
|
-
import mapContextDecorator from "../../decorators/MapContextDecorator";
|
|
7
|
-
import { LoadingOverlayContext } from "../../ui_components/LoadingOverlayContext";
|
|
8
|
-
|
|
9
|
-
const storyoptions = {
|
|
10
|
-
title: "MapComponents/MlThreeJsLayer",
|
|
11
|
-
component: MlThreeJsLayer,
|
|
12
|
-
argTypes: {
|
|
13
|
-
options: {
|
|
14
|
-
control: {
|
|
15
|
-
type: "object",
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
decorators: mapContextDecorator,
|
|
20
|
-
};
|
|
21
|
-
export default storyoptions;
|
|
22
|
-
|
|
23
|
-
const Template = (args) => {
|
|
24
|
-
const loadingOverlayContext = useContext(LoadingOverlayContext);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<TopToolbar>
|
|
28
|
-
<MlThreeJsLayer
|
|
29
|
-
init={() => loadingOverlayContext?.setControlled?.(true)}
|
|
30
|
-
onDone={() =>
|
|
31
|
-
setTimeout(() => loadingOverlayContext?.setLoadingDone?.(true), 1200)
|
|
32
|
-
}
|
|
33
|
-
/>
|
|
34
|
-
</TopToolbar>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const ExampleConfig = Template.bind({});
|
|
39
|
-
ExampleConfig.parameters = {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
|
|
3
|
-
import MlWmsLoader from "./MlWmsLoader";
|
|
4
|
-
|
|
5
|
-
import TextField from "@mui/material/TextField";
|
|
6
|
-
import mapContextDecorator from "../../decorators/MapContextDecorator";
|
|
7
|
-
import Sidebar from "../../ui_components/Sidebar";
|
|
8
|
-
|
|
9
|
-
const storyoptions = {
|
|
10
|
-
title: "MapComponents/MlWmsLoader",
|
|
11
|
-
component: MlWmsLoader,
|
|
12
|
-
argTypes: {
|
|
13
|
-
url: {},
|
|
14
|
-
layer: {},
|
|
15
|
-
},
|
|
16
|
-
decorators: mapContextDecorator,
|
|
17
|
-
};
|
|
18
|
-
export default storyoptions;
|
|
19
|
-
|
|
20
|
-
const Template = (props) => {
|
|
21
|
-
const [url, setUrl] = useState(props.url);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<>
|
|
25
|
-
<Sidebar sx={{ wordBreak: "break-word" }}>
|
|
26
|
-
<TextField
|
|
27
|
-
label="WMS Url"
|
|
28
|
-
variant="standard"
|
|
29
|
-
value={url}
|
|
30
|
-
onChange={(ev) => setUrl(ev.target.value)}
|
|
31
|
-
/>
|
|
32
|
-
<MlWmsLoader {...props} url={url} />
|
|
33
|
-
</Sidebar>
|
|
34
|
-
</>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export const ExampleConfig = Template.bind({});
|
|
39
|
-
ExampleConfig.parameters = {};
|
|
40
|
-
ExampleConfig.args = {
|
|
41
|
-
/**
|
|
42
|
-
* try https://maps.heigit.org/histosm/wms or https://magosm.magellium.com/geoserver/wms
|
|
43
|
-
* https://www.wms.nrw.de/wms/kitas
|
|
44
|
-
* https://www.wms.nrw.de/geobasis/wms_nw_vdop
|
|
45
|
-
*/
|
|
46
|
-
url: "https://www.wms.nrw.de/geobasis/wms_nw_vdop",
|
|
47
|
-
};
|