@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
|
@@ -2,11 +2,11 @@ import React, { useRef, useEffect, useState, useCallback, useMemo } from "react"
|
|
|
2
2
|
import useMap from "../../hooks/useMap";
|
|
3
3
|
import MlGeoJsonLayer from "../MlGeoJsonLayer/MlGeoJsonLayer";
|
|
4
4
|
|
|
5
|
-
import { Button
|
|
6
|
-
import GpsFixedIcon from
|
|
5
|
+
import { Button } from '@mui/material';
|
|
6
|
+
import GpsFixedIcon from '@mui/icons-material/GpsFixed';
|
|
7
7
|
|
|
8
|
-
import { point, circle, lineArc, Feature, Point } from
|
|
9
|
-
import { CircleLayerSpecification, FillLayerSpecification } from
|
|
8
|
+
import { point, circle, lineArc, Feature, Point } from '@turf/turf';
|
|
9
|
+
import { CircleLayerSpecification, FillLayerSpecification } from 'maplibre-gl';
|
|
10
10
|
|
|
11
11
|
interface MlFollowGpsProps {
|
|
12
12
|
/**
|
|
@@ -47,13 +47,13 @@ interface MlFollowGpsProps {
|
|
|
47
47
|
* Use any available paint prop from layer type "fill".
|
|
48
48
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
49
49
|
*/
|
|
50
|
-
orientationConePaint?: FillLayerSpecification[
|
|
50
|
+
orientationConePaint?: FillLayerSpecification['paint'];
|
|
51
51
|
/**
|
|
52
52
|
* Position circle paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the position circle.
|
|
53
53
|
* Use any available paint prop from layer type "circle".
|
|
54
54
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
55
55
|
*/
|
|
56
|
-
circlePaint?: CircleLayerSpecification[
|
|
56
|
+
circlePaint?: CircleLayerSpecification['paint'];
|
|
57
57
|
/**
|
|
58
58
|
* Active button font color
|
|
59
59
|
*/
|
|
@@ -67,11 +67,7 @@ interface MlFollowGpsProps {
|
|
|
67
67
|
* Use any available paint prop from layer type "fill".
|
|
68
68
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
69
69
|
*/
|
|
70
|
-
accuracyPaint?: FillLayerSpecification[
|
|
71
|
-
/**
|
|
72
|
-
* CSS style object that is applied to the button component
|
|
73
|
-
*/
|
|
74
|
-
buttonSx?: SxProps | any;
|
|
70
|
+
accuracyPaint?: FillLayerSpecification['paint'];
|
|
75
71
|
}
|
|
76
72
|
|
|
77
73
|
/**
|
|
@@ -93,7 +89,7 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
93
89
|
const initiallyCentered = useRef(false);
|
|
94
90
|
|
|
95
91
|
const getLocationSuccess = useCallback(
|
|
96
|
-
(pos) => {
|
|
92
|
+
(pos: GeolocationPosition) => {
|
|
97
93
|
if (!mapHook.map) return;
|
|
98
94
|
|
|
99
95
|
if ((!props.centerUserPosition && !initiallyCentered.current) || props.centerUserPosition) {
|
|
@@ -119,7 +115,7 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
119
115
|
);
|
|
120
116
|
|
|
121
117
|
const getLocationError = () => {
|
|
122
|
-
console.log(
|
|
118
|
+
console.log('Access of user location denied');
|
|
123
119
|
setLocationAccessDenied(true);
|
|
124
120
|
};
|
|
125
121
|
|
|
@@ -127,27 +123,29 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
127
123
|
if (!userLocationGeoJson) {
|
|
128
124
|
return undefined;
|
|
129
125
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
const radius = 0.02;
|
|
127
|
+
const bearing1 = deviceOrientation - 15;
|
|
128
|
+
const bearing2 = deviceOrientation + 15;
|
|
133
129
|
const options = { steps: 65 };
|
|
134
|
-
|
|
135
|
-
|
|
130
|
+
const arc = lineArc(userLocationGeoJson, radius, bearing1, bearing2, options);
|
|
131
|
+
const copy = arc;
|
|
136
132
|
copy.geometry.coordinates.push(userLocationGeoJson.geometry.coordinates);
|
|
137
133
|
copy.geometry.coordinates.slice(0, 0);
|
|
138
134
|
return copy;
|
|
139
135
|
}, [deviceOrientation, userLocationGeoJson]);
|
|
140
136
|
|
|
141
|
-
const handleOrientation = (event:
|
|
142
|
-
|
|
137
|
+
const handleOrientation = (event: DeviceOrientationEvent) => {
|
|
138
|
+
if (event?.alpha) {
|
|
139
|
+
setDeviceOrientation(-event.alpha);
|
|
140
|
+
}
|
|
143
141
|
};
|
|
144
142
|
|
|
145
143
|
useEffect(() => {
|
|
146
144
|
if (isFollowed) {
|
|
147
|
-
|
|
148
|
-
window.addEventListener(
|
|
145
|
+
const _handleOrientation = handleOrientation;
|
|
146
|
+
window.addEventListener('deviceorientation', _handleOrientation);
|
|
149
147
|
return () => {
|
|
150
|
-
window.removeEventListener(
|
|
148
|
+
window.removeEventListener('deviceorientation', _handleOrientation);
|
|
151
149
|
};
|
|
152
150
|
} else {
|
|
153
151
|
initiallyCentered.current = false;
|
|
@@ -159,7 +157,7 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
159
157
|
if (!mapHook.map) return;
|
|
160
158
|
|
|
161
159
|
if (isFollowed) {
|
|
162
|
-
|
|
160
|
+
const _watchId = navigator.geolocation.watchPosition(getLocationSuccess, getLocationError);
|
|
163
161
|
|
|
164
162
|
return () => {
|
|
165
163
|
navigator.geolocation.clearWatch(_watchId);
|
|
@@ -173,10 +171,10 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
173
171
|
{isFollowed && userLocationGeoJson && (
|
|
174
172
|
<MlGeoJsonLayer
|
|
175
173
|
geojson={accuracyGeoJson}
|
|
176
|
-
type={
|
|
174
|
+
type={'fill'}
|
|
177
175
|
paint={{
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
'fill-color': '#cbd300',
|
|
177
|
+
'fill-opacity': 0.3,
|
|
180
178
|
...props.accuracyPaint,
|
|
181
179
|
}}
|
|
182
180
|
insertBeforeLayer={props.insertBeforeLayer}
|
|
@@ -186,11 +184,11 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
186
184
|
{isFollowed && orientationCone && (
|
|
187
185
|
<MlGeoJsonLayer
|
|
188
186
|
geojson={orientationCone}
|
|
189
|
-
type={
|
|
187
|
+
type={'fill'}
|
|
190
188
|
paint={{
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
'fill-color': '#0000ff',
|
|
190
|
+
'fill-antialias': false,
|
|
191
|
+
'fill-opacity': 0.3,
|
|
194
192
|
...props.orientationConePaint,
|
|
195
193
|
}}
|
|
196
194
|
insertBeforeLayer={props.insertBeforeLayer}
|
|
@@ -200,12 +198,12 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
200
198
|
{isFollowed && userLocationGeoJson && (
|
|
201
199
|
<MlGeoJsonLayer
|
|
202
200
|
geojson={userLocationGeoJson}
|
|
203
|
-
type={
|
|
201
|
+
type={'circle'}
|
|
204
202
|
paint={{
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
203
|
+
'circle-color': '#009ee0',
|
|
204
|
+
'circle-radius': 5,
|
|
205
|
+
'circle-stroke-color': '#fafaff',
|
|
206
|
+
'circle-stroke-width': 1,
|
|
209
207
|
...props.circlePaint,
|
|
210
208
|
}}
|
|
211
209
|
insertBeforeLayer={props.insertBeforeLayer}
|
|
@@ -213,20 +211,17 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
213
211
|
)}
|
|
214
212
|
|
|
215
213
|
<Button
|
|
214
|
+
variant="navtools"
|
|
216
215
|
sx={{
|
|
217
216
|
zIndex: 1002,
|
|
218
217
|
color: isFollowed ? props.onColor : props.offColor,
|
|
219
|
-
...props.buttonSx,
|
|
220
218
|
}}
|
|
221
219
|
disabled={locationAccessDenied}
|
|
222
220
|
onClick={() => {
|
|
223
221
|
setIsFollowed(!isFollowed);
|
|
224
222
|
}}
|
|
225
223
|
>
|
|
226
|
-
{
|
|
227
|
-
<GpsFixedIcon
|
|
228
|
-
sx={{ ...(props.buttonSx?.fontSize ? { fontSize: props.buttonSx?.fontSize } : {}) }}
|
|
229
|
-
/>{" "}
|
|
224
|
+
<GpsFixedIcon sx={{ fontSize: { xs: '1.4em', md: '1em' } }} />
|
|
230
225
|
</Button>
|
|
231
226
|
</>
|
|
232
227
|
);
|
|
@@ -234,22 +229,8 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
234
229
|
|
|
235
230
|
MlFollowGps.defaultProps = {
|
|
236
231
|
mapId: undefined,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
minHeight: "30px",
|
|
240
|
-
width: "30px",
|
|
241
|
-
height: "30px",
|
|
242
|
-
backgroundColor: "#414141",
|
|
243
|
-
borderRadius: "23%",
|
|
244
|
-
margin: 0.15,
|
|
245
|
-
fontSize: "1.3em",
|
|
246
|
-
":hover": {
|
|
247
|
-
backgroundColor: "#515151",
|
|
248
|
-
color: "#ececec",
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
onColor: "#ececec",
|
|
252
|
-
offColor: "#666",
|
|
232
|
+
onColor: '#ececec',
|
|
233
|
+
offColor: '#666',
|
|
253
234
|
showAccuracyCircle: true,
|
|
254
235
|
showUserLocation: true,
|
|
255
236
|
showOrientation: true,
|
|
@@ -115,7 +115,7 @@ const MlGeoJsonLayer = (props: MlGeoJsonLayerProps) => {
|
|
|
115
115
|
layout: props.layout || {},
|
|
116
116
|
...props.options,
|
|
117
117
|
type: layerType as LayerSpecification['type'],
|
|
118
|
-
}
|
|
118
|
+
} as Partial<LayerSpecification>,
|
|
119
119
|
insertBeforeLayer: props.insertBeforeLayer,
|
|
120
120
|
onHover: props.onHover,
|
|
121
121
|
onClick: props.onClick,
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import { LayerSpecification, RasterLayerSpecification } from 'maplibre-gl';
|
|
2
|
+
|
|
3
|
+
const getDefaultPaintPropsByType = (
|
|
4
|
+
type: string,
|
|
5
|
+
defaultPaintOverrides?: { [key: string]: unknown }
|
|
6
|
+
): Exclude<LayerSpecification['paint'], RasterLayerSpecification['paint']> => {
|
|
2
7
|
switch (type) {
|
|
3
|
-
case
|
|
8
|
+
case 'fill':
|
|
4
9
|
if (defaultPaintOverrides?.fill) {
|
|
5
10
|
return defaultPaintOverrides.fill;
|
|
6
11
|
}
|
|
7
12
|
return {
|
|
8
|
-
|
|
13
|
+
'fill-color': 'rgba(10,240,256,0.6)',
|
|
9
14
|
};
|
|
10
|
-
case
|
|
15
|
+
case 'line':
|
|
11
16
|
if (defaultPaintOverrides?.line) {
|
|
12
17
|
return defaultPaintOverrides.line;
|
|
13
18
|
}
|
|
14
19
|
return {
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
'line-color': 'rgb(203,211,2)',
|
|
21
|
+
'line-width': 5,
|
|
22
|
+
'line-blur': 0,
|
|
17
23
|
};
|
|
18
|
-
case
|
|
24
|
+
case 'circle':
|
|
19
25
|
default:
|
|
20
26
|
if (defaultPaintOverrides?.circle) {
|
|
21
27
|
return defaultPaintOverrides.circle;
|
|
22
28
|
}
|
|
23
29
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
'circle-color': 'rgba(10,240,256,0.8)',
|
|
31
|
+
'circle-stroke-color': '#fff',
|
|
32
|
+
'circle-stroke-width': 2,
|
|
27
33
|
};
|
|
28
34
|
}
|
|
29
35
|
};
|
|
@@ -47,8 +47,8 @@ const Template = () => {
|
|
|
47
47
|
|
|
48
48
|
return (
|
|
49
49
|
<>
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
<MlGpxViewerInstructions open={guide} />
|
|
51
|
+
<MlGpxDemoLoader open={demoLoaderOpen} setOpen={setDemoLoaderOpen} setGpx={setGpxData} />
|
|
52
52
|
<TopToolbar appBarStyle={{ zIndex: 500 }}>
|
|
53
53
|
<Button variant="contained" onClick={handleClick2} sx={{ marginRight: '10px' }}>
|
|
54
54
|
Guide me through
|
|
@@ -57,8 +57,7 @@ const Template = () => {
|
|
|
57
57
|
Demo Mode
|
|
58
58
|
</Button>
|
|
59
59
|
</TopToolbar>
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
|
|
62
61
|
<div
|
|
63
62
|
style={{
|
|
64
63
|
position: 'fixed',
|
|
@@ -73,12 +72,7 @@ const Template = () => {
|
|
|
73
72
|
<UploadButton
|
|
74
73
|
setData={setGpxData}
|
|
75
74
|
buttonComponent={
|
|
76
|
-
<IconButton
|
|
77
|
-
style={{
|
|
78
|
-
backgroundColor: 'rgba(255,255,255,1)',
|
|
79
|
-
}}
|
|
80
|
-
size="large"
|
|
81
|
-
>
|
|
75
|
+
<IconButton size="large">
|
|
82
76
|
<FileCopy />
|
|
83
77
|
</IconButton>
|
|
84
78
|
}
|
|
@@ -87,9 +81,6 @@ const Template = () => {
|
|
|
87
81
|
onClick={() => {
|
|
88
82
|
setMetadataDrawerOpen((prevState) => !prevState);
|
|
89
83
|
}}
|
|
90
|
-
style={{
|
|
91
|
-
backgroundColor: 'rgba(255,255,255,1)',
|
|
92
|
-
}}
|
|
93
84
|
size="large"
|
|
94
85
|
>
|
|
95
86
|
<InfoIcon />
|
|
@@ -19,6 +19,7 @@ const modalStyle = {
|
|
|
19
19
|
width: 350,
|
|
20
20
|
height: 280,
|
|
21
21
|
bgcolor: 'background.paper',
|
|
22
|
+
color: 'text.primary',
|
|
22
23
|
boxShadow: 24,
|
|
23
24
|
p: 4,
|
|
24
25
|
};
|
|
@@ -30,6 +31,7 @@ const mobileStyle = {
|
|
|
30
31
|
width: 200,
|
|
31
32
|
height: 300,
|
|
32
33
|
bgcolor: 'background.paper',
|
|
34
|
+
color: 'text.primary',
|
|
33
35
|
boxShadow: 24,
|
|
34
36
|
p: 4,
|
|
35
37
|
};
|
|
@@ -101,7 +103,7 @@ const MlGpxDemoLoader = (props: MlGpxDemoLoaderProps) => {
|
|
|
101
103
|
</Grid>
|
|
102
104
|
<Grid item xs={2}>
|
|
103
105
|
<Button onClick={handleClose}>
|
|
104
|
-
<CloseIcon sx={{ color: '
|
|
106
|
+
<CloseIcon sx={{ color: 'text.primary' }} />
|
|
105
107
|
</Button>
|
|
106
108
|
</Grid>
|
|
107
109
|
</Grid>
|
|
@@ -3,7 +3,7 @@ import React, { useContext, useCallback, useRef, useEffect, useState, useMemo }
|
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import syncMove from '@mapbox/mapbox-gl-sync-move';
|
|
5
5
|
import './style.css';
|
|
6
|
-
import MapContext from '../../contexts/MapContext';
|
|
6
|
+
import MapContext, { MapContextType } from '../../contexts/MapContext';
|
|
7
7
|
|
|
8
8
|
export interface MlLayerMagnifyProps {
|
|
9
9
|
/**
|
|
@@ -34,10 +34,10 @@ const MlLayerMagnify = (props: MlLayerMagnifyProps) => {
|
|
|
34
34
|
const syncMoveInitializedRef = useRef(false);
|
|
35
35
|
const syncCleanupFunctionRef = useRef(() => {});
|
|
36
36
|
|
|
37
|
-
const [swipeX, setSwipeX] = useState(
|
|
38
|
-
const swipeXRef = useRef(
|
|
39
|
-
const [swipeY, setSwipeY] = useState(
|
|
40
|
-
const swipeYRef = useRef(
|
|
37
|
+
const [swipeX, setSwipeX] = useState(50);
|
|
38
|
+
const swipeXRef = useRef(50);
|
|
39
|
+
const [swipeY, setSwipeY] = useState(50);
|
|
40
|
+
const swipeYRef = useRef(50);
|
|
41
41
|
|
|
42
42
|
const magnifierRadius = useMemo(() => {
|
|
43
43
|
return props.magnifierRadius || 200;
|
|
@@ -60,7 +60,7 @@ const MlLayerMagnify = (props: MlLayerMagnifyProps) => {
|
|
|
60
60
|
onMove({
|
|
61
61
|
clientX: swipeXRef.current,
|
|
62
62
|
clientY: swipeYRef.current,
|
|
63
|
-
});
|
|
63
|
+
} as (TouchEvent & MouseEvent));
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
useEffect(() => {
|
|
@@ -74,25 +74,25 @@ const MlLayerMagnify = (props: MlLayerMagnifyProps) => {
|
|
|
74
74
|
}, []);
|
|
75
75
|
|
|
76
76
|
const onMove = useCallback(
|
|
77
|
-
(e) => {
|
|
77
|
+
(e:(TouchEvent & MouseEvent)) => {
|
|
78
78
|
if (!mapExists()) return;
|
|
79
79
|
|
|
80
80
|
const bounds = mapContext.maps[props.map1Id].getCanvas().getBoundingClientRect();
|
|
81
81
|
let clientX =
|
|
82
|
-
e
|
|
83
|
-
(typeof e
|
|
84
|
-
? e
|
|
82
|
+
e?.clientX ||
|
|
83
|
+
(typeof e?.touches !== 'undefined' && typeof e?.touches[0] !== 'undefined'
|
|
84
|
+
? e?.touches[0].clientX
|
|
85
85
|
: 0);
|
|
86
86
|
let clientY =
|
|
87
|
-
e
|
|
87
|
+
e?.clientY ||
|
|
88
88
|
(typeof e.touches !== 'undefined' && typeof e.touches[0] !== 'undefined'
|
|
89
89
|
? e.touches[0].clientY
|
|
90
90
|
: 0);
|
|
91
91
|
|
|
92
92
|
clientX -= bounds.x;
|
|
93
93
|
clientY -= bounds.y;
|
|
94
|
-
const swipeX_tmp = ((clientX / bounds.width) * 100).toFixed(2);
|
|
95
|
-
const swipeY_tmp = ((clientY / bounds.height) * 100).toFixed(2);
|
|
94
|
+
const swipeX_tmp = parseFloat(((clientX / bounds.width) * 100).toFixed(2));
|
|
95
|
+
const swipeY_tmp = parseFloat(((clientY / bounds.height) * 100).toFixed(2));
|
|
96
96
|
|
|
97
97
|
if (swipeXRef.current !== swipeX_tmp || swipeYRef.current !== swipeY_tmp) {
|
|
98
98
|
setSwipeX(swipeX_tmp);
|
|
@@ -102,9 +102,9 @@ const MlLayerMagnify = (props: MlLayerMagnifyProps) => {
|
|
|
102
102
|
|
|
103
103
|
mapContext.maps[props.map2Id].getContainer().style.clipPath =
|
|
104
104
|
`circle(${magnifierRadius}px at ` +
|
|
105
|
-
(
|
|
105
|
+
(swipeXRef.current * bounds.width) / 100 +
|
|
106
106
|
'px ' +
|
|
107
|
-
(
|
|
107
|
+
(swipeYRef.current * bounds.height) / 100 +
|
|
108
108
|
'px)';
|
|
109
109
|
}
|
|
110
110
|
},
|
|
@@ -120,6 +120,10 @@ const MlLayerMagnify = (props: MlLayerMagnifyProps) => {
|
|
|
120
120
|
mapContext.getMap(props.map2Id).map
|
|
121
121
|
);
|
|
122
122
|
|
|
123
|
+
onMove({
|
|
124
|
+
clientX: swipeXRef.current,
|
|
125
|
+
clientY: swipeYRef.current,
|
|
126
|
+
} as (TouchEvent & MouseEvent));
|
|
123
127
|
/*
|
|
124
128
|
automatically adjust radius for small screens
|
|
125
129
|
if (
|
|
@@ -150,7 +154,7 @@ const MlLayerMagnify = (props: MlLayerMagnifyProps) => {
|
|
|
150
154
|
onMove({
|
|
151
155
|
clientX: mapContext.maps[props.map1Id].getCanvas().clientWidth / 2,
|
|
152
156
|
clientY: mapContext.maps[props.map1Id].getCanvas().clientHeight / 2,
|
|
153
|
-
});
|
|
157
|
+
} as (TouchEvent & MouseEvent));
|
|
154
158
|
}, [mapContext.mapIds, mapContext, mapExists, props, onMove]);
|
|
155
159
|
|
|
156
160
|
const onDown = (e: React.MouseEvent | React.TouchEvent) => {
|
|
@@ -175,7 +179,7 @@ const MlLayerMagnify = (props: MlLayerMagnifyProps) => {
|
|
|
175
179
|
|
|
176
180
|
const onWheel = (e: React.WheelEvent) => {
|
|
177
181
|
const evCopy = new WheelEvent(e.type, e as unknown as WheelEventInit);
|
|
178
|
-
mapContext.map.getCanvas().dispatchEvent(evCopy);
|
|
182
|
+
mapContext.map?.map.getCanvas().dispatchEvent(evCopy);
|
|
179
183
|
};
|
|
180
184
|
|
|
181
185
|
return (
|
|
@@ -3,7 +3,7 @@ import React, { useContext, useCallback, useRef, useEffect, useState } from 'rea
|
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import syncMove from '@mapbox/mapbox-gl-sync-move';
|
|
5
5
|
import './style.css';
|
|
6
|
-
import MapContext from '../../contexts/MapContext';
|
|
6
|
+
import MapContext, { MapContextType } from '../../contexts/MapContext';
|
|
7
7
|
|
|
8
8
|
export interface MlLayerSwipeProps {
|
|
9
9
|
/**
|
|
@@ -48,7 +48,7 @@ const MlLayerSwipe = (props: MlLayerSwipeProps) => {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const onMove = useCallback(
|
|
51
|
-
(e) => {
|
|
51
|
+
(e:(TouchEvent & MouseEvent)) => {
|
|
52
52
|
if (!mapExists()) return;
|
|
53
53
|
|
|
54
54
|
const bounds = mapContext.maps[props.map1Id].getCanvas().getBoundingClientRect();
|
|
@@ -87,7 +87,7 @@ const MlLayerSwipe = (props: MlLayerSwipeProps) => {
|
|
|
87
87
|
);
|
|
88
88
|
onMove({
|
|
89
89
|
clientX: mapContext.maps[props.map1Id].getCanvas().clientWidth / 2,
|
|
90
|
-
});
|
|
90
|
+
} as (TouchEvent & MouseEvent));
|
|
91
91
|
}, [mapContext.mapIds, mapContext, props, onMove, mapExists]);
|
|
92
92
|
|
|
93
93
|
const onDown = (e: React.MouseEvent | React.TouchEvent) => {
|
|
@@ -7,7 +7,7 @@ import BuildIcon from "@mui/icons-material/Build";
|
|
|
7
7
|
import Button from "@mui/material/Button";
|
|
8
8
|
|
|
9
9
|
const storyoptions = {
|
|
10
|
-
title:
|
|
10
|
+
title: 'MapComponents/MlNavigationTools',
|
|
11
11
|
component: MlNavigationTools,
|
|
12
12
|
argTypes: {
|
|
13
13
|
url: {},
|
|
@@ -18,7 +18,6 @@ const storyoptions = {
|
|
|
18
18
|
export default storyoptions;
|
|
19
19
|
|
|
20
20
|
const Template = (args) => <MlNavigationTools {...args} />;
|
|
21
|
-
|
|
22
21
|
export const DefaultConfig = Template.bind({});
|
|
23
22
|
DefaultConfig.parameters = {};
|
|
24
23
|
DefaultConfig.args = {};
|
|
@@ -39,7 +38,7 @@ ShowCenterLocationButton.args = {
|
|
|
39
38
|
export const AlterToolPosition = Template.bind({});
|
|
40
39
|
AlterToolPosition.parameters = {};
|
|
41
40
|
AlterToolPosition.args = {
|
|
42
|
-
sx: { top:
|
|
41
|
+
sx: { top: '10px', right: '5px' },
|
|
43
42
|
};
|
|
44
43
|
|
|
45
44
|
export const NoZoomButtons = Template.bind({});
|
|
@@ -58,8 +57,8 @@ export const CustomButton = Template.bind({});
|
|
|
58
57
|
CustomButton.parameters = {};
|
|
59
58
|
CustomButton.args = {
|
|
60
59
|
children: (
|
|
61
|
-
<Button onClick={() => {}}>
|
|
62
|
-
<BuildIcon sx={{ fontSize:
|
|
60
|
+
<Button variant="navtools" onClick={() => {}}>
|
|
61
|
+
<BuildIcon sx={{ fontSize: { xs: '1.4em', md: '1em' } }} />
|
|
63
62
|
</Button>
|
|
64
63
|
),
|
|
65
64
|
};
|
|
@@ -46,11 +46,16 @@ interface MlNavigationToolsProps {
|
|
|
46
46
|
* Style attribute for NavigationTools container
|
|
47
47
|
*/
|
|
48
48
|
sx?: SxProps;
|
|
49
|
+
/**
|
|
50
|
+
* Style attribute for NavigationTools container
|
|
51
|
+
*/
|
|
52
|
+
mediaIsMobile?: boolean;
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
/**
|
|
52
56
|
* @component
|
|
53
57
|
*/
|
|
58
|
+
|
|
54
59
|
const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
55
60
|
const mapHook = useMap({
|
|
56
61
|
mapId: props.mapId,
|
|
@@ -58,32 +63,13 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
58
63
|
});
|
|
59
64
|
|
|
60
65
|
const [pitch, setPitch] = useState(0);
|
|
61
|
-
const mediaIsMobile = useMediaQuery(
|
|
62
|
-
const buttonStyle = {
|
|
63
|
-
minWidth: "20px",
|
|
64
|
-
minHeight: "20px",
|
|
65
|
-
width: mediaIsMobile ? "50px" : "30px",
|
|
66
|
-
height: mediaIsMobile ? "50px" : "30px",
|
|
67
|
-
backgroundColor: "#414141",
|
|
68
|
-
borderRadius: "23%",
|
|
69
|
-
//border: "1px solid #bbb",
|
|
70
|
-
//boxShadow: "0px 0px 4px rgba(0,0,0,.5)",
|
|
71
|
-
margin: 0.15,
|
|
72
|
-
fontSize: mediaIsMobile ? "1.4em" : "1.2em",
|
|
73
|
-
":hover": {
|
|
74
|
-
backgroundColor: "#515151",
|
|
75
|
-
},
|
|
76
|
-
color: "#ececec",
|
|
77
|
-
};
|
|
78
|
-
const iconStyle = {
|
|
79
|
-
fontSize: buttonStyle.fontSize,
|
|
80
|
-
};
|
|
66
|
+
const mediaIsMobile = useMediaQuery('(max-width:900px)');
|
|
81
67
|
|
|
82
68
|
useEffect(() => {
|
|
83
69
|
if (!mapHook.map) return;
|
|
84
70
|
|
|
85
71
|
mapHook.map.on(
|
|
86
|
-
|
|
72
|
+
'pitchend',
|
|
87
73
|
() => {
|
|
88
74
|
if (!mapHook.map) return;
|
|
89
75
|
|
|
@@ -124,63 +110,53 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
124
110
|
<Box
|
|
125
111
|
sx={{
|
|
126
112
|
zIndex: 501,
|
|
127
|
-
position:
|
|
128
|
-
display:
|
|
129
|
-
flexDirection:
|
|
130
|
-
...(mediaIsMobile ? { margin:
|
|
113
|
+
position: 'absolute',
|
|
114
|
+
display: 'flex',
|
|
115
|
+
flexDirection: 'column',
|
|
116
|
+
...(mediaIsMobile ? { margin: '20px 10px 20px 10px' } : {}),
|
|
131
117
|
...props.sx,
|
|
132
118
|
}}
|
|
133
119
|
>
|
|
134
120
|
<MlNavigationCompass
|
|
135
121
|
style={{
|
|
136
|
-
width:
|
|
137
|
-
position:
|
|
138
|
-
height: mediaIsMobile ?
|
|
139
|
-
marginLeft: mediaIsMobile ?
|
|
140
|
-
transform: mediaIsMobile ?
|
|
122
|
+
width: '31px',
|
|
123
|
+
position: 'relative',
|
|
124
|
+
height: mediaIsMobile ? '55px' : '45px',
|
|
125
|
+
marginLeft: mediaIsMobile ? '3px' : '-5px',
|
|
126
|
+
transform: mediaIsMobile ? 'scale(1.6)' : 'scale(1)',
|
|
141
127
|
}}
|
|
142
128
|
backgroundStyle={{
|
|
143
|
-
boxShadow:
|
|
129
|
+
boxShadow: '0px 0px 18px rgba(0,0,0,.5)',
|
|
144
130
|
}}
|
|
145
131
|
/>
|
|
146
132
|
{props.show3DButton && (
|
|
147
|
-
<Button
|
|
148
|
-
|
|
149
|
-
onClick={adjustPitch}
|
|
150
|
-
>
|
|
151
|
-
{pitch ? "2D" : "3D"}
|
|
133
|
+
<Button variant="navtools" onClick={adjustPitch}>
|
|
134
|
+
{pitch ? '2D' : '3D'}
|
|
152
135
|
</Button>
|
|
153
136
|
)}
|
|
154
|
-
{props.showFollowGpsButton &&
|
|
155
|
-
|
|
156
|
-
)}
|
|
157
|
-
{props.showCenterLocationButton && (
|
|
158
|
-
<MlCenterPosition style={{ ...(({ color, ...rest }) => rest)(buttonStyle) }} />
|
|
159
|
-
)}
|
|
137
|
+
{props.showFollowGpsButton && <MlFollowGps />}
|
|
138
|
+
{props.showCenterLocationButton && <MlCenterPosition />}
|
|
160
139
|
<ButtonGroup
|
|
161
140
|
orientation="vertical"
|
|
162
141
|
sx={{
|
|
163
|
-
width:
|
|
164
|
-
border:
|
|
165
|
-
Button: { minWidth:
|
|
166
|
-
|
|
142
|
+
width: '50px',
|
|
143
|
+
border: 'none',
|
|
144
|
+
Button: { minWidth: '20px !important', border: 'none', padding: 0 },
|
|
145
|
+
'Button:hover': { border: 'none' },
|
|
167
146
|
}}
|
|
168
147
|
>
|
|
169
148
|
{props.showZoomButtons && (
|
|
170
149
|
<>
|
|
171
|
-
<Button
|
|
172
|
-
<ControlPointIcon sx={{
|
|
150
|
+
<Button variant="navtools" onClick={zoomIn}>
|
|
151
|
+
<ControlPointIcon sx={{ fontSize: { xs: '1.4em', md: '1em' } }} />
|
|
173
152
|
</Button>
|
|
174
|
-
<Button
|
|
175
|
-
<RemoveCircleOutlineIcon sx={{
|
|
153
|
+
<Button variant="navtools" onClick={zoomOut}>
|
|
154
|
+
<RemoveCircleOutlineIcon sx={{ fontSize: { xs: '1.4em', md: '1em' } }} />
|
|
176
155
|
</Button>
|
|
177
156
|
</>
|
|
178
157
|
)}
|
|
179
158
|
</ButtonGroup>
|
|
180
|
-
{props.children &&
|
|
181
|
-
React.cloneElement(props.children, {
|
|
182
|
-
sx: { ...buttonStyle },
|
|
183
|
-
})}
|
|
159
|
+
{props.children && React.cloneElement(props.children, {})}
|
|
184
160
|
</Box>
|
|
185
161
|
);
|
|
186
162
|
};
|