@mapcomponents/react-maplibre 0.1.62 → 0.1.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +21 -2
- package/.editorconfig +1 -1
- package/.eslintrc.js +11 -1
- package/.github/workflows/check-catalogue-metadata-schema.yml +19 -0
- package/.storybook/main.js +0 -1
- package/.storybook/preview.js +0 -2
- package/CHANGELOG.md +43 -0
- package/coverage/clover.xml +864 -1037
- package/coverage/coverage-final.json +32 -21
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +170 -95
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +24 -24
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +5 -5
- package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +2 -2
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx.html +148 -0
- package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +22 -7
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +72 -42
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +15 -15
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +86 -35
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/{MlSpatialElevationProfile/MlSpatialElevationProfile.js.html → MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js.html} +215 -320
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js.html +649 -0
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.tsx.html +112 -0
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.tsx.html +115 -0
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/index.html +161 -0
- package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGpxViewer/MlGpxViewer.tsx.html +394 -0
- package/coverage/lcov-report/src/components/MlGpxViewer/index.html +116 -0
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +63 -285
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +21 -21
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +58 -76
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +58 -61
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +11 -11
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +30 -21
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/ColorPicker.tsx.html +214 -0
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerList.tsx.html +121 -0
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerListItem.tsx.html +412 -0
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx.html +463 -0
- package/coverage/lcov-report/src/components/MlSketchTool/LayerList/index.html +161 -0
- package/coverage/lcov-report/src/components/{MlGPXViewer/MlGPXViewer.tsx.html → MlSketchTool/MlSketchTool.tsx.html} +271 -589
- package/coverage/lcov-report/src/components/{MlGPXViewer → MlSketchTool}/index.html +22 -37
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.tsx.html +514 -0
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +21 -21
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +20 -206
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +10 -7
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +5 -5
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +111 -57
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +19 -19
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +201 -144
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +9 -9
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +23 -23
- package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
- package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
- package/coverage/lcov-report/src/contexts/index.html +1 -1
- package/coverage/lcov-report/src/hooks/index.html +50 -50
- package/coverage/lcov-report/src/hooks/useCameraFollowPath/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useCameraFollowPath/useCameraFollowPath.tsx.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/index.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/lib.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useGpx/index.html +116 -0
- package/coverage/lcov-report/src/hooks/useGpx/useGpx.tsx.html +295 -0
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +132 -66
- package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayerHoverPopup/index.html +116 -0
- package/coverage/lcov-report/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx.html +331 -0
- package/coverage/lcov-report/src/hooks/useMap.ts.html +47 -47
- package/coverage/lcov-report/src/hooks/useMapState.ts.html +54 -54
- package/coverage/lcov-report/src/hooks/useSource.ts.html +57 -57
- package/coverage/lcov-report/src/hooks/{useWms.js.html → useWms.ts.html} +54 -15
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +6 -6
- package/coverage/lcov.info +1724 -1974
- package/cypress/support/commands.ts +37 -0
- package/cypress/support/component-index.html +12 -0
- package/cypress/support/component.ts +46 -0
- package/cypress.config.ts +101 -0
- package/dist/components/MapLibreMap/MapLibreMap.d.ts +1 -1
- package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +53 -27
- package/dist/components/MlCenterPosition/MlCenterPosition.d.ts +3 -2
- package/dist/components/MlCenterPosition/MlCenterPosition.stories.d.ts +35 -16
- package/dist/components/MlComponentTemplate/MlComponentTemplate.d.ts +1 -1
- package/dist/components/MlComponentTemplate/MlComponentTemplate.stories.d.ts +12 -9
- package/dist/components/MlCreatePdfButton/MlCreatePdfButton.d.ts +1 -1
- package/dist/components/MlCreatePdfButton/MlCreatePdfButton.stories.d.ts +12 -9
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.cy.d.ts +1 -0
- package/dist/components/MlCreatePdfForm/lib/PdfPreview.d.ts +1 -1
- package/dist/components/MlFeatureEditor/MlFeatureEditor.d.ts +10 -4
- package/dist/components/MlFeatureEditor/lib/double_click_zoom.d.ts +0 -2
- package/dist/components/MlFeatureEditor/lib/theme.d.ts +1 -1
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +23 -12
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +12 -11
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.d.ts +2 -0
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.d.ts +2 -0
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.d.ts +3 -0
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.d.ts +3 -0
- package/dist/components/MlGpxViewer/MlGpxViewer.d.ts +30 -0
- package/dist/components/MlGpxViewer/MlGpxViewer.stories.d.ts +17 -0
- package/dist/components/MlGpxViewer/MlGpxViewer.test.d.ts +1 -0
- package/dist/components/MlGpxViewer/util/GeoJsonContext.d.ts +10 -0
- package/dist/components/MlGpxViewer/util/GeoJsonProvider.d.ts +4 -0
- package/dist/components/MlGpxViewer/util/MetadataDrawer.d.ts +7 -0
- package/dist/components/MlGpxViewer/util/MlGpxDemoLoader.d.ts +10 -0
- package/dist/components/MlGpxViewer/util/MlGpxViewerInstructions.d.ts +3 -0
- package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.d.ts +11 -2
- package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.d.ts +7 -9
- package/dist/components/MlLayerMagnify/MlLayerMagnify.d.ts +8 -2
- package/dist/components/MlLayerMagnify/MlLayerMagnify.stories.d.ts +13 -9
- package/dist/components/MlLayerSwipe/MlLayerSwipe.d.ts +13 -3
- package/dist/components/MlLayerSwipe/MlLayerSwipe.stories.d.ts +12 -10
- package/dist/components/MlSketchTool/LayerList/ColorPicker.d.ts +9 -0
- package/dist/components/MlSketchTool/LayerList/LayerList.d.ts +5 -0
- package/dist/components/MlSketchTool/LayerList/LayerListItem.d.ts +11 -0
- package/dist/components/MlSketchTool/LayerList/LayerPropertyForm.d.ts +9 -0
- package/dist/components/MlSketchTool/MlSketchTool.d.ts +29 -0
- package/dist/components/MlSketchTool/MlSketchTool.stories.d.ts +10 -0
- package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.d.ts +33 -14
- package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.d.ts +18 -15
- package/dist/components/MlSpatialElevationProfile/util/getElevationData.d.ts +14 -0
- package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +3 -67
- package/dist/components/MlWmsLayer/MlWmsLayer.d.ts +7 -4
- package/dist/components/MlWmsLoader/MlWmsLoader.d.ts +17 -10
- package/dist/components/MlWmsLoader/MlWmsLoader.stories.d.ts +23 -12
- package/dist/components/MlWmsLoader/utils/MlWmsLoaderInstructions.d.ts +3 -0
- package/dist/components/MlWmsLoader/utils/WMSLinks.d.ts +6 -0
- package/dist/contexts/SimpleDataProvider.d.ts +1 -1
- package/dist/custom.d.d.ts +1 -1
- package/dist/decorators/ThemeWrapper.d.ts +3 -1
- package/dist/hooks/useGpx/lib/gpxConverter.d.ts +11 -0
- package/dist/hooks/useGpx/useGpx.d.ts +26 -0
- package/dist/hooks/useGpx/useGpx.stories.d.ts +10 -0
- package/dist/hooks/useLayer.d.ts +14 -8
- package/dist/hooks/useLayerHoverPopup/useLayerHoverPopup.d.ts +23 -0
- package/dist/hooks/useLayerHoverPopup/useLayerHoverPopup.stories.d.ts +10 -0
- package/dist/hooks/useMap.d.ts +2 -2
- package/dist/hooks/useMap.test.d.ts +1 -0
- package/dist/hooks/useMapState.d.ts +3 -3
- package/dist/hooks/useSource.d.ts +3 -3
- package/dist/hooks/useWms.d.ts +24 -16
- package/dist/index.d.ts +5 -5
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +9327 -14844
- package/dist/index.esm.js.map +1 -1
- package/dist/setupTests.d.ts +6 -5
- package/dist/ui_components/Dropzone.d.ts +5 -0
- package/dist/ui_components/ImageLoader.d.ts +8 -1
- package/dist/ui_components/LoadingOverlayContext.d.ts +11 -11
- package/dist/ui_components/Sidebar.d.ts +10 -1
- package/dist/ui_components/Tooltip.d.ts +1 -1
- package/dist/ui_components/TopToolbar.d.ts +7 -1
- package/dist/ui_components/UploadButton.d.ts +6 -0
- package/dist/util/BubbleForInstructions.d.ts +2 -0
- package/dist/util/Instructions.d.ts +13 -0
- package/package.json +195 -185
- package/public/assets/sample1.gpx +3003 -0
- package/public/assets/sample2.gpx +1264 -0
- package/public/assets/sample3.gpx +912 -0
- package/{src/components/MlImageMarkerLayer → public}/assets/wg-marker.png +0 -0
- package/public/index.html +0 -4
- package/public/thumbnails/MlSketchTool.png +0 -0
- package/public/thumbnails/useCameraFollowPath.png +0 -0
- package/scripts/build-catalogue-meta.js +35 -11
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +230 -188
- package/src/components/MlCenterPosition/MlCenterPosition.meta_.json +1 -2
- package/src/components/MlCenterPosition/MlCenterPosition.stories.tsx +20 -0
- package/src/components/MlCenterPosition/MlCenterPosition.tsx +4 -4
- package/src/components/MlComponentTemplate/MlComponentTemplate.meta_.json +1 -2
- package/src/components/MlComponentTemplate/{MlComponentTemplate.stories.js → MlComponentTemplate.stories.tsx} +2 -2
- package/src/components/MlComponentTemplate/MlComponentTemplate.tsx +1 -1
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta_.json +1 -2
- package/src/components/MlCreatePdfButton/{MlCreatePdfButton.stories.js → MlCreatePdfButton.stories.tsx} +1 -1
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx +1 -1
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx +21 -0
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.meta.json +1 -2
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.stories.tsx +1 -3
- package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +25 -2
- package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -3
- package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +39 -29
- package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.meta.json +1 -2
- package/src/components/MlFollowGps/MlFollowGps.meta.json +1 -2
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -2
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.tsx +191 -0
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +47 -30
- package/src/components/MlGeoJsonLayer/assets/earthquake.json +109937 -0
- package/src/components/MlGeoJsonLayer/assets/sample_1.json +138 -24
- package/src/components/MlGeoJsonLayer/assets/sample_2.json +140 -20
- package/src/components/MlGeoJsonLayer/assets/wg_locations.json +65 -0
- package/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js +189 -0
- package/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js +188 -0
- package/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.tsx +9 -0
- package/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.tsx +10 -0
- package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.meta_.json +1 -2
- package/src/components/{MlGPXViewer/MlGPXViewer.doc.de.md → MlGpxViewer/MlGpxViewer.doc.de.md} +0 -0
- package/src/components/{MlGPXViewer/MlGPXViewer.doc.en.md → MlGpxViewer/MlGpxViewer.doc.en.md} +0 -0
- package/src/components/{MlGPXViewer/MlGPXViewer.meta.json → MlGpxViewer/MlGpxViewer.meta.json} +2 -3
- package/src/components/MlGpxViewer/MlGpxViewer.stories.tsx +109 -0
- package/src/components/MlGpxViewer/MlGpxViewer.test.js +53 -0
- package/src/components/MlGpxViewer/MlGpxViewer.tsx +103 -0
- package/src/components/{MlGPXViewer → MlGpxViewer}/util/GeoJsonContext.ts +0 -0
- package/src/components/{MlGPXViewer → MlGpxViewer}/util/GeoJsonProvider.tsx +0 -0
- package/src/components/MlGpxViewer/util/MetadataDrawer.tsx +38 -0
- package/src/components/MlGpxViewer/util/MlGpxDemoLoader.tsx +128 -0
- package/src/components/MlGpxViewer/util/MlGpxViewerInstructions.tsx +68 -0
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.meta_.json +1 -2
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.tsx +41 -0
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +27 -8
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx +41 -115
- package/src/components/MlLayer/MlLayer.meta_.json +1 -2
- package/src/components/MlLayerMagnify/MlLayerMagnify.meta.json +1 -2
- package/src/components/MlLayerMagnify/MlLayerMagnify.stories.tsx +44 -0
- package/src/components/MlLayerMagnify/{MlLayerMagnify.test.js → MlLayerMagnify.test.tsx} +15 -18
- package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +55 -61
- package/src/components/MlLayerSwipe/MlLayerSwipe.meta.json +1 -2
- package/src/components/MlLayerSwipe/{MlLayerSwipe.stories.js → MlLayerSwipe.stories.tsx} +9 -11
- package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +47 -48
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.meta_.json +1 -2
- package/src/components/MlLayerSwitcher/components/LayerBox.js +22 -19
- package/src/components/MlMarker/MlMarker.meta_.json +1 -2
- package/src/components/MlMeasureTool/MlMeasureTool.meta.json +1 -2
- package/src/components/MlNavigationCompass/MlNavigationCompass.meta.json +1 -2
- package/src/components/MlNavigationTools/MlNavigationTools.meta.json +1 -2
- package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -2
- package/src/components/MlShareMapState/MlShareMapState.meta_.json +1 -2
- package/src/components/MlSketchTool/LayerList/ColorPicker.tsx +43 -0
- package/src/components/MlSketchTool/LayerList/LayerList.tsx +12 -0
- package/src/components/MlSketchTool/LayerList/LayerListItem.tsx +109 -0
- package/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx +126 -0
- package/src/components/MlSketchTool/MlSketchTool.doc.de.md +3 -0
- package/src/components/MlSketchTool/MlSketchTool.meta.json +14 -0
- package/src/components/MlSketchTool/MlSketchTool.stories.js +26 -0
- package/src/components/MlSketchTool/MlSketchTool.tsx +271 -0
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.meta.json +1 -2
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.tsx +121 -0
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.test.js +30 -1
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.tsx +143 -0
- package/src/components/MlSpatialElevationProfile/util/getElevationData.tsx +103 -0
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.meta.json +1 -2
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.meta.json +3 -4
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.stories.js +2 -3
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx +17 -79
- package/src/components/MlUseMapDebugger/MlUseMapDebugger.meta_.json +1 -2
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.meta.json +1 -2
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx +3 -2
- package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.meta_.json +1 -2
- package/src/components/MlWmsLayer/MlWmsLayer.tsx +59 -41
- package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -2
- package/src/components/MlWmsLoader/MlWmsLoader.stories.tsx +89 -0
- package/src/components/MlWmsLoader/MlWmsLoader.tsx +141 -122
- package/src/components/MlWmsLoader/utils/MlWmsLoaderInstructions.tsx +50 -0
- package/src/components/MlWmsLoader/utils/WMSLinks.tsx +128 -0
- package/src/decorators/MapContextDecorator.js +1 -1
- package/src/decorators/MapContextDecoratorHooks.js +1 -1
- package/src/decorators/ThemeWrapper.tsx +9 -0
- package/src/hooks/useCameraFollowPath/useCameraFollowPath.meta.json +1 -2
- package/src/{components/MlGPXViewer → hooks/useGpx/lib}/gpxConverter.js +1 -0
- package/src/hooks/useGpx/useGpx.doc.de.md +3 -0
- package/src/hooks/useGpx/useGpx.meta_.json +15 -0
- package/src/{components/MlCenterPosition/MlCenterPosition.stories.js → hooks/useGpx/useGpx.stories.js} +4 -5
- package/src/hooks/useGpx/useGpx.tsx +70 -0
- package/src/hooks/useLayer.ts +32 -10
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.doc.de.md +3 -0
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.meta_.json +15 -0
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.stories.js +20 -0
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx +82 -0
- package/src/hooks/useMap.test.tsx +48 -0
- package/src/hooks/useMap.ts +8 -8
- package/src/hooks/useSource.ts +4 -4
- package/src/hooks/{useWms.js → useWms.ts} +24 -11
- package/src/index.ts +5 -5
- package/src/setupTests.js +18 -15
- package/src/ui_components/Dropzone.tsx +104 -0
- package/src/ui_components/{ImageLoader.js → ImageLoader.tsx} +30 -25
- package/src/ui_components/{LoadingOverlayContext.js → LoadingOverlayContext.tsx} +12 -15
- package/src/ui_components/Sidebar.tsx +82 -0
- package/src/ui_components/Tooltip.tsx +17 -0
- package/src/ui_components/TopToolbar.tsx +26 -0
- package/src/ui_components/UploadButton.tsx +57 -0
- package/src/util/BubbleForInstructions.js +46 -0
- package/src/util/Instructions.tsx +60 -0
- package/tsconfig.json +39 -58
- package/config/getHttpsConfig.js +0 -66
- package/config/modules.js +0 -134
- package/config/pnpTs.js +0 -35
- package/config/webpack.config.js +0 -757
- package/config/webpackDevServer.config.js +0 -130
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +0 -1645
- package/scripts/start.js +0 -166
- package/src/components/MlGPXViewer/MlGPXViewer.stories.js +0 -31
- package/src/components/MlGPXViewer/MlGPXViewer.test.js +0 -28
- package/src/components/MlGPXViewer/MlGPXViewer.tsx +0 -377
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +0 -66
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.js +0 -45
- package/src/components/MlLayerMagnify/MlLayerMagnify.stories.js +0 -41
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js +0 -224
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +0 -57
- package/src/components/MlWmsLoader/MlWmsLoader.stories.js +0 -47
- package/src/decorators/ThemeWrapper.jsx +0 -9
- package/src/ui_components/Legend.js +0 -44
- package/src/ui_components/LoadingOverlay.js +0 -41
- package/src/ui_components/Sidebar.js +0 -100
- package/src/ui_components/Tooltip.js +0 -21
- package/src/ui_components/TopToolbar.js +0 -29
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import MlCenterPosition from './MlCenterPosition';
|
|
4
|
+
|
|
5
|
+
import mapContextDecorator from '../../decorators/MapContextDecorator';
|
|
6
|
+
|
|
7
|
+
const storyoptions = {
|
|
8
|
+
title: 'MapComponents/MlCenterPosition',
|
|
9
|
+
component: MlCenterPosition,
|
|
10
|
+
argTypes: {},
|
|
11
|
+
decorators: mapContextDecorator,
|
|
12
|
+
parameters: { docs: { source: { type: 'code' } } },
|
|
13
|
+
};
|
|
14
|
+
export default storyoptions;
|
|
15
|
+
|
|
16
|
+
const Template = () => <MlCenterPosition />;
|
|
17
|
+
|
|
18
|
+
export const ExampleConfig = Template.bind({});
|
|
19
|
+
ExampleConfig.parameters = {};
|
|
20
|
+
ExampleConfig.args = {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useState, useCallback } from "react";
|
|
2
2
|
import useMap from "../../hooks/useMap";
|
|
3
|
-
import { Button } from "@mui/material";
|
|
3
|
+
import { Button, SxProps, Theme } from "@mui/material";
|
|
4
4
|
import GpsFixedIcon from "@mui/icons-material/GpsFixed";
|
|
5
5
|
|
|
6
|
-
interface MlCenterPositionProps {
|
|
6
|
+
export interface MlCenterPositionProps {
|
|
7
7
|
/**
|
|
8
8
|
* Id of the target MapLibre instance in mapContext
|
|
9
9
|
*/
|
|
@@ -24,7 +24,7 @@ interface MlCenterPositionProps {
|
|
|
24
24
|
/**
|
|
25
25
|
* CSS style object that is applied to the button component
|
|
26
26
|
*/
|
|
27
|
-
style?:
|
|
27
|
+
style?: SxProps<Theme> | undefined;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|
|
@@ -58,7 +58,7 @@ const MlCenterPosition = (props: MlCenterPositionProps) => {
|
|
|
58
58
|
...props.style,
|
|
59
59
|
}}
|
|
60
60
|
onClick={centerCurrentLocation} disabled={locationAccessDenied}>
|
|
61
|
-
<GpsFixedIcon sx={{ ...(props.style?.fontSize?{fontSize: props.style?.fontSize}:{}) }} />{" "}
|
|
61
|
+
<GpsFixedIcon sx={{ ...(props.style?.['fontSize']?{fontSize: props.style?.['fontSize']}:{}) }} />{" "}
|
|
62
62
|
</Button>
|
|
63
63
|
</>;
|
|
64
64
|
|
|
@@ -13,8 +13,8 @@ const storyoptions = {
|
|
|
13
13
|
};
|
|
14
14
|
export default storyoptions;
|
|
15
15
|
|
|
16
|
-
const Template = (
|
|
16
|
+
const Template = () => <MlComponentTemplate />;
|
|
17
17
|
|
|
18
18
|
export const ExampleConfig = Template.bind({});
|
|
19
19
|
ExampleConfig.parameters = {};
|
|
20
|
-
ExampleConfig.args = {};
|
|
20
|
+
ExampleConfig.args = {};
|
|
@@ -6,7 +6,7 @@ import createPdf from "./lib/createPdf";
|
|
|
6
6
|
import PrinterIcon from "@mui/icons-material/Print";
|
|
7
7
|
import Button from "@mui/material/Button";
|
|
8
8
|
|
|
9
|
-
interface MlCreatePdfButtonProps {
|
|
9
|
+
export interface MlCreatePdfButtonProps {
|
|
10
10
|
/**
|
|
11
11
|
* Id of the target MapLibre instance in mapContext
|
|
12
12
|
*/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { composeStories } from '@storybook/testing-react';
|
|
3
|
+
import { mount } from '@cypress/react';
|
|
4
|
+
import * as stories from "./MlCreatePdfForm.stories";
|
|
5
|
+
|
|
6
|
+
// compile the "Primary" story with the library
|
|
7
|
+
const {ExampleConfig } = composeStories(stories);
|
|
8
|
+
|
|
9
|
+
describe('MlCreatePdfForm Tests', () => {
|
|
10
|
+
it('Should generate and download a PDF export of the current map preview', () => {
|
|
11
|
+
// and mount the story using @cypress/react library
|
|
12
|
+
mount(<ExampleConfig />);
|
|
13
|
+
|
|
14
|
+
cy.get(".pdfFormButton").click();
|
|
15
|
+
|
|
16
|
+
cy.wait(1000)
|
|
17
|
+
cy.get(".createPdfButton").click();
|
|
18
|
+
cy.wait(2000)
|
|
19
|
+
cy.readFile("./cypress/downloads/Map.pdf").should('contain', 'WhereGroup')
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -51,14 +51,12 @@ export default storyoptions;
|
|
|
51
51
|
|
|
52
52
|
const Template = () => {
|
|
53
53
|
const [showCreatePdfForm, setShowCreatePdfForm] = useState(false);
|
|
54
|
-
const targetRef = React.useRef<HTMLDivElement>(null);
|
|
55
|
-
const containerRef = React.useRef<HTMLDivElement>(document.querySelector('.map_container'));
|
|
56
54
|
|
|
57
55
|
// <MlWmsLayer url='https://geo.stat.fi/geoserver/vaestoruutu/wms' urlParameters={{layers:'vaki2005_1km_kp'}}/>
|
|
58
56
|
return (
|
|
59
57
|
<>
|
|
60
58
|
<TopToolbar>
|
|
61
|
-
<Button variant="contained" onClick={() => setShowCreatePdfForm(!showCreatePdfForm)}>
|
|
59
|
+
<Button variant="contained" className='pdfFormButton' onClick={() => setShowCreatePdfForm(!showCreatePdfForm)}>
|
|
62
60
|
PDF
|
|
63
61
|
</Button>
|
|
64
62
|
</TopToolbar>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext, useMemo, useCallback } from 'react';
|
|
1
|
+
import React, { useContext, useMemo, useCallback, useState } from 'react';
|
|
2
2
|
import PdfContext from './PdfContext';
|
|
3
3
|
import PdfPreview from './PdfPreview';
|
|
4
4
|
import {
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
FormControlLabel,
|
|
12
12
|
Radio,
|
|
13
13
|
RadioGroup,
|
|
14
|
+
CircularProgress,
|
|
14
15
|
} from '@mui/material';
|
|
15
16
|
|
|
16
17
|
import useMap from '../../../hooks/useMap';
|
|
@@ -84,6 +85,7 @@ interface PdfFormProps {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
export default function PdfForm(props: PdfFormProps) {
|
|
88
|
+
const [loading, setLoading] = useState(false);
|
|
87
89
|
const pdfContext = useContext(PdfContext);
|
|
88
90
|
const mapHook = useMap({
|
|
89
91
|
// eslint-disable-next-line react/prop-types
|
|
@@ -101,6 +103,7 @@ export default function PdfForm(props: PdfFormProps) {
|
|
|
101
103
|
pdfContext.geojsonRef?.current?.bbox &&
|
|
102
104
|
pdfContext.geojsonRef?.current
|
|
103
105
|
) {
|
|
106
|
+
setLoading(true);
|
|
104
107
|
const bbox = turf.bbox(pdfContext.geojsonRef.current);
|
|
105
108
|
|
|
106
109
|
mapExporter
|
|
@@ -118,10 +121,12 @@ export default function PdfForm(props: PdfFormProps) {
|
|
|
118
121
|
if (typeof props.onCreatePdf === 'function') {
|
|
119
122
|
props.onCreatePdf(res);
|
|
120
123
|
}
|
|
124
|
+
setLoading(false);
|
|
121
125
|
return res.downloadPdf();
|
|
122
126
|
})
|
|
123
127
|
.catch((error) => {
|
|
124
128
|
console.log(error);
|
|
129
|
+
setLoading(false);
|
|
125
130
|
});
|
|
126
131
|
}
|
|
127
132
|
}, [mapHook.map, pdfContext]);
|
|
@@ -218,9 +223,27 @@ export default function PdfForm(props: PdfFormProps) {
|
|
|
218
223
|
</Select>
|
|
219
224
|
</FormControl>
|
|
220
225
|
<FormControl fullWidth sx={formControlStyles}>
|
|
221
|
-
<Button
|
|
226
|
+
<Button
|
|
227
|
+
variant="contained"
|
|
228
|
+
className="createPdfButton"
|
|
229
|
+
onClick={createPdfHandler}
|
|
230
|
+
disabled={loading}
|
|
231
|
+
>
|
|
222
232
|
PDF erstellen
|
|
223
233
|
</Button>
|
|
234
|
+
{loading && (
|
|
235
|
+
<CircularProgress
|
|
236
|
+
size={24}
|
|
237
|
+
sx={{
|
|
238
|
+
color: 'primary.main',
|
|
239
|
+
position: 'absolute',
|
|
240
|
+
top: '50%',
|
|
241
|
+
left: '50%',
|
|
242
|
+
marginTop: '-12px',
|
|
243
|
+
marginLeft: '-12px',
|
|
244
|
+
}}
|
|
245
|
+
/>
|
|
246
|
+
)}
|
|
224
247
|
</FormControl>
|
|
225
248
|
{pdfContext.options && pdfContext.setOptions && (
|
|
226
249
|
<PdfPreview
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "MlFeatureEditor",
|
|
3
|
-
"title": "
|
|
3
|
+
"title": "Feature editor",
|
|
4
4
|
"description": "Enables the editing of Point, Linestring and Polygon GeoJSON Files.",
|
|
5
5
|
"i18n": {
|
|
6
6
|
"de": {
|
|
@@ -10,6 +10,5 @@
|
|
|
10
10
|
},
|
|
11
11
|
"tags": ["Map add-on"],
|
|
12
12
|
"category": "add-ons",
|
|
13
|
-
"type": "component"
|
|
14
|
-
"price": 0
|
|
13
|
+
"type": "component"
|
|
15
14
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from
|
|
2
|
-
import
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import './MlFeatureEditor.css';
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import MapboxDraw from
|
|
6
|
-
import CustomPolygonMode from
|
|
7
|
-
import CustomSelectMode from
|
|
8
|
-
import CustomDirectSelectMode from
|
|
4
|
+
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
|
|
5
|
+
import MapboxDraw from '@mapbox/mapbox-gl-draw';
|
|
6
|
+
import CustomPolygonMode from './custom-polygon-mode.js';
|
|
7
|
+
import CustomSelectMode from './custom-select-mode.js';
|
|
8
|
+
import CustomDirectSelectMode from './custom-direct-select-mode.js';
|
|
9
9
|
|
|
10
|
-
import useMap from
|
|
10
|
+
import useMap from '../../hooks/useMap';
|
|
11
|
+
import { GeoJSONObject, Feature } from '@turf/turf';
|
|
11
12
|
|
|
12
13
|
interface MlFeatureEditorProps {
|
|
13
14
|
/**
|
|
@@ -22,12 +23,17 @@ interface MlFeatureEditorProps {
|
|
|
22
23
|
/**
|
|
23
24
|
* Input GeoJson data at initialization
|
|
24
25
|
*/
|
|
25
|
-
geojson?:
|
|
26
|
+
geojson?: Feature;
|
|
26
27
|
/**
|
|
27
28
|
* Callback function that is called each time the GeoJson data within has changed within MlFeatureEditor.
|
|
28
29
|
* First parameter is the new GeoJson feature.
|
|
29
30
|
*/
|
|
30
|
-
onChange?:
|
|
31
|
+
onChange?: (para: GeoJSONObject[]) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Callback function that is called each time the GeoJson data within has been finished within MlFeatureEditor.
|
|
34
|
+
* First parameter is the new GeoJson feature.
|
|
35
|
+
*/
|
|
36
|
+
onFinish?: () => void;
|
|
31
37
|
/**
|
|
32
38
|
* Feature editor mode:
|
|
33
39
|
* - "custom_select" edit features
|
|
@@ -51,10 +57,15 @@ const MlFeatureEditor = (props: MlFeatureEditorProps) => {
|
|
|
51
57
|
const drawToolsInitialized = useRef(false);
|
|
52
58
|
const [drawToolsReady, setDrawToolsReady] = useState(false);
|
|
53
59
|
|
|
54
|
-
|
|
55
60
|
const modeChangeHandler = (e: any) => {
|
|
56
|
-
console.log(
|
|
61
|
+
console.log('MlFeatureEditor mode change to ' + e.mode);
|
|
57
62
|
//setDrawMode(e.mode);
|
|
63
|
+
if (
|
|
64
|
+
typeof props.onFinish === 'function' &&
|
|
65
|
+
(e.mode === 'custom_select' || e.mode === 'simple_select')
|
|
66
|
+
) {
|
|
67
|
+
props.onFinish();
|
|
68
|
+
}
|
|
58
69
|
};
|
|
59
70
|
|
|
60
71
|
useEffect(() => {
|
|
@@ -63,17 +74,19 @@ const MlFeatureEditor = (props: MlFeatureEditorProps) => {
|
|
|
63
74
|
|
|
64
75
|
if (
|
|
65
76
|
mapHook.map.map.style &&
|
|
66
|
-
mapHook.map.map.getSource(
|
|
77
|
+
mapHook.map.map.getSource('mapbox-gl-draw-cold') &&
|
|
67
78
|
draw.current
|
|
68
79
|
) {
|
|
69
80
|
// remove old Mapbox-gl-Draw from Mapbox instance when hot-reloading this component during development
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
70
82
|
// @ts-ignore
|
|
71
83
|
draw.current?.remove();
|
|
72
84
|
}
|
|
73
85
|
|
|
74
86
|
draw.current = new MapboxDraw({
|
|
75
87
|
displayControlsDefault: false,
|
|
76
|
-
defaultMode: props.mode ||
|
|
88
|
+
defaultMode: props.mode || 'custom_select',
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
77
90
|
// @ts-ignore
|
|
78
91
|
modes: Object.assign(
|
|
79
92
|
{
|
|
@@ -85,10 +98,8 @@ const MlFeatureEditor = (props: MlFeatureEditorProps) => {
|
|
|
85
98
|
),
|
|
86
99
|
});
|
|
87
100
|
|
|
88
|
-
mapHook.map.addControl(draw.current,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
mapHook.map.on("draw.modechange", modeChangeHandler, mapHook.componentId);
|
|
101
|
+
mapHook.map.addControl(draw.current, 'top-left', mapHook.componentId);
|
|
102
|
+
mapHook.map.on('draw.modechange', modeChangeHandler, mapHook.componentId);
|
|
92
103
|
|
|
93
104
|
setDrawToolsReady(true);
|
|
94
105
|
}
|
|
@@ -100,35 +111,34 @@ const MlFeatureEditor = (props: MlFeatureEditorProps) => {
|
|
|
100
111
|
const changeHandler = () => {
|
|
101
112
|
if (draw.current) {
|
|
102
113
|
// update drawnFeatures state object
|
|
103
|
-
if (typeof props.onChange ===
|
|
104
|
-
|
|
114
|
+
if (typeof props.onChange === 'function') {
|
|
115
|
+
const currentFeatureCollection = draw.current.getAll?.();
|
|
105
116
|
props.onChange(currentFeatureCollection?.features);
|
|
106
117
|
}
|
|
107
118
|
}
|
|
108
119
|
};
|
|
109
120
|
|
|
110
|
-
mapHook.map.on(
|
|
121
|
+
mapHook.map.on('mouseup', changeHandler);
|
|
111
122
|
|
|
112
|
-
mapHook.map.on(
|
|
123
|
+
mapHook.map.on('touchend', changeHandler);
|
|
113
124
|
|
|
114
125
|
return () => {
|
|
115
126
|
if (!mapHook.map) return;
|
|
116
127
|
|
|
117
|
-
mapHook.map.map.off(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}, [drawToolsReady, mapHook.map])
|
|
128
|
+
mapHook.map.map.off('mouseup', changeHandler);
|
|
129
|
+
mapHook.map.map.off('touchend', changeHandler);
|
|
130
|
+
};
|
|
131
|
+
}, [drawToolsReady, mapHook.map]);
|
|
123
132
|
|
|
124
133
|
useEffect(() => {
|
|
125
134
|
if (draw.current && props.geojson?.geometry) {
|
|
126
|
-
draw.current.set({ type:
|
|
135
|
+
draw.current.set({ type: 'FeatureCollection', features: [props.geojson as any] });
|
|
127
136
|
}
|
|
128
137
|
}, [props.geojson, drawToolsReady]);
|
|
129
138
|
|
|
130
139
|
useEffect(() => {
|
|
131
140
|
if (props.mode && draw.current) {
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
132
142
|
// @ts-ignore
|
|
133
143
|
draw.current.changeMode(props.mode);
|
|
134
144
|
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
|
+
import MlGeoJsonLayer from './MlGeoJsonLayer';
|
|
3
|
+
import useMap from '../../hooks/useMap';
|
|
4
|
+
import mapContextDecorator from '../../decorators/MapContextDecorator';
|
|
5
|
+
import PolygonStyler from './story_utils/MlGeoJsonLayer.polygonStyler';
|
|
6
|
+
import LineStyler from './story_utils/MlGeoJsonLayer.lineStyler';
|
|
7
|
+
import HeatMapStyler from './story_utils/MlGeojsonLayerHeatMapStyler';
|
|
8
|
+
import sample_geojson_1 from './assets/sample_1.json';
|
|
9
|
+
import sample_geojson_2 from './assets/sample_2.json';
|
|
10
|
+
import earthquakes from './assets/earthquake.json';
|
|
11
|
+
import wg_locations from './assets/wg_locations.json';
|
|
12
|
+
import { GeoJSONObject } from '@turf/turf';
|
|
13
|
+
import { MlGeoJsonLayerProps } from './MlGeoJsonLayer';
|
|
14
|
+
import CircleMapStyler from './story_utils/MlGeojsonLayerCircleStyler';
|
|
15
|
+
|
|
16
|
+
const storyoptions = {
|
|
17
|
+
title: 'MapComponents/MlGeoJsonLayer',
|
|
18
|
+
component: MlGeoJsonLayer,
|
|
19
|
+
|
|
20
|
+
argTypes: {},
|
|
21
|
+
|
|
22
|
+
decorators: mapContextDecorator,
|
|
23
|
+
};
|
|
24
|
+
export default storyoptions;
|
|
25
|
+
|
|
26
|
+
interface TemplateProps {
|
|
27
|
+
geojson: GeoJSONObject;
|
|
28
|
+
mapId: string;
|
|
29
|
+
type: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const Template = (props: TemplateProps) => {
|
|
33
|
+
const mapHook = useMap({
|
|
34
|
+
mapId: undefined,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const initializedRef = useRef(false);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!mapHook.map || initializedRef.current) return;
|
|
41
|
+
|
|
42
|
+
initializedRef.current = true;
|
|
43
|
+
mapHook.map.map.flyTo({ center: [7.100175528281227, 50.73487992742369], zoom: 15 });
|
|
44
|
+
}, [mapHook.map]);
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<LineStyler {...props} />
|
|
49
|
+
</>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
const PolygonTemplate = (props: TemplateProps) => {
|
|
53
|
+
const mapHook = useMap({
|
|
54
|
+
mapId: undefined,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const initializedRef = useRef(false);
|
|
58
|
+
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!mapHook.map || initializedRef.current) return;
|
|
61
|
+
|
|
62
|
+
initializedRef.current = true;
|
|
63
|
+
mapHook.map.map.flyTo({ center: [7.100175528281227, 50.73487992742369], zoom: 15 });
|
|
64
|
+
}, [mapHook.map]);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<>
|
|
68
|
+
<PolygonStyler {...props} />
|
|
69
|
+
</>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const HeatmapTemplate = (props: MlGeoJsonLayerProps) => {
|
|
74
|
+
const mapHook = useMap({
|
|
75
|
+
mapId: undefined,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const initializedRef = useRef(false);
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (!mapHook.map || initializedRef.current) return;
|
|
82
|
+
|
|
83
|
+
initializedRef.current = true;
|
|
84
|
+
mapHook.map.map.flyTo({ center: [-150.4048, 63.1224], zoom: 3 });
|
|
85
|
+
}, [mapHook.map]);
|
|
86
|
+
|
|
87
|
+
return <HeatMapStyler {...props} />;
|
|
88
|
+
};
|
|
89
|
+
const CircleTemplate = (props: MlGeoJsonLayerProps) => {
|
|
90
|
+
const mapHook = useMap({
|
|
91
|
+
mapId: undefined,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const initializedRef = useRef(false);
|
|
95
|
+
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (!mapHook.map || initializedRef.current) return;
|
|
98
|
+
|
|
99
|
+
initializedRef.current = true;
|
|
100
|
+
mapHook.map.map.flyTo({ center: [10.251805123900311, 51.11826171422632], zoom: 5 });
|
|
101
|
+
}, [mapHook.map]);
|
|
102
|
+
|
|
103
|
+
return <CircleMapStyler {...props} />;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const Linestring = Template.bind({});
|
|
107
|
+
Linestring.parameters = {};
|
|
108
|
+
Linestring.args = {
|
|
109
|
+
geojson: sample_geojson_2,
|
|
110
|
+
mapId: 'Map_1',
|
|
111
|
+
/*paint:{
|
|
112
|
+
"stroke-color": 'rgba(123,20,80)',
|
|
113
|
+
"fill-opacity": 0
|
|
114
|
+
},*/
|
|
115
|
+
type: 'line',
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const Polygon = PolygonTemplate.bind({});
|
|
119
|
+
|
|
120
|
+
Polygon.args = {
|
|
121
|
+
geojson: sample_geojson_1,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const DefaultPaintOverrides = Template.bind({});
|
|
125
|
+
DefaultPaintOverrides.parameters = {};
|
|
126
|
+
DefaultPaintOverrides.args = {
|
|
127
|
+
defaultPaintOverrides: {
|
|
128
|
+
fill: {
|
|
129
|
+
'fill-color': 'blue',
|
|
130
|
+
},
|
|
131
|
+
circle: {
|
|
132
|
+
'circle-color': 'red',
|
|
133
|
+
},
|
|
134
|
+
line: {
|
|
135
|
+
'line-color': 'black',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
geojson: sample_geojson_1,
|
|
139
|
+
type: '',
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const HeatMapEarthquakes = HeatmapTemplate.bind({});
|
|
143
|
+
HeatMapEarthquakes.parameters = {};
|
|
144
|
+
HeatMapEarthquakes.args = {
|
|
145
|
+
geojson: earthquakes,
|
|
146
|
+
options: {
|
|
147
|
+
// paint examples copied from https://maplibre.org/maplibre-gl-js-docs/example/heatmap-layer/
|
|
148
|
+
paint: {
|
|
149
|
+
// Increase the heatmap weight based on frequency and property magnitude
|
|
150
|
+
'heatmap-weight': ['interpolate', ['linear'], ['get', 'mag'], 0, 0, 6, 1],
|
|
151
|
+
// Increase the heatmap color weight by zoom level
|
|
152
|
+
// heatmap-intensity is a multiplier on top of heatmap-weight
|
|
153
|
+
'heatmap-intensity': ['interpolate', ['linear'], ['zoom'], 0, 1, 9, 3],
|
|
154
|
+
// Color ramp for heatmap. Domain is 0 (low) to 1 (high).
|
|
155
|
+
// Begin color ramp at 0-stop with a 0-transparancy color
|
|
156
|
+
// to create a blur-like effect.
|
|
157
|
+
'heatmap-color': [
|
|
158
|
+
'interpolate',
|
|
159
|
+
['linear'],
|
|
160
|
+
['heatmap-density'],
|
|
161
|
+
0,
|
|
162
|
+
'rgba(33,102,172,0)',
|
|
163
|
+
0.2,
|
|
164
|
+
'rgb(103,169,207)',
|
|
165
|
+
0.4,
|
|
166
|
+
'rgb(209,229,240)',
|
|
167
|
+
0.6,
|
|
168
|
+
'rgb(253,219,199)',
|
|
169
|
+
0.8,
|
|
170
|
+
'rgb(239,138,98)',
|
|
171
|
+
1,
|
|
172
|
+
'rgb(178,24,43)',
|
|
173
|
+
],
|
|
174
|
+
// Adjust the heatmap radius by zoom level
|
|
175
|
+
'heatmap-radius': ['interpolate', ['linear'], ['zoom'], 0, 2, 9, 20],
|
|
176
|
+
// Transition from heatmap to circle layer by zoom level
|
|
177
|
+
'heatmap-opacity': ['interpolate', ['linear'], ['zoom'], 7, 1, 9, 0],
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
type: 'heatmap',
|
|
181
|
+
};
|
|
182
|
+
export const CircleMapWheregroupLocations = CircleTemplate.bind({});
|
|
183
|
+
CircleMapWheregroupLocations.parameters = {};
|
|
184
|
+
CircleMapWheregroupLocations.args = {
|
|
185
|
+
geojson: wg_locations,
|
|
186
|
+
paint: {
|
|
187
|
+
'circle-radius': ['/', ['get', 'Mitarbeitende'], 1.2],
|
|
188
|
+
'circle-color': '#B11E40',
|
|
189
|
+
},
|
|
190
|
+
type: 'circle',
|
|
191
|
+
};
|