@mapcomponents/react-maplibre 0.1.66 → 0.1.68
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/.github/workflows/node_version_test.yml +1 -1
- package/.storybook/main.js +37 -31
- package/.storybook/preview.js +21 -0
- package/CHANGELOG.md +13 -0
- package/coverage/clover.xml +545 -472
- package/coverage/coverage-final.json +18 -17
- package/coverage/lcov-report/index.html +80 -80
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +50 -26
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +5 -5
- package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +30 -51
- package/coverage/lcov-report/src/components/MlCenterPosition/index.html +3 -3
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +1 -1
- 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 +1 -1
- 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 +48 -105
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +15 -15
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +2 -2
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlGpxViewer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
- 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 +52 -40
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +10 -10
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +4 -4
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
- 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 +41 -113
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +15 -15
- 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 → MlScaleReference.tsx.html} +57 -36
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +2 -2
- package/coverage/lcov-report/src/components/MlShareMapState/{MlShareMapState.js.html → MlShareMapState.tsx.html} +192 -84
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +20 -20
- 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 +2 -2
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreejsLayer.tsx.html +769 -0
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +25 -10
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +1 -1
- 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 +22 -10
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +13 -13
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +11 -11
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +11 -11
- package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +27 -18
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +11 -11
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +72 -27
- 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 +21 -21
- 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 +2 -2
- package/coverage/lcov-report/src/hooks/useGpx/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useGpx/useGpx.tsx.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +9 -9
- package/coverage/lcov-report/src/hooks/useLayerFilter/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayerFilter/useLayerFilter.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayerHoverPopup/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx.html +9 -6
- package/coverage/lcov-report/src/hooks/useMap.ts.html +2 -2
- package/coverage/lcov-report/src/hooks/useMapState.ts.html +8 -29
- package/coverage/lcov-report/src/hooks/useSource.ts.html +10 -10
- package/coverage/lcov-report/src/hooks/useWms.ts.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +105 -12
- package/coverage/lcov.info +1038 -917
- package/dist/components/MapLibreMap/MapLibreMap.d.ts +3 -3
- package/dist/components/MapLibreMap/MapLibreMap.stories.d.ts +5 -0
- package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +17 -15
- package/dist/components/MlCenterPosition/MlCenterPosition.d.ts +2 -15
- package/dist/components/MlCenterPosition/MlCenterPosition.stories.d.ts +2 -15
- package/dist/components/MlComponentTemplate/MlComponentTemplate.d.ts +1 -0
- package/dist/components/MlComponentTemplate/MlComponentTemplate.stories.d.ts +2 -1
- package/dist/components/MlCreatePdfButton/MlCreatePdfButton.d.ts +1 -0
- package/dist/components/MlCreatePdfButton/MlCreatePdfButton.stories.d.ts +2 -1
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.d.ts +1 -0
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.stories.d.ts +2 -1
- package/dist/components/MlCreatePdfForm/lib/PdfForm.d.ts +1 -0
- package/dist/components/MlCreatePdfForm/lib/_PdfPreview.d.ts +1 -0
- package/dist/components/MlFeatureEditor/MlFeatureEditor.d.ts +1 -0
- package/dist/components/MlFeatureEditor/lib/create_supplementary_points.d.ts +1 -1
- package/dist/components/MlFeatureEditor/lib/create_vertex.d.ts +1 -1
- package/dist/components/MlFillExtrusionLayer/MlFillExtrusionLayer.d.ts +1 -0
- package/dist/components/MlFollowGps/MlFollowGps.d.ts +5 -23
- package/dist/components/MlFollowGps/MlFollowGps.stories.d.ts +2 -2
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +1 -0
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +2 -1
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.d.ts +1 -0
- package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.d.ts +1 -0
- package/dist/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.d.ts +4 -1
- package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.d.ts +1 -0
- package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.d.ts +2 -1
- package/dist/components/MlGpxViewer/MlGpxViewer.d.ts +1 -0
- package/dist/components/MlGpxViewer/MlGpxViewer.stories.d.ts +2 -1
- package/dist/components/MlGpxViewer/util/GeoJsonProvider.d.ts +1 -0
- package/dist/components/MlGpxViewer/util/MetadataDrawer.d.ts +1 -0
- package/dist/components/MlGpxViewer/util/MlGpxDemoLoader.d.ts +1 -0
- package/dist/components/MlGpxViewer/util/MlGpxViewerInstructions.d.ts +1 -0
- package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.d.ts +1 -0
- package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.d.ts +2 -1
- package/dist/components/MlLayer/MlLayer.d.ts +1 -0
- package/dist/components/MlLayerMagnify/MlLayerMagnify.stories.d.ts +2 -1
- package/dist/components/MlLayerSwipe/MlLayerSwipe.stories.d.ts +2 -1
- package/dist/components/MlMarker/MlMarker.d.ts +1 -0
- package/dist/components/MlMeasureTool/MlMeasureTool.d.ts +1 -0
- package/dist/components/MlNavigationCompass/MlNavigationCompass.d.ts +1 -0
- package/dist/components/MlNavigationTools/MlNavigationTools.d.ts +5 -0
- package/dist/components/MlScaleReference/MlScaleReference.d.ts +8 -1
- package/dist/components/MlShareMapState/MlShareMapState.d.ts +33 -13
- package/dist/components/MlShareMapState/MlShareMapState.stories.d.ts +16 -9
- package/dist/components/MlSketchTool/LayerList/ColorPicker.d.ts +1 -0
- package/dist/components/MlSketchTool/LayerList/LayerList.d.ts +1 -0
- package/dist/components/MlSketchTool/LayerList/LayerListItem.d.ts +1 -0
- package/dist/components/MlSketchTool/LayerList/LayerPropertyForm.d.ts +1 -0
- package/dist/components/MlSketchTool/MlSketchTool.d.ts +1 -0
- package/dist/components/MlSketchTool/MlSketchTool.stories.d.ts +2 -1
- package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.d.ts +1 -0
- package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.d.ts +2 -1
- package/dist/components/MlSpatialElevationProfile/util/getElevationData.d.ts +1 -1
- package/dist/components/MlThreeJsLayer/MlThreeJsLayer.stories.d.ts +2 -1
- package/dist/components/MlThreeJsLayer/MlThreejsLayer.d.ts +30 -0
- package/dist/components/MlThreeJsLayer/lib/GLTFLoader.d.ts +2 -1
- package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +1 -0
- package/dist/components/MlVectorTileLayer/MlVectorTileLayer.d.ts +3 -2
- package/dist/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.d.ts +2 -1
- package/dist/components/MlWmsLayer/MlWmsLayer.d.ts +1 -0
- package/dist/components/MlWmsLoader/MlWmsLoader.d.ts +1 -0
- package/dist/components/MlWmsLoader/MlWmsLoader.stories.d.ts +2 -1
- package/dist/components/MlWmsLoader/utils/MlWmsLoaderInstructions.d.ts +1 -0
- package/dist/components/MlWmsLoader/utils/WMSLinks.d.ts +1 -0
- package/dist/contexts/MapContext.d.ts +13 -2
- package/dist/decorators/EmptyMapDecorator.d.ts +2 -0
- package/dist/decorators/MapContextDecorator.d.ts +1 -1
- package/dist/decorators/MapContextDecoratorHooks.d.ts +1 -1
- package/dist/decorators/MultiMapContextDecorator.d.ts +1 -1
- package/dist/decorators/NoNavToolsDecorator.d.ts +1 -1
- package/dist/decorators/ThemeDecorator.d.ts +2 -0
- package/dist/hooks/useCameraFollowPath/useCameraFollowPath.stories.d.ts +2 -1
- package/dist/hooks/useExportMap/lib.d.ts +1 -1
- package/dist/hooks/useLayerFilter/useLayerFilter.stories.d.ts +2 -1
- package/dist/hooks/useLayerHoverPopup/useLayerHoverPopup.d.ts +1 -0
- package/dist/index.d.ts +25 -8
- package/dist/index.esm.css +0 -97
- package/dist/index.esm.js +2187 -9306
- package/dist/index.esm.js.map +1 -1
- package/dist/setupTests.d.ts +6 -6
- package/dist/ui_components/Dropzone.d.ts +1 -0
- package/dist/ui_components/ImageLoader.d.ts +1 -0
- package/dist/ui_components/LayerList/LayerList.d.ts +6 -0
- package/dist/ui_components/LayerList/LayerList.stories.d.ts +12 -0
- package/dist/ui_components/LayerList/LayerListFolder.d.ts +9 -0
- package/dist/ui_components/LayerList/LayerListItem.d.ts +18 -0
- package/dist/ui_components/LayerList/util/LayerListItemVectorLayer.d.ts +15 -0
- package/dist/ui_components/LayerList/util/LayerPropertyForm.d.ts +10 -0
- package/dist/ui_components/LayerList/util/input/ColorPicker.d.ts +10 -0
- package/dist/ui_components/LoadingOverlayContext.d.ts +0 -1
- package/dist/ui_components/MapcomponentsTheme.d.ts +7 -0
- package/dist/ui_components/Tooltip.d.ts +1 -0
- package/dist/ui_components/TopToolbar.d.ts +1 -0
- package/dist/ui_components/UploadButton.d.ts +1 -0
- package/dist/util/Instructions.d.ts +1 -0
- package/package.json +67 -67
- package/public/thumbnails/{MlGPXViewer.png → MlGpxViewer.png} +0 -0
- package/rollup.config.js +68 -50
- package/src/@types/assets/index.d.ts +20 -0
- package/src/App.css +0 -55
- package/src/components/MapLibreMap/MapLibreMap.stories.js +38 -32
- package/src/components/MapLibreMap/MapLibreMap.tsx +29 -21
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +50 -40
- package/src/components/MlCenterPosition/MlCenterPosition.tsx +22 -29
- package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +6 -6
- package/src/components/MlFollowGps/MlFollowGps.stories.js +28 -10
- package/src/components/MlFollowGps/MlFollowGps.tsx +38 -57
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +1 -1
- package/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.ts +16 -10
- package/src/components/MlGpxViewer/MlGpxViewer.stories.tsx +4 -13
- package/src/components/MlGpxViewer/util/MlGpxDemoLoader.tsx +3 -1
- package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +21 -17
- package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +3 -3
- package/src/components/MlNavigationTools/MlNavigationTools.stories.js +4 -5
- package/src/components/MlNavigationTools/MlNavigationTools.tsx +30 -54
- package/src/components/MlScaleReference/{MlScaleReference.js → MlScaleReference.tsx} +38 -31
- package/src/components/MlShareMapState/MlShareMapState.stories.tsx +100 -0
- package/src/components/MlShareMapState/{MlShareMapState.js → MlShareMapState.tsx} +94 -58
- package/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx +1 -1
- package/src/components/MlSketchTool/MlSketchTool.tsx +1 -1
- package/src/components/MlThreeJsLayer/MlThreejsLayer.tsx +228 -0
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx +7 -3
- package/src/components/MlWmsLoader/MlWmsLoader.stories.tsx +3 -11
- package/src/components/MlWmsLoader/MlWmsLoader.tsx +7 -4
- package/src/components/MlWmsLoader/utils/MlWmsLoaderInstructions.tsx +2 -2
- package/src/components/MlWmsLoader/utils/WMSLinks.tsx +1 -1
- package/src/contexts/MapContext.tsx +34 -20
- package/src/custom.d.ts +4 -0
- package/src/decorators/EmptyMapDecorator.js +38 -0
- package/src/decorators/MapContextDecorator.js +31 -26
- package/src/decorators/MapContextDecoratorHooks.js +29 -24
- package/src/decorators/MultiMapContextDecorator.js +71 -71
- package/src/decorators/NoNavToolsDecorator.js +25 -23
- package/src/decorators/ThemeDecorator.js +24 -0
- package/src/decorators/style.css +0 -2
- package/src/hooks/useCameraFollowPath/useCameraFollowPath.stories.tsx +13 -19
- package/src/hooks/useExportMap/lib.ts +1 -1
- package/src/hooks/useGpx/useGpx.stories.js +1 -1
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.stories.js +1 -1
- package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx +5 -4
- package/src/hooks/useMap.ts +1 -1
- package/src/hooks/useMapState.stories.js +1 -1
- package/src/hooks/useMapState.ts +6 -13
- package/src/hooks/useSource.ts +1 -1
- package/src/hooks/useSources.stories.js +1 -1
- package/src/index.ts +40 -8
- package/src/ui_components/LayerList/LayerList.stories.tsx +136 -0
- package/src/ui_components/LayerList/LayerList.tsx +12 -0
- package/src/ui_components/LayerList/LayerListFolder.tsx +82 -0
- package/src/ui_components/LayerList/LayerListItem.tsx +180 -0
- package/src/ui_components/LayerList/assets/sample_1.json +26 -0
- package/src/ui_components/LayerList/assets/sample_2.json +22 -0
- package/src/ui_components/LayerList/assets/sample_polygon_1.json +33 -0
- package/src/ui_components/LayerList/assets/style.json +2599 -0
- package/src/ui_components/LayerList/util/LayerListItemVectorLayer.tsx +92 -0
- package/src/ui_components/LayerList/util/LayerPropertyForm.tsx +125 -0
- package/src/ui_components/LayerList/util/input/ColorPicker.tsx +44 -0
- package/src/ui_components/MapcomponentsTheme.tsx +133 -0
- package/src/ui_components/Sidebar.tsx +16 -11
- package/src/ui_components/TopToolbar.tsx +1 -3
- package/src/util/BubbleForInstructions.js +14 -12
- package/tsconfig.json +3 -9
- package/dist/components/MlGPXViewer/MlGPXViewer.d.ts +0 -29
- package/dist/components/MlGPXViewer/MlGPXViewer.stories.d.ts +0 -16
- package/dist/components/MlGPXViewer/MlGPXViewer.test.d.ts +0 -1
- package/dist/components/MlGPXViewer/gpxConverter.d.ts +0 -11
- package/dist/components/MlGPXViewer/util/GeoJsonContext.d.ts +0 -10
- package/dist/components/MlGPXViewer/util/GeoJsonProvider.d.ts +0 -4
- package/dist/components/MlLayer/MlLayer.stories.d.ts +0 -10
- package/dist/custom.d.d.ts +0 -22
- package/dist/decorators/ThemeWrapper.d.ts +0 -3
- package/dist/hooks/exportMap/index.d.ts +0 -11
- package/dist/hooks/exportMap/lib.d.ts +0 -36
- package/dist/ui_components/Legend.d.ts +0 -1
- package/dist/ui_components/LoadingOverlay.d.ts +0 -2
- package/src/components/MlShareMapState/MlShareMapState.stories.js +0 -100
- package/src/custom.d.tsx +0 -26
- package/src/decorators/ThemeWrapper.tsx +0 -9
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import React, { useRef, useEffect, useState, useCallback } from
|
|
2
|
-
import useMap from
|
|
1
|
+
import React, { useRef, useEffect, useState, useCallback } from 'react';
|
|
2
|
+
import useMap from '../../hooks/useMap';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export interface MlScaleReferenceProps {
|
|
5
|
+
mapId?: string;
|
|
6
|
+
insertBeforeLayer?: string | undefined;
|
|
7
|
+
maxWidth?: number;
|
|
8
|
+
unit?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const MlScaleReference = (props: MlScaleReferenceProps) => {
|
|
5
12
|
const zoomRef = useRef(0);
|
|
6
13
|
const mapHook = useMap({ mapId: props.mapId, waitForLayer: props.insertBeforeLayer });
|
|
7
14
|
|
|
8
15
|
const [pxWidth, setPxWidth] = useState(0);
|
|
9
|
-
const [text, setText] = useState(
|
|
16
|
+
const [text, setText] = useState('');
|
|
10
17
|
|
|
11
18
|
const updateScale = useCallback(() => {
|
|
19
|
+
if (!mapHook.map) return;
|
|
12
20
|
if (mapHook.map?.map.getZoom() === zoomRef.current) {
|
|
13
21
|
return;
|
|
14
22
|
}
|
|
15
|
-
if (!mapHook.map) return;
|
|
16
23
|
|
|
17
24
|
zoomRef.current = mapHook.map?.map.getZoom();
|
|
18
25
|
// Calculation from MapLibre
|
|
@@ -21,56 +28,56 @@ const MlScaleReference = (props) => {
|
|
|
21
28
|
// found between the two coordinates.
|
|
22
29
|
const maxWidth = props.maxWidth || 100;
|
|
23
30
|
|
|
24
|
-
const y = mapHook.map._container.clientHeight / 2;
|
|
25
|
-
const left = mapHook.map.unproject([0, y]);
|
|
26
|
-
const right = mapHook.map.unproject([maxWidth, y]);
|
|
31
|
+
const y = mapHook.map.map._container.clientHeight / 2;
|
|
32
|
+
const left = mapHook.map.map.unproject([0, y]);
|
|
33
|
+
const right = mapHook.map.map.unproject([maxWidth, y]);
|
|
27
34
|
const maxMeters = left.distanceTo(right);
|
|
28
35
|
// The real distance corresponding to 100px scale length is rounded off to
|
|
29
36
|
// near pretty number and the scale length for the same is found out.
|
|
30
37
|
// Default unit of the scale is based on User's locale.
|
|
31
|
-
if (props.unit ===
|
|
38
|
+
if (props.unit === 'imperial') {
|
|
32
39
|
const maxFeet = 3.2808 * maxMeters;
|
|
33
40
|
if (maxFeet > 5280) {
|
|
34
41
|
const maxMiles = maxFeet / 5280;
|
|
35
|
-
setScale(maxWidth, maxMiles, mapHook.map._getUIString(
|
|
42
|
+
setScale(maxWidth, maxMiles, mapHook.map.map._getUIString('ScaleControl.Miles'));
|
|
36
43
|
} else {
|
|
37
|
-
setScale(maxWidth, maxFeet, mapHook.map._getUIString(
|
|
44
|
+
setScale(maxWidth, maxFeet, mapHook.map.map._getUIString('ScaleControl.Feet'));
|
|
38
45
|
}
|
|
39
|
-
} else if (props.unit ===
|
|
46
|
+
} else if (props.unit === 'nautical') {
|
|
40
47
|
const maxNauticals = maxMeters / 1852;
|
|
41
|
-
setScale(maxWidth, maxNauticals, mapHook.map._getUIString(
|
|
48
|
+
setScale(maxWidth, maxNauticals, mapHook.map.map._getUIString('ScaleControl.NauticalMiles'));
|
|
42
49
|
} else if (maxMeters >= 1000) {
|
|
43
|
-
setScale(maxWidth, maxMeters / 1000, mapHook.map._getUIString(
|
|
50
|
+
setScale(maxWidth, maxMeters / 1000, mapHook.map.map._getUIString('ScaleControl.Kilometers'));
|
|
44
51
|
} else {
|
|
45
|
-
setScale(maxWidth, maxMeters, mapHook.map._getUIString(
|
|
52
|
+
setScale(maxWidth, maxMeters, mapHook.map.map._getUIString('ScaleControl.Meters'));
|
|
46
53
|
}
|
|
47
54
|
}, [mapHook.map, props.unit, props.maxWidth]);
|
|
48
55
|
|
|
49
56
|
useEffect(() => {
|
|
50
57
|
if (!mapHook.map) return;
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
mapHook.map.on(
|
|
59
|
+
const _updateScale = updateScale;
|
|
60
|
+
mapHook.map.on('move', _updateScale, mapHook.componentId);
|
|
54
61
|
updateScale();
|
|
55
62
|
|
|
56
63
|
return () => {
|
|
57
|
-
mapHook.map.off(
|
|
64
|
+
mapHook.map?.map.off('move', _updateScale);
|
|
58
65
|
};
|
|
59
66
|
}, [mapHook.map, updateScale]);
|
|
60
67
|
|
|
61
|
-
const setScale = (maxWidth, maxDistance, unit) => {
|
|
68
|
+
const setScale = (maxWidth: number, maxDistance: number, unit: string) => {
|
|
62
69
|
const distance = getRoundNum(maxDistance);
|
|
63
70
|
const ratio = distance / maxDistance;
|
|
64
71
|
setPxWidth(maxWidth * ratio);
|
|
65
|
-
setText(distance +
|
|
72
|
+
setText(distance + ' ' + unit);
|
|
66
73
|
};
|
|
67
74
|
|
|
68
|
-
const getDecimalRoundNum = (d) => {
|
|
75
|
+
const getDecimalRoundNum = (d: number) => {
|
|
69
76
|
const multiplier = Math.pow(10, Math.ceil(-Math.log(d) / Math.LN10));
|
|
70
77
|
return Math.round(d * multiplier) / multiplier;
|
|
71
78
|
};
|
|
72
79
|
|
|
73
|
-
const getRoundNum = (num) => {
|
|
80
|
+
const getRoundNum = (num: number) => {
|
|
74
81
|
const pow10 = Math.pow(10, `${Math.floor(num)}`.length - 1);
|
|
75
82
|
let d = num / pow10;
|
|
76
83
|
|
|
@@ -83,15 +90,15 @@ const MlScaleReference = (props) => {
|
|
|
83
90
|
<>
|
|
84
91
|
<div
|
|
85
92
|
style={{
|
|
86
|
-
backgroundColor:
|
|
87
|
-
fontSize:
|
|
88
|
-
border:
|
|
89
|
-
borderTop:
|
|
90
|
-
padding:
|
|
91
|
-
color:
|
|
92
|
-
boxSizing:
|
|
93
|
-
width: pxWidth +
|
|
94
|
-
fontFamily:
|
|
93
|
+
backgroundColor: 'hsla(0,0%,100%,.75)',
|
|
94
|
+
fontSize: '10px',
|
|
95
|
+
border: '2px solid #333',
|
|
96
|
+
borderTop: '#333',
|
|
97
|
+
padding: '0 5px',
|
|
98
|
+
color: '#333',
|
|
99
|
+
boxSizing: 'border-box',
|
|
100
|
+
width: pxWidth + 'px',
|
|
101
|
+
fontFamily: 'sans-serif',
|
|
95
102
|
}}
|
|
96
103
|
dangerouslySetInnerHTML={{ __html: text }}
|
|
97
104
|
></div>
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import MlShareMapState from './MlShareMapState';
|
|
4
|
+
import mapContextDecorator from '../../decorators/MapContextDecorator';
|
|
5
|
+
import useMapState from '../../hooks/useMapState';
|
|
6
|
+
import useMap from '../../hooks/useMap';
|
|
7
|
+
import Sidebar from '../../ui_components/Sidebar';
|
|
8
|
+
import ListItem from '@mui/material/ListItem';
|
|
9
|
+
import IconButton from '@mui/material/IconButton';
|
|
10
|
+
import VisibilityIcon from '@mui/icons-material/Visibility';
|
|
11
|
+
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
|
12
|
+
import ListItemText from '@mui/material/ListItemText';
|
|
13
|
+
import sample_geojson_1 from '../MlGeoJsonLayer/assets/sample_1.json';
|
|
14
|
+
import sample_geojson_2 from '../MlGeoJsonLayer/assets/sample_2.json';
|
|
15
|
+
import List from '@mui/material/List';
|
|
16
|
+
import MlGeoJsonLayer from '../MlGeoJsonLayer/MlGeoJsonLayer';
|
|
17
|
+
import { ToggleButton } from '@mui/material';
|
|
18
|
+
import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline';
|
|
19
|
+
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
20
|
+
|
|
21
|
+
const storyoptions = {
|
|
22
|
+
title: 'MapComponents/MlShareMapState',
|
|
23
|
+
component: MlShareMapState,
|
|
24
|
+
argTypes: {},
|
|
25
|
+
decorators: mapContextDecorator,
|
|
26
|
+
};
|
|
27
|
+
export default storyoptions;
|
|
28
|
+
|
|
29
|
+
const Template = () => {
|
|
30
|
+
const geoJsonArray = [sample_geojson_1, sample_geojson_2];
|
|
31
|
+
const [watchState, setWatchState] = useState(true);
|
|
32
|
+
const mapHook = useMap({ mapId: 'map_1' });
|
|
33
|
+
const mapState = useMapState({
|
|
34
|
+
mapId: 'map_1',
|
|
35
|
+
watch: {
|
|
36
|
+
viewport: false,
|
|
37
|
+
layers: true,
|
|
38
|
+
sources: false,
|
|
39
|
+
},
|
|
40
|
+
filter: {
|
|
41
|
+
includeBaseLayers: false,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
<MlShareMapState active={watchState} />
|
|
48
|
+
{geoJsonArray.map((el, i) => (
|
|
49
|
+
<MlGeoJsonLayer layerId={'GeoJson_' + i} type="line" geojson={el} key={'GeoJson_' + i} />
|
|
50
|
+
))}
|
|
51
|
+
<Sidebar sx={{ wordBreak: 'break-word' }}>
|
|
52
|
+
<ToggleButton
|
|
53
|
+
size="small"
|
|
54
|
+
selected={watchState}
|
|
55
|
+
value={watchState}
|
|
56
|
+
onChange={() => {
|
|
57
|
+
setWatchState(!watchState);
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
{watchState ? <CheckCircleOutlineIcon /> : <ErrorOutlineIcon />}
|
|
61
|
+
|
|
62
|
+
{watchState ? 'active' : 'inactive'}
|
|
63
|
+
</ToggleButton>
|
|
64
|
+
<List dense key="layers">
|
|
65
|
+
{mapState.layers?.map((el) => (
|
|
66
|
+
<ListItem
|
|
67
|
+
key={el?.id}
|
|
68
|
+
secondaryAction={
|
|
69
|
+
<IconButton
|
|
70
|
+
edge="end"
|
|
71
|
+
aria-label="toggle visibility"
|
|
72
|
+
onClick={() => {
|
|
73
|
+
const currentVisibility = mapHook.map
|
|
74
|
+
?.getLayer?.(el?.id)
|
|
75
|
+
?.getLayoutProperty('visibility');
|
|
76
|
+
mapHook.map
|
|
77
|
+
?.getLayer?.(el?.id)
|
|
78
|
+
?.setLayoutProperty(
|
|
79
|
+
'visibility',
|
|
80
|
+
currentVisibility === 'none' ? 'visible' : 'none'
|
|
81
|
+
);
|
|
82
|
+
mapHook.map?.map.fire('zoom');
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
{el?.visible ? <VisibilityIcon /> : <VisibilityOffIcon />}
|
|
86
|
+
</IconButton>
|
|
87
|
+
}
|
|
88
|
+
>
|
|
89
|
+
<ListItemText primary={el?.id} secondary={''} />
|
|
90
|
+
</ListItem>
|
|
91
|
+
))}
|
|
92
|
+
</List>
|
|
93
|
+
</Sidebar>
|
|
94
|
+
</>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export const ExampleConfig = Template.bind({});
|
|
99
|
+
ExampleConfig.parameters = {};
|
|
100
|
+
ExampleConfig.args = {};
|
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
import React, { useRef, useEffect, useContext, useState, useCallback } from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
|
|
4
|
-
import MapContext from
|
|
5
|
-
import { v4 as uuidv4 } from
|
|
6
|
-
import useMapState from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import React, { useRef, useEffect, useContext, useState, useCallback } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import MapContext from '../../contexts/MapContext';
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
import useMapState from '../../hooks/useMapState';
|
|
7
|
+
import MapLibreGlWrapper from '../MapLibreMap/lib/MapLibreGlWrapper';
|
|
8
|
+
|
|
9
|
+
export interface MapState {
|
|
10
|
+
lat?: number;
|
|
11
|
+
lng?: number;
|
|
12
|
+
zoom?: number;
|
|
13
|
+
bearing?: number;
|
|
14
|
+
pitch?: number;
|
|
15
|
+
layers?: {
|
|
16
|
+
visible: boolean;
|
|
17
|
+
id: string;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const getCurrentUrlParameters = (): MapState => {
|
|
22
|
+
const currentParams = Object.fromEntries(new URLSearchParams(window.location.search));
|
|
23
|
+
currentParams.layers = JSON.parse(currentParams?.layers ? currentParams.layers : '[]');
|
|
11
24
|
|
|
12
25
|
return currentParams;
|
|
13
26
|
};
|
|
@@ -22,14 +35,27 @@ const initialUrlParams = getCurrentUrlParameters();
|
|
|
22
35
|
*
|
|
23
36
|
* @component
|
|
24
37
|
*/
|
|
25
|
-
|
|
38
|
+
|
|
39
|
+
export interface MlShareMapStateProps {
|
|
40
|
+
//
|
|
41
|
+
mapId?: string;
|
|
42
|
+
idPrefix?: string;
|
|
43
|
+
active?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface LayerStatesInterface {
|
|
47
|
+
//
|
|
48
|
+
[key: string]: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const MlShareMapState = (props: MlShareMapStateProps) => {
|
|
26
52
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
27
53
|
const mapContext = useContext(MapContext);
|
|
28
54
|
const initializedRef = useRef(false);
|
|
29
|
-
const mapRef = useRef(
|
|
30
|
-
const [map, setMap] = useState(undefined);
|
|
55
|
+
const mapRef = useRef<MapLibreGlWrapper | undefined>();
|
|
56
|
+
const [map, setMap] = useState<MapLibreGlWrapper | undefined>(undefined);
|
|
31
57
|
const layersFromUrlParamsRef = useRef({});
|
|
32
|
-
const componentId = useRef((props.idPrefix ? props.idPrefix :
|
|
58
|
+
const componentId = useRef((props.idPrefix ? props.idPrefix : 'MlShareMapState-') + uuidv4());
|
|
33
59
|
const mapState = useMapState({
|
|
34
60
|
watch: {
|
|
35
61
|
viewport: false,
|
|
@@ -42,7 +68,7 @@ const MlShareMapState = (props) => {
|
|
|
42
68
|
});
|
|
43
69
|
|
|
44
70
|
const allStatesRestoredRef = useRef(false);
|
|
45
|
-
const layerStatesRestored = useRef(
|
|
71
|
+
const layerStatesRestored = useRef<LayerStatesInterface>();
|
|
46
72
|
const restoredStatesRef = useRef({
|
|
47
73
|
viewport: {
|
|
48
74
|
center: false,
|
|
@@ -56,42 +82,42 @@ const MlShareMapState = (props) => {
|
|
|
56
82
|
});
|
|
57
83
|
|
|
58
84
|
// initial URL-Params
|
|
59
|
-
const mapStateRef = useRef({});
|
|
85
|
+
const mapStateRef = useRef<MapState>({});
|
|
60
86
|
|
|
61
87
|
const refreshUrlParameters = useCallback(() => {
|
|
62
88
|
if (!props.active) return;
|
|
63
89
|
|
|
64
|
-
|
|
65
|
-
for (
|
|
90
|
+
const mapLayers = [];
|
|
91
|
+
for (const x in mapState.layers) {
|
|
66
92
|
mapLayers.push({
|
|
67
|
-
id: mapState.layers[x]
|
|
68
|
-
type: mapState.layers[x]
|
|
69
|
-
visible: mapState.layers[x]
|
|
93
|
+
id: mapState.layers[x]?.id,
|
|
94
|
+
type: mapState.layers[x]?.type,
|
|
95
|
+
visible: mapState.layers[x]?.visible,
|
|
70
96
|
});
|
|
71
97
|
}
|
|
72
98
|
refreshMapState();
|
|
73
|
-
|
|
74
|
-
...getCurrentUrlParameters(),
|
|
75
|
-
...mapStateRef.current,
|
|
99
|
+
const urlParams = new URLSearchParams({
|
|
100
|
+
...(getCurrentUrlParameters() as Record<string, string>),
|
|
101
|
+
...(mapStateRef.current as Record<string, string>),
|
|
76
102
|
layers: JSON.stringify(mapLayers),
|
|
77
103
|
});
|
|
78
|
-
JSON.parse(Object.fromEntries(urlParams).layers).forEach((el) => {
|
|
104
|
+
JSON.parse(Object.fromEntries(urlParams).layers).forEach((el: { id: number }) => {
|
|
105
|
+
// is iD a number?
|
|
79
106
|
layersFromUrlParamsRef.current[el.id] = false;
|
|
80
107
|
});
|
|
81
108
|
|
|
82
|
-
|
|
83
|
-
checkRestorationStates(mapState.layers);
|
|
109
|
+
const currentParams = new URLSearchParams(window.location.search);
|
|
84
110
|
if (urlParams.toString() !== currentParams.toString()) {
|
|
85
111
|
window.history.pushState(
|
|
86
112
|
{ ...mapStateRef.current },
|
|
87
113
|
document.title,
|
|
88
|
-
|
|
114
|
+
'?' + urlParams.toString()
|
|
89
115
|
);
|
|
90
116
|
}
|
|
91
117
|
}, [mapState.layers, props.active]);
|
|
92
118
|
|
|
93
119
|
useEffect(() => {
|
|
94
|
-
|
|
120
|
+
const _componentId = componentId.current;
|
|
95
121
|
|
|
96
122
|
mapStateRef.current = getCurrentUrlParameters();
|
|
97
123
|
|
|
@@ -119,12 +145,12 @@ const MlShareMapState = (props) => {
|
|
|
119
145
|
useEffect(() => {
|
|
120
146
|
if (!mapRef.current) return;
|
|
121
147
|
|
|
122
|
-
|
|
148
|
+
const _refreshUrlParameters = refreshUrlParameters;
|
|
123
149
|
|
|
124
|
-
mapRef.current.on(
|
|
150
|
+
mapRef.current.on('moveend', _refreshUrlParameters, componentId.current);
|
|
125
151
|
|
|
126
152
|
return () => {
|
|
127
|
-
mapRef.current?.off(
|
|
153
|
+
mapRef.current?.map.off('moveend', _refreshUrlParameters);
|
|
128
154
|
};
|
|
129
155
|
}, [refreshUrlParameters, map]);
|
|
130
156
|
|
|
@@ -143,14 +169,16 @@ const MlShareMapState = (props) => {
|
|
|
143
169
|
useEffect(() => {
|
|
144
170
|
if (!mapState?.layers?.length) return;
|
|
145
171
|
|
|
146
|
-
if (typeof layerStatesRestored.current ===
|
|
147
|
-
layerStatesRestored.current =
|
|
148
|
-
initialUrlParams?.layers
|
|
149
|
-
layerStatesRestored.current[layer.id]
|
|
172
|
+
if (typeof layerStatesRestored.current === 'undefined') {
|
|
173
|
+
layerStatesRestored.current = undefined;
|
|
174
|
+
initialUrlParams?.layers?.forEach((layer: { id: string }) => {
|
|
175
|
+
if (layerStatesRestored.current?.[layer.id]) {
|
|
176
|
+
layerStatesRestored.current[layer.id] = false;
|
|
177
|
+
}
|
|
150
178
|
});
|
|
151
179
|
}
|
|
152
180
|
|
|
153
|
-
for (
|
|
181
|
+
for (const key in layerStatesRestored.current) {
|
|
154
182
|
let _allDone = true;
|
|
155
183
|
if (layerStatesRestored.current[key] === false) {
|
|
156
184
|
_allDone = false;
|
|
@@ -162,11 +190,14 @@ const MlShareMapState = (props) => {
|
|
|
162
190
|
|
|
163
191
|
if (initialUrlParams.layers) {
|
|
164
192
|
initialUrlParams.layers.forEach((layer) => {
|
|
165
|
-
if (
|
|
193
|
+
if (
|
|
194
|
+
mapRef.current?.map.getLayer(layer.id) && //number oder str?
|
|
195
|
+
layerStatesRestored.current?.[layer.id] === false
|
|
196
|
+
) {
|
|
166
197
|
layerStatesRestored.current[layer.id] = true;
|
|
167
|
-
mapRef.current
|
|
198
|
+
mapRef.current.map
|
|
168
199
|
?.getLayer(layer.id)
|
|
169
|
-
?.setLayoutProperty(
|
|
200
|
+
?.setLayoutProperty('visibility', layer.visible ? 'visible' : 'none');
|
|
170
201
|
}
|
|
171
202
|
});
|
|
172
203
|
}
|
|
@@ -181,28 +212,32 @@ const MlShareMapState = (props) => {
|
|
|
181
212
|
}
|
|
182
213
|
}, [props.active, map, mapState.layers]);
|
|
183
214
|
|
|
184
|
-
|
|
185
|
-
mapStateRef.current.lat = mapRef.current.getCenter().lat;
|
|
186
|
-
mapStateRef.current.lng = mapRef.current.getCenter().lng;
|
|
187
|
-
mapStateRef.current.zoom = mapRef.current.getZoom();
|
|
188
|
-
mapStateRef.current.bearing = mapRef.current.getBearing();
|
|
189
|
-
mapStateRef.current.pitch = mapRef.current.getPitch();
|
|
190
|
-
};
|
|
215
|
+
//ist .current?.map. richtig?
|
|
191
216
|
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
217
|
+
const refreshMapState = () => {
|
|
218
|
+
mapStateRef.current.lat = mapRef.current?.map.getCenter().lat;
|
|
219
|
+
mapStateRef.current.lng = mapRef.current?.map.getCenter().lng;
|
|
220
|
+
mapStateRef.current.zoom = mapRef.current?.map.getZoom();
|
|
221
|
+
mapStateRef.current.bearing = mapRef.current?.map.getBearing();
|
|
222
|
+
mapStateRef.current.pitch = mapRef.current?.map.getPitch();
|
|
197
223
|
};
|
|
198
224
|
|
|
199
225
|
const restoreViewportState = () => {
|
|
200
226
|
if (!restoredStatesRef.current.viewport.center) {
|
|
201
227
|
restoredStatesRef.current.viewport.center = true;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
228
|
+
|
|
229
|
+
if (mapStateRef.current.lng && mapStateRef.current.lat) {
|
|
230
|
+
mapRef.current?.map.setCenter([mapStateRef.current.lng, mapStateRef.current.lat]);
|
|
231
|
+
}
|
|
232
|
+
if (mapStateRef.current.zoom) {
|
|
233
|
+
mapRef.current?.map.setZoom(mapStateRef.current.zoom);
|
|
234
|
+
}
|
|
235
|
+
if (mapStateRef.current.bearing) {
|
|
236
|
+
mapRef.current?.map.setBearing(mapStateRef.current.bearing);
|
|
237
|
+
}
|
|
238
|
+
if (mapStateRef.current.pitch) {
|
|
239
|
+
mapRef.current?.map.setPitch(mapStateRef.current.pitch);
|
|
240
|
+
}
|
|
206
241
|
}
|
|
207
242
|
|
|
208
243
|
allStatesRestoredRef.current = true;
|
|
@@ -210,7 +245,8 @@ const MlShareMapState = (props) => {
|
|
|
210
245
|
|
|
211
246
|
window.onpopstate = (event) => {
|
|
212
247
|
if (event.state && event.state.lng && event.state.lat && event.state.zoom) {
|
|
213
|
-
mapRef.current.easeTo({
|
|
248
|
+
mapRef.current?.map.easeTo({
|
|
249
|
+
// so möglich?
|
|
214
250
|
zoom: event.state.zoom,
|
|
215
251
|
center: [event.state.lng, event.state.lat],
|
|
216
252
|
});
|
|
@@ -218,7 +254,7 @@ const MlShareMapState = (props) => {
|
|
|
218
254
|
};
|
|
219
255
|
|
|
220
256
|
return <></>;
|
|
221
|
-
}
|
|
257
|
+
};;
|
|
222
258
|
|
|
223
259
|
MlShareMapState.defaultProps = {
|
|
224
260
|
mapId: undefined,
|
|
@@ -84,7 +84,7 @@ export default function LayerPropertyForm({ paintProps = {}, setPaintProps }: Pr
|
|
|
84
84
|
<TextField
|
|
85
85
|
inputProps={{ inputMode: 'decimal', pattern: '[0-9]*' }}
|
|
86
86
|
value={paintProps[key]}
|
|
87
|
-
onChange={(ev: React.ChangeEvent) => {
|
|
87
|
+
onChange={(ev: React.ChangeEvent<HTMLInputElement>) => {
|
|
88
88
|
if (ev?.target?.value) {
|
|
89
89
|
setPaintProps((current) => ({ ...current, [key]: parseInt(ev.target.value) }));
|
|
90
90
|
}
|
|
@@ -18,7 +18,7 @@ import Tooltip from '@mui/material/Tooltip';
|
|
|
18
18
|
import LayerListItem from './LayerList/LayerListItem';
|
|
19
19
|
import GpsFixedIcon from '@mui/icons-material/GpsFixed';
|
|
20
20
|
import { Feature } from '@turf/turf';
|
|
21
|
-
import { LngLatLike } from '
|
|
21
|
+
import { LngLatLike } from 'maplibre-gl';
|
|
22
22
|
import { SxProps } from '@mui/system/styleFunctionSx/styleFunctionSx';
|
|
23
23
|
|
|
24
24
|
export interface MlSketchToolProps {
|