@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
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { distance, lineOffset } from '@turf/turf';
|
|
2
|
+
import { polygon, lineString, featureCollection} from '@turf/helpers';
|
|
3
|
+
import { GeoJSONFeature } from 'maplibre-gl';
|
|
4
|
+
|
|
5
|
+
interface geometry{
|
|
6
|
+
coordinates: Array<number>
|
|
7
|
+
}
|
|
8
|
+
interface line {
|
|
9
|
+
geometry: geometry
|
|
10
|
+
}
|
|
11
|
+
interface _geojsonInfo {
|
|
12
|
+
line: line,
|
|
13
|
+
min: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export default function getElevationData(_geojsonInfo: _geojsonInfo, elevationFactor: number) {
|
|
19
|
+
|
|
20
|
+
const createStep = (x: number, y: number, z: number, x2: number, y2: number) => {
|
|
21
|
+
//const summand = 0.0002;
|
|
22
|
+
const line = lineString([
|
|
23
|
+
[x, y],
|
|
24
|
+
[x2, y2],
|
|
25
|
+
]);
|
|
26
|
+
const offsetLine = lineOffset(line, 5, { units: 'meters' });
|
|
27
|
+
const x3 = offsetLine.geometry.coordinates[0][0];
|
|
28
|
+
const y3 = offsetLine.geometry.coordinates[0][1];
|
|
29
|
+
const x4 = offsetLine.geometry.coordinates[1][0];
|
|
30
|
+
const y4 = offsetLine.geometry.coordinates[1][1];
|
|
31
|
+
|
|
32
|
+
return polygon(
|
|
33
|
+
[
|
|
34
|
+
[
|
|
35
|
+
[x, y],
|
|
36
|
+
[x2, y2],
|
|
37
|
+
|
|
38
|
+
[x4, y4],
|
|
39
|
+
[x3, y3],
|
|
40
|
+
[x, y],
|
|
41
|
+
],
|
|
42
|
+
],
|
|
43
|
+
{ height: z * elevationFactor }
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const lerp = (x: number, y: number, a: number) => x * (1 - a) + y * a;
|
|
48
|
+
const points: GeoJSONFeature[] = [];
|
|
49
|
+
|
|
50
|
+
_geojsonInfo.line.geometry.coordinates.forEach((coordinate: number, index: number) => {
|
|
51
|
+
//const point = createPoint(coordinate[0],coordinate[1],coordinate[2]-min);
|
|
52
|
+
//points.push(point);
|
|
53
|
+
if (_geojsonInfo.line.geometry.coordinates[index + 1]) {
|
|
54
|
+
const wayLength = distance(
|
|
55
|
+
[coordinate[0], coordinate[1]],
|
|
56
|
+
[
|
|
57
|
+
_geojsonInfo.line.geometry.coordinates[index + 1][0],
|
|
58
|
+
_geojsonInfo.line.geometry.coordinates[index + 1][1],
|
|
59
|
+
],
|
|
60
|
+
{ units: 'kilometers' }
|
|
61
|
+
);
|
|
62
|
+
let listLength = ~~((wayLength * 1000) / 10);
|
|
63
|
+
listLength = listLength < 1 ? 1 : listLength;
|
|
64
|
+
for (let i = 0; i < listLength; i++) {
|
|
65
|
+
const x = lerp(
|
|
66
|
+
_geojsonInfo.line.geometry.coordinates[index][0],
|
|
67
|
+
_geojsonInfo.line.geometry.coordinates[index + 1][0],
|
|
68
|
+
i / listLength
|
|
69
|
+
);
|
|
70
|
+
const y = lerp(
|
|
71
|
+
_geojsonInfo.line.geometry.coordinates[index][1],
|
|
72
|
+
_geojsonInfo.line.geometry.coordinates[index + 1][1],
|
|
73
|
+
i / listLength
|
|
74
|
+
);
|
|
75
|
+
const z = lerp(
|
|
76
|
+
_geojsonInfo.line.geometry.coordinates[index][2] - _geojsonInfo.min,
|
|
77
|
+
_geojsonInfo.line.geometry.coordinates[index + 1][2] - _geojsonInfo.min,
|
|
78
|
+
i / listLength
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const x2 = lerp(
|
|
82
|
+
_geojsonInfo.line.geometry.coordinates[index][0],
|
|
83
|
+
_geojsonInfo.line.geometry.coordinates[index + 1][0],
|
|
84
|
+
(i + 1) / listLength
|
|
85
|
+
);
|
|
86
|
+
const y2 = lerp(
|
|
87
|
+
_geojsonInfo.line.geometry.coordinates[index][1],
|
|
88
|
+
_geojsonInfo.line.geometry.coordinates[index + 1][1],
|
|
89
|
+
(i + 1) / listLength
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const point = createStep(x, y, z, x2, y2);
|
|
93
|
+
points.push(point as unknown as GeoJSONFeature);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const output = featureCollection(points);
|
|
99
|
+
|
|
100
|
+
return output;
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
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 = () => {
|
|
24
|
+
const loadingOverlayContext = useContext(LoadingOverlayContext);
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<TopToolbar>
|
|
28
|
+
<MlThreeJsLayer
|
|
29
|
+
init={() => loadingOverlayContext?.setControlled?.(true)}
|
|
30
|
+
onDone={() => setTimeout(() => loadingOverlayContext?.setLoadingDone?.(true), 1200)}
|
|
31
|
+
/>
|
|
32
|
+
</TopToolbar>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const ExampleConfig = Template.bind({});
|
|
37
|
+
ExampleConfig.parameters = {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState,
|
|
1
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
2
2
|
|
|
3
3
|
import MlTransitionGeoJsonLayer from "./MlTransitionGeoJsonLayer";
|
|
4
4
|
|
|
@@ -7,9 +7,8 @@ import useMap from "../../hooks/useMap";
|
|
|
7
7
|
|
|
8
8
|
import sample_geojson_1 from "./assets/sample_1.json";
|
|
9
9
|
import sample_geojson_2 from "./assets/sample_2.json";
|
|
10
|
-
import sample_polygon_geojson_1 from "./assets/sample_polygon_1.json";
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
|
|
13
12
|
const storyoptions = {
|
|
14
13
|
title: "MapComponents/MlTransitionGeoJsonLayer",
|
|
15
14
|
component: MlTransitionGeoJsonLayer,
|
|
@@ -1,83 +1,23 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect, useCallback } from
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import MlGeoJsonLayer from "../MlGeoJsonLayer/MlGeoJsonLayer";
|
|
9
|
-
import { Feature, FeatureCollection } from "@turf/turf";
|
|
10
|
-
import { CircleLayerSpecification, FillLayerSpecification, LineLayerSpecification, MapLayerMouseEvent } from "maplibre-gl";
|
|
1
|
+
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
2
|
+
import * as turf from '@turf/turf';
|
|
3
|
+
import useMap from '../../hooks/useMap';
|
|
4
|
+
import { _transitionToGeojson } from './util/transitionFunctions';
|
|
5
|
+
import MlGeoJsonLayer from '../MlGeoJsonLayer/MlGeoJsonLayer';
|
|
6
|
+
import { Feature, FeatureCollection } from '@turf/turf';
|
|
7
|
+
import { MlGeoJsonLayerProps } from '../MlGeoJsonLayer/MlGeoJsonLayer';
|
|
11
8
|
|
|
12
9
|
const msPerStep = 50;
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Id of the target MapLibre instance in mapContext
|
|
17
|
-
*/
|
|
18
|
-
mapId: string;
|
|
19
|
-
/**
|
|
20
|
-
* GeoJSON data that is supposed to be rendered by this component.
|
|
21
|
-
*/
|
|
22
|
-
geojson: Feature | FeatureCollection | undefined;
|
|
23
|
-
/**
|
|
24
|
-
* Type of the layer that will be added to the MapLibre instance.
|
|
25
|
-
* Possible values: "line", "circle", "fill"
|
|
26
|
-
*/
|
|
27
|
-
type?: "fill" | "line" | "circle";
|
|
28
|
-
/**
|
|
29
|
-
* Paint property object, that is passed to the addLayer call.
|
|
30
|
-
* Possible props depend on the layer type.
|
|
31
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
32
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
33
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
34
|
-
*/
|
|
35
|
-
paint?: CircleLayerSpecification['paint'] | FillLayerSpecification['paint'] | LineLayerSpecification['paint'];
|
|
36
|
-
/**
|
|
37
|
-
* Layout property object, that is passed to the addLayer call.
|
|
38
|
-
* Possible props depend on the layer type.
|
|
39
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
|
|
40
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
41
|
-
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
42
|
-
*/
|
|
43
|
-
layout?: CircleLayerSpecification['layout'] | FillLayerSpecification['layout'] | LineLayerSpecification['layout'];
|
|
44
|
-
/**
|
|
45
|
-
* Javascript object that is spread into the addLayer commands first parameter.
|
|
46
|
-
*/
|
|
47
|
-
options?: CircleLayerSpecification | FillLayerSpecification | LineLayerSpecification;
|
|
48
|
-
/**
|
|
49
|
-
* Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
|
|
50
|
-
*/
|
|
51
|
-
defaultPaintOverrides?: { circle?: CircleLayerSpecification['paint'], fill?: FillLayerSpecification['paint'], line?: LineLayerSpecification['paint'] };
|
|
52
|
-
/**
|
|
53
|
-
* Id of an existing layer in the mapLibre instance to help specify the layer order
|
|
54
|
-
* This layer will be visually beneath the layer with the "insertBeforeLayer" id.
|
|
55
|
-
*/
|
|
56
|
-
insertBeforeLayer: string;
|
|
57
|
-
/**
|
|
58
|
-
* Hover event handler that is executed whenever a geometry rendered by this component is hovered.
|
|
59
|
-
*/
|
|
60
|
-
onHover?: MapLayerMouseEvent;
|
|
61
|
-
/**
|
|
62
|
-
* Click event handler that is executed whenever a geometry rendered by this component is clicked.
|
|
63
|
-
*/
|
|
64
|
-
onClick?: MapLayerMouseEvent;
|
|
65
|
-
/**
|
|
66
|
-
* Leave event handler that is executed whenever a geometry rendered by this component is
|
|
67
|
-
* left/unhovered.
|
|
68
|
-
*/
|
|
69
|
-
onLeave?: MapLayerMouseEvent;
|
|
70
|
-
/**
|
|
71
|
-
* Creates transition animation whenever the geojson prop changes.
|
|
72
|
-
* Only works with layer type "line" and LineString GeoJSON data.
|
|
73
|
-
*/
|
|
11
|
+
type MlTransitionGeoJsonLayerProps = MlGeoJsonLayerProps & {
|
|
74
12
|
transitionTime: number;
|
|
75
|
-
}
|
|
13
|
+
};
|
|
76
14
|
|
|
77
15
|
/**
|
|
78
16
|
* Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
|
|
79
17
|
*/
|
|
80
18
|
const MlTransitionGeoJsonLayer = (props: MlTransitionGeoJsonLayerProps) => {
|
|
19
|
+
// ignore eslint. Only using `geojson` for destructuring
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
81
21
|
const { geojson, ...restProps } = props;
|
|
82
22
|
|
|
83
23
|
const mapHook = useMap({
|
|
@@ -93,9 +33,7 @@ const MlTransitionGeoJsonLayer = (props: MlTransitionGeoJsonLayerProps) => {
|
|
|
93
33
|
const currentTransitionStepRef = useRef(false);
|
|
94
34
|
const transitionGeojsonDataRef = useRef([]);
|
|
95
35
|
const transitionGeojsonCommonDataRef = useRef([]);
|
|
96
|
-
const [displayGeojson, setDisplayGeojson] = useState(
|
|
97
|
-
turf.featureCollection([])
|
|
98
|
-
);
|
|
36
|
+
const [displayGeojson, setDisplayGeojson] = useState(turf.featureCollection([]));
|
|
99
37
|
|
|
100
38
|
useEffect(() => {
|
|
101
39
|
return () => {
|
|
@@ -125,8 +63,8 @@ const MlTransitionGeoJsonLayer = (props: MlTransitionGeoJsonLayerProps) => {
|
|
|
125
63
|
if (!mapHook.map || !initializedRef.current) return;
|
|
126
64
|
|
|
127
65
|
if (
|
|
128
|
-
typeof props.transitionTime !==
|
|
129
|
-
props.type ===
|
|
66
|
+
typeof props.transitionTime !== 'undefined' &&
|
|
67
|
+
props.type === 'line' &&
|
|
130
68
|
oldGeojsonRef.current
|
|
131
69
|
) {
|
|
132
70
|
transitionInProgressRef.current = false;
|
|
@@ -140,10 +78,10 @@ const MlTransitionGeoJsonLayer = (props: MlTransitionGeoJsonLayerProps) => {
|
|
|
140
78
|
|
|
141
79
|
const startTransition = useCallback(() => {
|
|
142
80
|
if (
|
|
143
|
-
props.type ===
|
|
144
|
-
typeof props.transitionTime !==
|
|
81
|
+
props.type === 'line' &&
|
|
82
|
+
typeof props.transitionTime !== 'undefined' &&
|
|
145
83
|
props.transitionTime &&
|
|
146
|
-
typeof props.geojson !==
|
|
84
|
+
typeof props.geojson !== 'undefined' &&
|
|
147
85
|
JSON.stringify(oldGeojsonRef.current) !== JSON.stringify(props.geojson)
|
|
148
86
|
) {
|
|
149
87
|
transitionToGeojson();
|
|
@@ -43,8 +43,7 @@ const MlVectorTileLayer = (props: MlVectorTileLayerProps) => {
|
|
|
43
43
|
layerId.current,
|
|
44
44
|
{
|
|
45
45
|
type: 'vector',
|
|
46
|
-
tiles: [props.url],
|
|
47
|
-
tileSize: 512,
|
|
46
|
+
tiles: [props.url || ""],
|
|
48
47
|
attribution: '',
|
|
49
48
|
...props.sourceOptions,
|
|
50
49
|
},
|
|
@@ -60,6 +59,8 @@ const MlVectorTileLayer = (props: MlVectorTileLayerProps) => {
|
|
|
60
59
|
maxzoom: 22,
|
|
61
60
|
layout: {},
|
|
62
61
|
paint: {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
63
|
+
// @ts-ignore
|
|
63
64
|
'line-opacity': 0.5,
|
|
64
65
|
'line-color': 'rgb(80, 80, 80)',
|
|
65
66
|
'line-width': 2,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import MlWmsFeatureInfoPopup from './MlWmsFeatureInfoPopup';
|
|
4
|
+
|
|
5
|
+
import mapContextDecorator from '../../decorators/MapContextDecorator';
|
|
6
|
+
|
|
7
|
+
const storyoptions = {
|
|
8
|
+
title: 'MapComponents/MlWmsFeatureInfoPopup',
|
|
9
|
+
component: MlWmsFeatureInfoPopup,
|
|
10
|
+
argTypes: {
|
|
11
|
+
url: {},
|
|
12
|
+
layer: {},
|
|
13
|
+
},
|
|
14
|
+
decorators: mapContextDecorator,
|
|
15
|
+
};
|
|
16
|
+
export default storyoptions;
|
|
17
|
+
|
|
18
|
+
const Template = () => <MlWmsFeatureInfoPopup />;
|
|
19
|
+
|
|
20
|
+
export const ExampleConfig = Template.bind({});
|
|
21
|
+
ExampleConfig.parameters = {};
|
|
22
|
+
ExampleConfig.args = {};
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import React, { useRef, useEffect, useCallback } from
|
|
2
|
-
import useMap from
|
|
1
|
+
import React, { useMemo, useRef, useEffect, useCallback } from 'react';
|
|
2
|
+
import useMap from '../../hooks/useMap';
|
|
3
3
|
|
|
4
|
-
import PropTypes from
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { RasterLayerSpecification, RasterSourceSpecification } from 'maplibre-gl';
|
|
5
6
|
|
|
6
7
|
const defaultProps = {
|
|
7
8
|
visible: true,
|
|
8
9
|
urlParameters: {
|
|
9
|
-
bbox:
|
|
10
|
-
format:
|
|
11
|
-
service:
|
|
12
|
-
version:
|
|
13
|
-
request:
|
|
14
|
-
srs:
|
|
10
|
+
bbox: '{bbox-epsg-3857}',
|
|
11
|
+
format: 'image/png',
|
|
12
|
+
service: 'WMS',
|
|
13
|
+
version: '1.1.1',
|
|
14
|
+
request: 'GetMap',
|
|
15
|
+
srs: 'EPSG:3857',
|
|
15
16
|
width: 256,
|
|
16
17
|
height: 256,
|
|
17
|
-
styles:
|
|
18
|
+
styles: '',
|
|
18
19
|
},
|
|
19
|
-
attribution:
|
|
20
|
+
attribution: '',
|
|
20
21
|
sourceOptions: {
|
|
21
22
|
minZoom: 0,
|
|
22
23
|
maxZoom: 20,
|
|
@@ -28,13 +29,13 @@ const defaultProps = {
|
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
interface MlWmsLayerProps {
|
|
31
|
-
urlParameters?:
|
|
32
|
+
urlParameters?: { [key: string]: string };
|
|
32
33
|
url: string;
|
|
33
34
|
visible?: boolean;
|
|
34
35
|
attribution?: string;
|
|
35
36
|
mapId?: string;
|
|
36
|
-
sourceOptions?:
|
|
37
|
-
layerOptions?:
|
|
37
|
+
sourceOptions?: RasterSourceSpecification;
|
|
38
|
+
layerOptions?: RasterLayerSpecification;
|
|
38
39
|
insertBeforeLayer?: string;
|
|
39
40
|
layerId?: string;
|
|
40
41
|
}
|
|
@@ -61,40 +62,44 @@ const MlWmsLayer = (props: MlWmsLayerProps) => {
|
|
|
61
62
|
});
|
|
62
63
|
|
|
63
64
|
const initializedRef = useRef(false);
|
|
64
|
-
const layerId = useRef(props.layerId ||
|
|
65
|
-
|
|
66
|
-
const createLayer = useCallback(() => {
|
|
67
|
-
if (!mapHook.map) return;
|
|
68
|
-
|
|
69
|
-
initializedRef.current = true;
|
|
70
|
-
|
|
71
|
-
if (mapHook.map.map.getLayer(layerId.current)) {
|
|
72
|
-
mapHook.cleanup();
|
|
73
|
-
}
|
|
65
|
+
const layerId = useRef(props.layerId || 'MlWmsLayer-' + mapHook.componentId);
|
|
74
66
|
|
|
67
|
+
const tileUrl = useMemo(() => {
|
|
75
68
|
let _propsUrlParams;
|
|
76
69
|
let _wmsUrl = props.url;
|
|
77
|
-
if (props.url.indexOf(
|
|
78
|
-
_propsUrlParams = props.url.split(
|
|
70
|
+
if (props.url.indexOf('?') !== -1) {
|
|
71
|
+
_propsUrlParams = props.url.split('?');
|
|
79
72
|
_wmsUrl = _propsUrlParams[0];
|
|
80
73
|
}
|
|
81
|
-
|
|
74
|
+
const _urlParamsFromUrl = new URLSearchParams(_propsUrlParams?.[1]);
|
|
82
75
|
// first spread in default props manually to enable overriding a single parameter without replacing the whole default urlParameters object
|
|
83
|
-
|
|
76
|
+
const urlParamsObj = {
|
|
84
77
|
...defaultProps.urlParameters,
|
|
85
78
|
...Object.fromEntries(_urlParamsFromUrl),
|
|
86
79
|
...props.urlParameters,
|
|
87
80
|
};
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
decodeURIComponent(urlParams.toString()) +
|
|
81
|
+
const urlParams = new URLSearchParams(urlParamsObj as unknown as Record<string, string>);
|
|
82
|
+
const urlParamsStr =
|
|
83
|
+
decodeURIComponent(urlParams.toString()) + ''.replace(/%2F/g, '/').replace(/%3A/g, ':');
|
|
84
|
+
|
|
85
|
+
return _wmsUrl + '?' + urlParamsStr;
|
|
86
|
+
}, [props.urlParameters, props.url]);
|
|
87
|
+
|
|
88
|
+
const createLayer = useCallback(() => {
|
|
89
|
+
if (!mapHook.map) return;
|
|
90
|
+
|
|
91
|
+
initializedRef.current = true;
|
|
92
|
+
|
|
93
|
+
if (mapHook.map.map.getLayer(layerId.current)) {
|
|
94
|
+
mapHook.cleanup();
|
|
95
|
+
}
|
|
91
96
|
|
|
92
97
|
mapHook.map.addSource(
|
|
93
98
|
layerId.current,
|
|
94
99
|
{
|
|
95
|
-
type:
|
|
96
|
-
tiles: [
|
|
97
|
-
tileSize:
|
|
100
|
+
type: 'raster',
|
|
101
|
+
tiles: [tileUrl],
|
|
102
|
+
tileSize: 256,
|
|
98
103
|
attribution: props.attribution,
|
|
99
104
|
...props.sourceOptions,
|
|
100
105
|
},
|
|
@@ -104,7 +109,7 @@ const MlWmsLayer = (props: MlWmsLayerProps) => {
|
|
|
104
109
|
mapHook.map.addLayer(
|
|
105
110
|
{
|
|
106
111
|
id: layerId.current,
|
|
107
|
-
type:
|
|
112
|
+
type: 'raster',
|
|
108
113
|
source: layerId.current,
|
|
109
114
|
...props.layerOptions,
|
|
110
115
|
},
|
|
@@ -114,19 +119,19 @@ const MlWmsLayer = (props: MlWmsLayerProps) => {
|
|
|
114
119
|
|
|
115
120
|
// recreate layer if map style.json has changed
|
|
116
121
|
mapHook.map.on(
|
|
117
|
-
|
|
122
|
+
'styledata',
|
|
118
123
|
() => {
|
|
119
124
|
if (initializedRef.current && !mapHook.map?.map.getLayer(layerId.current)) {
|
|
120
|
-
console.log(
|
|
125
|
+
console.log('Recreate Layer ' + layerId.current);
|
|
121
126
|
createLayer();
|
|
122
127
|
}
|
|
123
128
|
},
|
|
124
129
|
mapHook.componentId
|
|
125
130
|
);
|
|
126
131
|
if (!props.visible) {
|
|
127
|
-
mapHook.map.map.setLayoutProperty(layerId.current,
|
|
132
|
+
mapHook.map.map.setLayoutProperty(layerId.current, 'visibility', 'none');
|
|
128
133
|
}
|
|
129
|
-
}, [mapHook.map, props]);
|
|
134
|
+
}, [mapHook.map, props, tileUrl]);
|
|
130
135
|
|
|
131
136
|
useEffect(() => {
|
|
132
137
|
if (initializedRef.current) return;
|
|
@@ -134,14 +139,27 @@ const MlWmsLayer = (props: MlWmsLayerProps) => {
|
|
|
134
139
|
createLayer();
|
|
135
140
|
}, [createLayer]);
|
|
136
141
|
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (!mapHook.map || !mapHook.map?.map?.style?.sourceCaches?.[layerId.current] || !initializedRef.current) return;
|
|
144
|
+
|
|
145
|
+
const source = mapHook.map.map.getSource(layerId.current) as RasterSourceSpecification;
|
|
146
|
+
source.tiles = [tileUrl];
|
|
147
|
+
|
|
148
|
+
mapHook.map.map.style.sourceCaches[layerId.current].clearTiles();
|
|
149
|
+
|
|
150
|
+
mapHook.map.map.style.sourceCaches[layerId.current].update(mapHook.map.map.transform);
|
|
151
|
+
|
|
152
|
+
mapHook.map.map.triggerRepaint();
|
|
153
|
+
}, [mapHook.map, tileUrl]);
|
|
154
|
+
|
|
137
155
|
useEffect(() => {
|
|
138
156
|
if (!mapHook.map || !initializedRef.current) return;
|
|
139
157
|
|
|
140
158
|
// toggle layer visibility by changing the layout object's visibility property
|
|
141
159
|
if (props.visible) {
|
|
142
|
-
mapHook.map.map.setLayoutProperty(layerId.current,
|
|
160
|
+
mapHook.map.map.setLayoutProperty(layerId.current, 'visibility', 'visible');
|
|
143
161
|
} else {
|
|
144
|
-
mapHook.map.map.setLayoutProperty(layerId.current,
|
|
162
|
+
mapHook.map.map.setLayoutProperty(layerId.current, 'visibility', 'none');
|
|
145
163
|
}
|
|
146
164
|
}, [props.visible, mapHook.map]);
|
|
147
165
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React, { useState} from 'react';
|
|
2
|
+
import MlWmsLoader from './MlWmsLoader';
|
|
3
|
+
import { Button, TextField, useMediaQuery } from '@mui/material';
|
|
4
|
+
import mapContextDecorator from '../../decorators/MapContextDecorator';
|
|
5
|
+
import Sidebar from '../../ui_components/Sidebar';
|
|
6
|
+
import TopToolbar from '../../ui_components/TopToolbar';
|
|
7
|
+
import MlWmsLoaderInstructions from './utils/MlWmsLoaderInstructions';
|
|
8
|
+
import WMSLinks from './utils/WMSLinks';
|
|
9
|
+
|
|
10
|
+
const storyoptions = {
|
|
11
|
+
title: 'MapComponents/MlWmsLoader',
|
|
12
|
+
component: MlWmsLoader,
|
|
13
|
+
argTypes: {
|
|
14
|
+
url: {},
|
|
15
|
+
layer: {},
|
|
16
|
+
},
|
|
17
|
+
decorators: mapContextDecorator,
|
|
18
|
+
};
|
|
19
|
+
export default storyoptions;
|
|
20
|
+
|
|
21
|
+
interface MlWmsLoaderStoryProps {
|
|
22
|
+
url: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const Template = (props: MlWmsLoaderStoryProps) => {
|
|
26
|
+
const [url, setUrl] = useState(props.url || "");
|
|
27
|
+
const [demoMode, setDemoMode] = useState(false);
|
|
28
|
+
const [guide, setGuide] = useState(false);
|
|
29
|
+
|
|
30
|
+
const mediaIsMobile = useMediaQuery('(max-width:900px)');
|
|
31
|
+
|
|
32
|
+
const openGuide = () => {
|
|
33
|
+
setGuide(true);
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
setGuide(false);
|
|
36
|
+
}, 5500);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const loader = (str: string) => {
|
|
40
|
+
setUrl(str);
|
|
41
|
+
setDemoMode(false);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<MlWmsLoaderInstructions open={guide} />
|
|
47
|
+
<WMSLinks open={demoMode} close={() => setDemoMode(false)} load={loader} />
|
|
48
|
+
<TopToolbar appBarStyle={{ zIndex: 1220 }}>
|
|
49
|
+
<Button
|
|
50
|
+
variant="contained"
|
|
51
|
+
onClick={openGuide}
|
|
52
|
+
sx={{ marginRight: '10px' }}
|
|
53
|
+
>
|
|
54
|
+
Guide me through
|
|
55
|
+
</Button>
|
|
56
|
+
<Button
|
|
57
|
+
variant="contained"
|
|
58
|
+
onClick={() => setDemoMode(!demoMode)}
|
|
59
|
+
|
|
60
|
+
>
|
|
61
|
+
Demo WMS
|
|
62
|
+
</Button>
|
|
63
|
+
</TopToolbar>
|
|
64
|
+
|
|
65
|
+
{!mediaIsMobile || (mediaIsMobile && !demoMode) ? (
|
|
66
|
+
<Sidebar
|
|
67
|
+
drawerPaperProps={{ sx: { top: '65px', maxWidth: '20%', padding: '40px' } }}
|
|
68
|
+
drawerButtonStyle={{ top: '65px' }}
|
|
69
|
+
sx={{ wordBreak: 'break-word' }}
|
|
70
|
+
>
|
|
71
|
+
<TextField
|
|
72
|
+
id="wms_text_field"
|
|
73
|
+
label="WMS Url"
|
|
74
|
+
variant="standard"
|
|
75
|
+
value={url}
|
|
76
|
+
onChange={(ev) => setUrl(ev.target.value)}
|
|
77
|
+
/>
|
|
78
|
+
<MlWmsLoader mapId={'map_1'} url={url} />
|
|
79
|
+
</Sidebar>
|
|
80
|
+
) : (
|
|
81
|
+
<></>
|
|
82
|
+
)}
|
|
83
|
+
</>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const ExampleConfig = Template.bind({});
|
|
88
|
+
ExampleConfig.parameters = {};
|
|
89
|
+
ExampleConfig.args = {};
|