@mapcomponents/react-maplibre 0.1.61 → 0.1.63
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/.eslintrc.js +8 -1
- package/.storybook/main.js +0 -1
- package/.storybook/preview.js +0 -2
- package/CHANGELOG.md +23 -0
- package/coverage/clover.xml +265 -89
- package/coverage/coverage-final.json +14 -6
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +84 -39
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
- 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 +148 -0
- package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +2 -8
- package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +22 -7
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +73 -40
- 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/MlGPXViewer/MlGPXViewer.tsx.html +9 -3
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +59 -29
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js.html +652 -0
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js.html +649 -0
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/index.html +131 -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/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 +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +1 -1
- 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 +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/MlSketchTool/MlSketchTool.tsx.html +898 -0
- package/coverage/lcov-report/src/components/MlSketchTool/index.html +116 -0
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.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/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +1 -1
- 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 +11 -11
- 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 +14 -14
- package/coverage/lcov-report/src/hooks/useExportMap/index.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/lib.ts.html +21 -108
- 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/useMap.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useMapState.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useSource.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +5 -2
- package/coverage/lcov.info +564 -161
- 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 +3 -3
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.cy.d.ts +1 -0
- package/dist/components/MlCreatePdfForm/MlCreatePdfForm.stories.d.ts +1 -0
- package/dist/components/MlCreatePdfForm/lib/PdfContext.d.ts +3 -16
- package/dist/components/MlCreatePdfForm/lib/PdfPreview.d.ts +19 -6
- package/dist/components/MlCreatePdfForm/lib/_PdfPreview.d.ts +13 -0
- 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/MlGPXViewer/util/GeoJsonContext.d.ts +1 -1
- package/dist/components/MlGPXViewer/util/MlGPXViewerInstructions.d.ts +1 -0
- package/dist/components/MlGPXViewer/util/SampleLayer.d.ts +0 -0
- package/dist/components/MlGPXViewer/util/demoViewer.d.ts +5 -0
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +4 -4
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +103 -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/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/contexts/SimpleDataProvider.d.ts +1 -1
- package/dist/custom.d.d.ts +1 -1
- package/dist/hooks/useLayer.d.ts +1 -1
- package/dist/hooks/useMap.d.ts +1 -1
- package/dist/hooks/useMapState.d.ts +3 -3
- package/dist/hooks/useSource.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +3473 -4386
- package/dist/index.esm.js.map +1 -1
- package/dist/ui_components/LoadingOverlayContext.d.ts +1 -1
- package/dist/ui_components/Sidebar.d.ts +9 -1
- package/dist/ui_components/TopToolbar.d.ts +6 -1
- package/package.json +22 -15
- package/public/assets/sample1.gpx +3003 -0
- package/public/assets/sample2.gpx +1264 -0
- package/public/assets/sample3.gpx +912 -0
- package/public/index.html +0 -4
- package/public/thumbnails/MlSketchTool.png +0 -0
- package/public/thumbnails/useCameraFollowPath.png +0 -0
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx +21 -0
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.stories.tsx +14 -1
- package/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx +0 -2
- package/src/components/MlCreatePdfForm/lib/PdfContext.tsx +16 -18
- package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +79 -6
- package/src/components/MlCreatePdfForm/lib/PdfPreview.tsx +285 -357
- package/src/components/MlCreatePdfForm/lib/_PdfPreview.tsx +399 -0
- package/src/components/MlCreatePdfForm/lib/pdfContext.d.ts +24 -0
- package/src/components/MlCreatePdfForm/lib/preview.css +114 -0
- package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +1 -1
- package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +39 -28
- package/src/components/MlGPXViewer/MlGPXViewer.stories.js +75 -15
- package/src/components/MlGPXViewer/MlGPXViewer.tsx +3 -1
- package/src/components/MlGPXViewer/util/MlGPXViewerInstructions.js +145 -0
- package/src/components/MlGPXViewer/util/SampleLayer.js +2 -0
- package/src/components/MlGPXViewer/util/demoViewer.js +254 -0
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.tsx +102 -0
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +33 -23
- package/src/components/MlGeoJsonLayer/assets/sample_1.json +138 -24
- package/src/components/MlGeoJsonLayer/assets/sample_2.json +140 -20
- 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/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 +15 -0
- package/src/components/MlSketchTool/MlSketchTool.stories.js +26 -0
- package/src/components/MlSketchTool/MlSketchTool.tsx +271 -0
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.meta.json +2 -2
- package/src/hooks/useExportMap/lib.ts +14 -43
- package/src/index.ts +1 -0
- package/src/ui_components/Sidebar.tsx +80 -0
- package/src/ui_components/TopToolbar.tsx +24 -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/scripts/start.js +0 -166
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +0 -66
- package/src/ui_components/Sidebar.js +0 -100
- package/src/ui_components/TopToolbar.js +0 -29
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import MlGPXViewer from './MlGPXViewer';
|
|
3
|
+
import mapContextDecorator from '../../decorators/MapContextDecorator';
|
|
4
|
+
import GeoJsonProvider from './util/GeoJsonProvider';
|
|
5
|
+
import MlGPXViewerInstructions from './util/MlGPXViewerInstructions';
|
|
6
|
+
import TopToolbar from '../../ui_components/TopToolbar';
|
|
7
|
+
import { Button, IconButton } from '@mui/material';
|
|
8
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
9
|
+
import MlGPXDemoLoader from './util/demoViewer';
|
|
10
|
+
import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
|
7
11
|
|
|
8
12
|
const storyoptions = {
|
|
9
|
-
title:
|
|
13
|
+
title: 'MapComponents/MlGPXViewer',
|
|
10
14
|
component: MlGPXViewer,
|
|
11
15
|
argTypes: {
|
|
12
16
|
options: {
|
|
13
17
|
control: {
|
|
14
|
-
type:
|
|
18
|
+
type: 'object',
|
|
15
19
|
},
|
|
16
20
|
},
|
|
17
21
|
},
|
|
@@ -19,13 +23,69 @@ const storyoptions = {
|
|
|
19
23
|
};
|
|
20
24
|
export default storyoptions;
|
|
21
25
|
|
|
22
|
-
const Template = (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
26
|
+
const Template = () => {
|
|
27
|
+
const mediaIsMobile = useMediaQuery('(max-width:900px)');
|
|
28
|
+
const [demoMode, setDemoMode] = useState(false);
|
|
29
|
+
const [guide, setGuide] = useState(false);
|
|
30
|
+
|
|
31
|
+
const handleClick1 = () => {
|
|
32
|
+
setDemoMode(!demoMode);
|
|
33
|
+
|
|
34
|
+
};
|
|
35
|
+
const handleClick2 = ()=>{
|
|
36
|
+
setGuide(true);
|
|
37
|
+
setTimeout(()=>{
|
|
38
|
+
setGuide(false)
|
|
39
|
+
}, 9000);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const textColor = () =>{
|
|
43
|
+
if(demoMode){
|
|
44
|
+
return "white"
|
|
45
|
+
} else {
|
|
46
|
+
return "steelblue"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const textColor2 = () =>{
|
|
51
|
+
if(guide){
|
|
52
|
+
return "white"
|
|
53
|
+
} else {
|
|
54
|
+
return "steelblue"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
<TopToolbar>
|
|
61
|
+
<MlGPXViewerInstructions open={guide} />
|
|
62
|
+
<Button variant="contained" onClick={handleClick2} color={guide ? "primary" : "inherit"} sx={{ color: textColor2, marginRight: '10px' }}> Guide me through</Button>
|
|
63
|
+
<Button variant="contained" onClick={handleClick1} color={demoMode ? "primary" : "inherit"} sx={{ color: textColor }}>
|
|
64
|
+
Demo Mode
|
|
65
|
+
</Button>
|
|
66
|
+
</TopToolbar>
|
|
67
|
+
<IconButton
|
|
68
|
+
style={{
|
|
69
|
+
position: 'absolute',
|
|
70
|
+
right: '5px',
|
|
71
|
+
bottom: mediaIsMobile ? '145px' : '130px',
|
|
72
|
+
backgroundColor: 'rgba(255,255,255,1)',
|
|
73
|
+
zIndex: 1000,
|
|
74
|
+
}}
|
|
75
|
+
title="Download sample-data"
|
|
76
|
+
size="large"
|
|
77
|
+
href="assets/sample.gpx"
|
|
78
|
+
target="blank"
|
|
79
|
+
>
|
|
80
|
+
<FileDownloadIcon />
|
|
81
|
+
</IconButton>
|
|
82
|
+
<GeoJsonProvider>
|
|
83
|
+
<MlGPXDemoLoader enabled={demoMode} />
|
|
84
|
+
<MlGPXViewer />
|
|
85
|
+
</GeoJsonProvider>
|
|
86
|
+
</>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
29
89
|
|
|
30
90
|
export const ExampleConfig = Template.bind({});
|
|
31
91
|
ExampleConfig.parameters = {};
|
|
@@ -233,7 +233,7 @@ const MlGPXViewer = (props:MlGPXViewerProps) => {
|
|
|
233
233
|
if (node.nodeName === "link") {
|
|
234
234
|
value = node.getAttribute("href");
|
|
235
235
|
}
|
|
236
|
-
if (
|
|
236
|
+
if (value?.trim().length) {
|
|
237
237
|
const metaDatEntry = {
|
|
238
238
|
title: title,
|
|
239
239
|
value: value,
|
|
@@ -278,6 +278,8 @@ const MlGPXViewer = (props:MlGPXViewerProps) => {
|
|
|
278
278
|
|
|
279
279
|
fileupload.current.click();
|
|
280
280
|
};
|
|
281
|
+
|
|
282
|
+
|
|
281
283
|
return (
|
|
282
284
|
<>
|
|
283
285
|
<div
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Grid } from '@mui/material';
|
|
3
|
+
import ReplyAllIcon from '@mui/icons-material/ReplyAll';
|
|
4
|
+
import Fade from '@mui/material/Fade';
|
|
5
|
+
|
|
6
|
+
const divStyle = {
|
|
7
|
+
width: 450,
|
|
8
|
+
height: 450,
|
|
9
|
+
position: 'fixed',
|
|
10
|
+
//right: '5px',
|
|
11
|
+
//bottom: '25px',
|
|
12
|
+
display: 'block',
|
|
13
|
+
flexDirection: 'column',
|
|
14
|
+
gap: '5px',
|
|
15
|
+
zIndex: 900,
|
|
16
|
+
borderRadius: 360,
|
|
17
|
+
right: -120,
|
|
18
|
+
bottom: -120,
|
|
19
|
+
backgroundColor: 'steelblue',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default function MlGPXViewerInstructions(props) {
|
|
24
|
+
const [step1, setStep1] = useState(false);
|
|
25
|
+
const [step2, setStep2] = useState(false);
|
|
26
|
+
const [step3, setStep3] = useState(false);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (props.open) {
|
|
30
|
+
setStep1(true);
|
|
31
|
+
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
setStep2(true);
|
|
34
|
+
setStep1(false);
|
|
35
|
+
}, 2500);
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
setStep3(true);
|
|
38
|
+
}, 5000);
|
|
39
|
+
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
setStep2(false);
|
|
42
|
+
}, 5000);
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
setStep3(false);
|
|
45
|
+
props.callback(false);
|
|
46
|
+
}, 9000);
|
|
47
|
+
} else {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
}, [props.open]);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
{step1 && (
|
|
55
|
+
<Fade in={step1} timeout={150}>
|
|
56
|
+
<div style={divStyle} >
|
|
57
|
+
<h2 style={{ marginTop: 100, marginLeft: 100, color: 'white', textAlign: 'left' }}>
|
|
58
|
+
You can load your <br />
|
|
59
|
+
own GPX file <br /> here
|
|
60
|
+
</h2>
|
|
61
|
+
<ReplyAllIcon
|
|
62
|
+
sx={{
|
|
63
|
+
color: 'white',
|
|
64
|
+
fontSize: 80,
|
|
65
|
+
transform: 'rotate(180deg)',
|
|
66
|
+
marginTop: -3,
|
|
67
|
+
marginLeft: 22,
|
|
68
|
+
}}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
</Fade>
|
|
72
|
+
)}
|
|
73
|
+
|
|
74
|
+
{step2 && (
|
|
75
|
+
<Fade in={step2} timeout={150}>
|
|
76
|
+
<div style={divStyle}>
|
|
77
|
+
<Grid>
|
|
78
|
+
<h2 style={{ marginTop: 100, marginLeft: 100, color: 'white', textAlign: 'left' }}>
|
|
79
|
+
You can see more <br /> information about <br />
|
|
80
|
+
the track <br />
|
|
81
|
+
here
|
|
82
|
+
</h2>
|
|
83
|
+
</Grid>
|
|
84
|
+
|
|
85
|
+
<Grid>
|
|
86
|
+
<ReplyAllIcon
|
|
87
|
+
sx={{
|
|
88
|
+
color: 'white',
|
|
89
|
+
fontSize: 80,
|
|
90
|
+
transform: 'rotate(180deg)',
|
|
91
|
+
marginTop: 1,
|
|
92
|
+
marginLeft: 22,
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
</Grid>
|
|
96
|
+
</div>
|
|
97
|
+
</Fade>
|
|
98
|
+
)}
|
|
99
|
+
{step3 && (
|
|
100
|
+
<Fade in={step3} timeout={1500}>
|
|
101
|
+
<div
|
|
102
|
+
style={{
|
|
103
|
+
width: 450,
|
|
104
|
+
height: 450,
|
|
105
|
+
position: 'fixed',
|
|
106
|
+
//left: '5px',
|
|
107
|
+
//top: '25px',
|
|
108
|
+
display: 'block',
|
|
109
|
+
flexDirection: 'column',
|
|
110
|
+
gap: '5px',
|
|
111
|
+
//zIndex: 500,
|
|
112
|
+
borderRadius: 360,
|
|
113
|
+
left: -40,
|
|
114
|
+
top: -150,
|
|
115
|
+
backgroundColor: 'steelblue',
|
|
116
|
+
opacity: 1,
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
transition:'ease-in',
|
|
119
|
+
transitionProperty:'opacity',
|
|
120
|
+
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<Grid>
|
|
124
|
+
<h2 style={{ marginTop: 230, marginRight: 190, color: 'white', textAlign: 'right' }}>
|
|
125
|
+
In demo mode we <br /> provide you some <br /> GPX tracks <br /> to load.
|
|
126
|
+
</h2>
|
|
127
|
+
</Grid>
|
|
128
|
+
<Grid>
|
|
129
|
+
<ReplyAllIcon
|
|
130
|
+
sx={{
|
|
131
|
+
color: 'white',
|
|
132
|
+
fontSize: 80,
|
|
133
|
+
position: 'absolute',
|
|
134
|
+
transform: 'rotate(90deg)',
|
|
135
|
+
marginTop: -18,
|
|
136
|
+
marginLeft: 35,
|
|
137
|
+
}}
|
|
138
|
+
/>
|
|
139
|
+
</Grid>
|
|
140
|
+
</div>
|
|
141
|
+
</Fade>
|
|
142
|
+
)}
|
|
143
|
+
</>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import React, { useContext, useRef, useEffect, useState, useCallback } from 'react';
|
|
2
|
+
import { bbox } from '@turf/turf';
|
|
3
|
+
import Divider from '@mui/material/Divider';
|
|
4
|
+
import Typography from '@mui/material/Typography';
|
|
5
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
6
|
+
import Drawer from '@mui/material/Drawer';
|
|
7
|
+
import IconButton from '@mui/material/IconButton';
|
|
8
|
+
import Box from '@mui/material/Box';
|
|
9
|
+
import Button from '@mui/material/Button';
|
|
10
|
+
import Modal from '@mui/material/Modal';
|
|
11
|
+
import InfoIcon from '@mui/icons-material/Info';
|
|
12
|
+
import FileCopy from '@mui/icons-material/FileCopy';
|
|
13
|
+
import List from '@mui/material/List';
|
|
14
|
+
import ListItem from '@mui/material/ListItem';
|
|
15
|
+
import ListItemText from '@mui/material/ListItemText';
|
|
16
|
+
import GeoJsonContext from './GeoJsonContext';
|
|
17
|
+
import toGeoJSON from '../gpxConverter';
|
|
18
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
19
|
+
import useMap from '../../../hooks/useMap';
|
|
20
|
+
import Grid from '@mui/material/Grid';
|
|
21
|
+
import { ListItemButton } from '@mui/material';
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const modalStyle = {
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
top: '50%',
|
|
27
|
+
left: '60%',
|
|
28
|
+
width: 350,
|
|
29
|
+
height: 280,
|
|
30
|
+
bgcolor: 'background.paper',
|
|
31
|
+
boxShadow: 24,
|
|
32
|
+
p: 4,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const mobileStyle = {
|
|
36
|
+
position: 'absolute',
|
|
37
|
+
top: '30%',
|
|
38
|
+
left: '20%',
|
|
39
|
+
width: 200,
|
|
40
|
+
height: 300,
|
|
41
|
+
bgcolor: 'background.paper',
|
|
42
|
+
boxShadow: 24,
|
|
43
|
+
p: 4,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* MlSpatialElevationProfileDemoViewer returns a button to load a Demo GPX Track into the map.
|
|
48
|
+
*/
|
|
49
|
+
const MlGPXDemoLoader = (props) => {
|
|
50
|
+
|
|
51
|
+
const [openModal, setOpenModal] = useState(false);
|
|
52
|
+
const [infoOpen, setInfoOpen] = useState(false);
|
|
53
|
+
const [metaData, setMetaData] = useState([]);
|
|
54
|
+
const [selectedSample, setSelectedSample] = useState();
|
|
55
|
+
const mapHook = useMap({ mapId: 'map_1' });
|
|
56
|
+
const dataSource = useContext(GeoJsonContext);
|
|
57
|
+
const sourceName = 'import-source';
|
|
58
|
+
const [file, setFile] = useState();
|
|
59
|
+
const reader = useRef(new FileReader());
|
|
60
|
+
reader.current.onload = (payload) => {
|
|
61
|
+
if (!payload) return;
|
|
62
|
+
setFile(payload.currentTarget.result);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const mediaIsMobile = useMediaQuery('(max-width:900px)');
|
|
66
|
+
|
|
67
|
+
const toogleDrawer = () => {
|
|
68
|
+
setInfoOpen(!infoOpen);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const handleClick = () => {
|
|
72
|
+
setOpenModal(true);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const handleSelect = (e) => {
|
|
76
|
+
|
|
77
|
+
if (e.target.innerText === 'mountain_trail.gpx') {
|
|
78
|
+
setSelectedSample('assets/sample1.gpx');
|
|
79
|
+
} else if (e.target.innerText === 'bycycle_tour.gpx') {
|
|
80
|
+
setSelectedSample('assets/sample2.gpx');
|
|
81
|
+
} else {
|
|
82
|
+
setSelectedSample('assets/sample3.gpx');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
e.target.style.backgroundColor = 'lightgray';
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (!selectedSample) return;
|
|
90
|
+
fetch(selectedSample)
|
|
91
|
+
.then(function (response) {
|
|
92
|
+
return response.blob();
|
|
93
|
+
})
|
|
94
|
+
.then(function (gpx) {
|
|
95
|
+
reader.current.readAsText(gpx);
|
|
96
|
+
});
|
|
97
|
+
}, [selectedSample]);
|
|
98
|
+
|
|
99
|
+
const handleLoad = useCallback(() => {
|
|
100
|
+
addGPXToMap(file);
|
|
101
|
+
setOpenModal(false);
|
|
102
|
+
}, [file]);
|
|
103
|
+
|
|
104
|
+
const handleClose = () => {
|
|
105
|
+
setOpenModal(false);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const addGPXToMap = (gpxAsString) => {
|
|
109
|
+
if (!mapHook.map || !dataSource.setData) return;
|
|
110
|
+
try {
|
|
111
|
+
setMetaData([]);
|
|
112
|
+
const domParser = new DOMParser();
|
|
113
|
+
const gpxDoc = domParser.parseFromString(gpxAsString, 'application/xml');
|
|
114
|
+
const metadata = gpxDoc.querySelector('metadata');
|
|
115
|
+
metadata?.childNodes.forEach((node) => {
|
|
116
|
+
let value = node.textContent;
|
|
117
|
+
const title = node.nodeName;
|
|
118
|
+
|
|
119
|
+
if (node.nodeName === 'link') {
|
|
120
|
+
value = node.getAttribute('href');
|
|
121
|
+
}
|
|
122
|
+
if (value?.trim().length) {
|
|
123
|
+
const metaDatEntry = {
|
|
124
|
+
title: title,
|
|
125
|
+
value: value,
|
|
126
|
+
id: new Date().getTime(),
|
|
127
|
+
};
|
|
128
|
+
setMetaData((prevState) => [...prevState, metaDatEntry]);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const data = toGeoJSON.gpx(gpxDoc);
|
|
132
|
+
dataSource.setData(data);
|
|
133
|
+
mapHook.map.map.getSource(sourceName).setData(data);
|
|
134
|
+
const bounds = bbox(data);
|
|
135
|
+
mapHook.map.map.fitBounds(bounds);
|
|
136
|
+
} catch (e) {
|
|
137
|
+
console.log(e);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<>
|
|
143
|
+
<Modal
|
|
144
|
+
open={openModal}
|
|
145
|
+
onClose={handleClose}
|
|
146
|
+
aria-labelledby="modal-modal-title"
|
|
147
|
+
aria-describedby="modal-modal-description"
|
|
148
|
+
>
|
|
149
|
+
<Box sx={mediaIsMobile ? mobileStyle : modalStyle}>
|
|
150
|
+
<Grid container>
|
|
151
|
+
<Grid xs={10}>
|
|
152
|
+
<Typography id="modal-modal-title" variant="h6">
|
|
153
|
+
GPX demo files
|
|
154
|
+
</Typography>
|
|
155
|
+
</Grid>
|
|
156
|
+
<Grid xs={2}>
|
|
157
|
+
<Button onClick={handleClose}>
|
|
158
|
+
<CloseIcon sx={{ color: 'black' }} />
|
|
159
|
+
</Button>
|
|
160
|
+
</Grid>
|
|
161
|
+
</Grid>
|
|
162
|
+
<Divider />
|
|
163
|
+
|
|
164
|
+
<List>
|
|
165
|
+
<ListItem>
|
|
166
|
+
<ListItemButton value="sample1" onClick={handleSelect}>
|
|
167
|
+
<ListItemText> mountain_trail.gpx </ListItemText>
|
|
168
|
+
</ListItemButton>
|
|
169
|
+
</ListItem>
|
|
170
|
+
<Divider variant="inset" component="li" />
|
|
171
|
+
<ListItem>
|
|
172
|
+
<ListItemButton value="sample2" onClick={handleSelect}>
|
|
173
|
+
<ListItemText> bycycle_tour.gpx </ListItemText>
|
|
174
|
+
</ListItemButton>
|
|
175
|
+
</ListItem>
|
|
176
|
+
<Divider variant="inset" component="li" />
|
|
177
|
+
<ListItem>
|
|
178
|
+
<ListItemButton value="sample3" onClick={handleSelect}>
|
|
179
|
+
<ListItemText>treckking.gpx </ListItemText>
|
|
180
|
+
</ListItemButton>
|
|
181
|
+
</ListItem>
|
|
182
|
+
<Divider variant="inset" component="li" />
|
|
183
|
+
</List>
|
|
184
|
+
|
|
185
|
+
<Grid>
|
|
186
|
+
<Button
|
|
187
|
+
variant="outlined"
|
|
188
|
+
onClick={handleLoad}
|
|
189
|
+
sx={{ display: 'block', marginLeft: 'auto' }}
|
|
190
|
+
>
|
|
191
|
+
Load
|
|
192
|
+
</Button>
|
|
193
|
+
</Grid>
|
|
194
|
+
</Box>
|
|
195
|
+
</Modal>
|
|
196
|
+
|
|
197
|
+
<Drawer variant="persistent" anchor="left" open={infoOpen}>
|
|
198
|
+
<Typography
|
|
199
|
+
variant="h6"
|
|
200
|
+
style={{
|
|
201
|
+
textAlign: "center",
|
|
202
|
+
padding: "1em",
|
|
203
|
+
}}
|
|
204
|
+
noWrap
|
|
205
|
+
>
|
|
206
|
+
Informationen zur Route
|
|
207
|
+
</Typography>
|
|
208
|
+
<Divider />
|
|
209
|
+
<List>
|
|
210
|
+
{metaData.map((item) => (
|
|
211
|
+
<ListItem key={`item--${item.id}`}>
|
|
212
|
+
<ListItemText primary={item.value} />
|
|
213
|
+
</ListItem>
|
|
214
|
+
))}
|
|
215
|
+
</List>
|
|
216
|
+
</Drawer>
|
|
217
|
+
|
|
218
|
+
{props.enabled && (
|
|
219
|
+
<div
|
|
220
|
+
style={{
|
|
221
|
+
position: 'fixed',
|
|
222
|
+
right: '5px',
|
|
223
|
+
bottom: mediaIsMobile ? '40px' : '25px',
|
|
224
|
+
display: 'flex',
|
|
225
|
+
flexDirection: 'column',
|
|
226
|
+
gap: '5px',
|
|
227
|
+
zIndex: 3000,
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
<IconButton
|
|
231
|
+
onClick={handleClick}
|
|
232
|
+
style={{
|
|
233
|
+
backgroundColor: '#cbd300',
|
|
234
|
+
}}
|
|
235
|
+
size="large"
|
|
236
|
+
>
|
|
237
|
+
<FileCopy />
|
|
238
|
+
</IconButton>
|
|
239
|
+
<IconButton
|
|
240
|
+
onClick={toogleDrawer}
|
|
241
|
+
style={{
|
|
242
|
+
backgroundColor: '#cbd300',
|
|
243
|
+
}}
|
|
244
|
+
size="large"
|
|
245
|
+
>
|
|
246
|
+
<InfoIcon />
|
|
247
|
+
</IconButton>
|
|
248
|
+
</div>
|
|
249
|
+
)}
|
|
250
|
+
</>
|
|
251
|
+
);
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export default MlGPXDemoLoader;
|
|
@@ -0,0 +1,102 @@
|
|
|
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 sample_geojson_1 from './assets/sample_1.json';
|
|
8
|
+
import sample_geojson_2 from './assets/sample_2.json';
|
|
9
|
+
import { GeoJSONObject } from '@turf/turf';
|
|
10
|
+
|
|
11
|
+
const storyoptions = {
|
|
12
|
+
title: 'MapComponents/MlGeoJsonLayer',
|
|
13
|
+
component: MlGeoJsonLayer,
|
|
14
|
+
|
|
15
|
+
argTypes: {},
|
|
16
|
+
|
|
17
|
+
decorators: mapContextDecorator,
|
|
18
|
+
};
|
|
19
|
+
export default storyoptions;
|
|
20
|
+
|
|
21
|
+
interface TemplateProps {
|
|
22
|
+
geojson: GeoJSONObject;
|
|
23
|
+
mapId: string;
|
|
24
|
+
type: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const Template = (props: TemplateProps) => {
|
|
28
|
+
const mapHook = useMap({
|
|
29
|
+
mapId: undefined,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const initializedRef = useRef(false);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!mapHook.map || initializedRef.current) return;
|
|
36
|
+
|
|
37
|
+
initializedRef.current = true;
|
|
38
|
+
mapHook.map.map.flyTo({ center: [7.100175528281227, 50.73487992742369], zoom: 15 });
|
|
39
|
+
}, [mapHook.map]);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<>
|
|
43
|
+
<LineStyler {...props} />
|
|
44
|
+
</>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
const PolygonTemplate = (props: TemplateProps) => {
|
|
48
|
+
const mapHook = useMap({
|
|
49
|
+
mapId: undefined,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const initializedRef = useRef(false);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!mapHook.map || initializedRef.current) return;
|
|
56
|
+
|
|
57
|
+
initializedRef.current = true;
|
|
58
|
+
mapHook.map.map.flyTo({ center: [7.100175528281227, 50.73487992742369], zoom: 15 });
|
|
59
|
+
}, [mapHook.map]);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
<PolygonStyler {...props} />
|
|
64
|
+
</>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const Linestring = Template.bind({});
|
|
69
|
+
Linestring.parameters = {};
|
|
70
|
+
Linestring.args = {
|
|
71
|
+
geojson: sample_geojson_2,
|
|
72
|
+
mapId: 'Map_1',
|
|
73
|
+
/*paint:{
|
|
74
|
+
"stroke-color": 'rgba(123,20,80)',
|
|
75
|
+
"fill-opacity": 0
|
|
76
|
+
},*/
|
|
77
|
+
type: 'line',
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const Polygon = PolygonTemplate.bind({});
|
|
81
|
+
|
|
82
|
+
Polygon.args = {
|
|
83
|
+
geojson: sample_geojson_1,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const DefaultPaintOverrides = Template.bind({});
|
|
87
|
+
DefaultPaintOverrides.parameters = {};
|
|
88
|
+
DefaultPaintOverrides.args = {
|
|
89
|
+
defaultPaintOverrides: {
|
|
90
|
+
fill: {
|
|
91
|
+
'fill-color': 'blue',
|
|
92
|
+
},
|
|
93
|
+
circle: {
|
|
94
|
+
'circle-color': 'red',
|
|
95
|
+
},
|
|
96
|
+
line: {
|
|
97
|
+
'line-color': 'black',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
geojson: sample_geojson_1,
|
|
101
|
+
type: '',
|
|
102
|
+
};
|