@mapcomponents/react-maplibre 0.1.62 → 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 +18 -0
- package/coverage/clover.xml +232 -44
- package/coverage/coverage-final.json +11 -3
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +70 -25
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/hooks/useCameraFollowPath/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useCameraFollowPath/useCameraFollowPath.tsx.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/index.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useExportMap/lib.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov.info +514 -89
- 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/lib/PdfPreview.d.ts +1 -1
- package/dist/components/MlFeatureEditor/MlFeatureEditor.d.ts +10 -4
- package/dist/components/MlFeatureEditor/lib/double_click_zoom.d.ts +0 -2
- package/dist/components/MlFeatureEditor/lib/theme.d.ts +1 -1
- package/dist/components/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.esm.css +1 -1
- package/dist/index.esm.js +2736 -3557
- 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 +21 -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 +1 -3
- package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +1 -1
- 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/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
package/public/index.html
CHANGED
|
@@ -5,10 +5,6 @@
|
|
|
5
5
|
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
7
|
<meta name="theme-color" content="#000000" />
|
|
8
|
-
<meta
|
|
9
|
-
name="description"
|
|
10
|
-
content="Web site created using create-react-app"
|
|
11
|
-
/>
|
|
12
8
|
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
13
9
|
<!--
|
|
14
10
|
manifest.json provides metadata used when your web app is installed on a
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { composeStories } from '@storybook/testing-react';
|
|
3
|
+
import { mount } from '@cypress/react';
|
|
4
|
+
import * as stories from "./MlCreatePdfForm.stories";
|
|
5
|
+
|
|
6
|
+
// compile the "Primary" story with the library
|
|
7
|
+
const {ExampleConfig } = composeStories(stories);
|
|
8
|
+
|
|
9
|
+
describe('MlCreatePdfForm Tests', () => {
|
|
10
|
+
it('Should generate and download a PDF export of the current map preview', () => {
|
|
11
|
+
// and mount the story using @cypress/react library
|
|
12
|
+
mount(<ExampleConfig />);
|
|
13
|
+
|
|
14
|
+
cy.get(".pdfFormButton").click();
|
|
15
|
+
|
|
16
|
+
cy.wait(1000)
|
|
17
|
+
cy.get(".createPdfButton").click();
|
|
18
|
+
cy.wait(2000)
|
|
19
|
+
cy.readFile("./cypress/downloads/Map.pdf").should('contain', 'WhereGroup')
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -51,14 +51,12 @@ export default storyoptions;
|
|
|
51
51
|
|
|
52
52
|
const Template = () => {
|
|
53
53
|
const [showCreatePdfForm, setShowCreatePdfForm] = useState(false);
|
|
54
|
-
const targetRef = React.useRef<HTMLDivElement>(null);
|
|
55
|
-
const containerRef = React.useRef<HTMLDivElement>(document.querySelector('.map_container'));
|
|
56
54
|
|
|
57
55
|
// <MlWmsLayer url='https://geo.stat.fi/geoserver/vaestoruutu/wms' urlParameters={{layers:'vaki2005_1km_kp'}}/>
|
|
58
56
|
return (
|
|
59
57
|
<>
|
|
60
58
|
<TopToolbar>
|
|
61
|
-
<Button variant="contained" onClick={() => setShowCreatePdfForm(!showCreatePdfForm)}>
|
|
59
|
+
<Button variant="contained" className='pdfFormButton' onClick={() => setShowCreatePdfForm(!showCreatePdfForm)}>
|
|
62
60
|
PDF
|
|
63
61
|
</Button>
|
|
64
62
|
</TopToolbar>
|
|
@@ -218,7 +218,7 @@ export default function PdfForm(props: PdfFormProps) {
|
|
|
218
218
|
</Select>
|
|
219
219
|
</FormControl>
|
|
220
220
|
<FormControl fullWidth sx={formControlStyles}>
|
|
221
|
-
<Button variant="contained" onClick={createPdfHandler}>
|
|
221
|
+
<Button variant="contained" className='createPdfButton' onClick={createPdfHandler}>
|
|
222
222
|
PDF erstellen
|
|
223
223
|
</Button>
|
|
224
224
|
</FormControl>
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from
|
|
2
|
-
import
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import './MlFeatureEditor.css';
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import MapboxDraw from
|
|
6
|
-
import CustomPolygonMode from
|
|
7
|
-
import CustomSelectMode from
|
|
8
|
-
import CustomDirectSelectMode from
|
|
4
|
+
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
|
|
5
|
+
import MapboxDraw from '@mapbox/mapbox-gl-draw';
|
|
6
|
+
import CustomPolygonMode from './custom-polygon-mode.js';
|
|
7
|
+
import CustomSelectMode from './custom-select-mode.js';
|
|
8
|
+
import CustomDirectSelectMode from './custom-direct-select-mode.js';
|
|
9
9
|
|
|
10
|
-
import useMap from
|
|
10
|
+
import useMap from '../../hooks/useMap';
|
|
11
|
+
import { GeoJSONObject, Feature } from '@turf/turf';
|
|
11
12
|
|
|
12
13
|
interface MlFeatureEditorProps {
|
|
13
14
|
/**
|
|
@@ -22,12 +23,17 @@ interface MlFeatureEditorProps {
|
|
|
22
23
|
/**
|
|
23
24
|
* Input GeoJson data at initialization
|
|
24
25
|
*/
|
|
25
|
-
geojson?:
|
|
26
|
+
geojson?: Feature;
|
|
26
27
|
/**
|
|
27
28
|
* Callback function that is called each time the GeoJson data within has changed within MlFeatureEditor.
|
|
28
29
|
* First parameter is the new GeoJson feature.
|
|
29
30
|
*/
|
|
30
|
-
onChange?:
|
|
31
|
+
onChange?: (para: GeoJSONObject[]) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Callback function that is called each time the GeoJson data within has been finished within MlFeatureEditor.
|
|
34
|
+
* First parameter is the new GeoJson feature.
|
|
35
|
+
*/
|
|
36
|
+
onFinish?: () => void;
|
|
31
37
|
/**
|
|
32
38
|
* Feature editor mode:
|
|
33
39
|
* - "custom_select" edit features
|
|
@@ -51,10 +57,15 @@ const MlFeatureEditor = (props: MlFeatureEditorProps) => {
|
|
|
51
57
|
const drawToolsInitialized = useRef(false);
|
|
52
58
|
const [drawToolsReady, setDrawToolsReady] = useState(false);
|
|
53
59
|
|
|
54
|
-
|
|
55
60
|
const modeChangeHandler = (e: any) => {
|
|
56
|
-
console.log(
|
|
61
|
+
console.log('MlFeatureEditor mode change to ' + e.mode);
|
|
57
62
|
//setDrawMode(e.mode);
|
|
63
|
+
if (
|
|
64
|
+
typeof props.onFinish === 'function' &&
|
|
65
|
+
(e.mode === 'custom_select' || e.mode === 'simple_select')
|
|
66
|
+
) {
|
|
67
|
+
props.onFinish();
|
|
68
|
+
}
|
|
58
69
|
};
|
|
59
70
|
|
|
60
71
|
useEffect(() => {
|
|
@@ -63,17 +74,19 @@ const MlFeatureEditor = (props: MlFeatureEditorProps) => {
|
|
|
63
74
|
|
|
64
75
|
if (
|
|
65
76
|
mapHook.map.map.style &&
|
|
66
|
-
mapHook.map.map.getSource(
|
|
77
|
+
mapHook.map.map.getSource('mapbox-gl-draw-cold') &&
|
|
67
78
|
draw.current
|
|
68
79
|
) {
|
|
69
80
|
// remove old Mapbox-gl-Draw from Mapbox instance when hot-reloading this component during development
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
70
82
|
// @ts-ignore
|
|
71
83
|
draw.current?.remove();
|
|
72
84
|
}
|
|
73
85
|
|
|
74
86
|
draw.current = new MapboxDraw({
|
|
75
87
|
displayControlsDefault: false,
|
|
76
|
-
defaultMode: props.mode ||
|
|
88
|
+
defaultMode: props.mode || 'custom_select',
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
77
90
|
// @ts-ignore
|
|
78
91
|
modes: Object.assign(
|
|
79
92
|
{
|
|
@@ -85,10 +98,9 @@ const MlFeatureEditor = (props: MlFeatureEditorProps) => {
|
|
|
85
98
|
),
|
|
86
99
|
});
|
|
87
100
|
|
|
88
|
-
mapHook.map.addControl(draw.current,
|
|
101
|
+
mapHook.map.addControl(draw.current, 'top-left', mapHook.componentId);
|
|
89
102
|
|
|
90
|
-
|
|
91
|
-
mapHook.map.on("draw.modechange", modeChangeHandler, mapHook.componentId);
|
|
103
|
+
mapHook.map.on('draw.modechange', modeChangeHandler, mapHook.componentId);
|
|
92
104
|
|
|
93
105
|
setDrawToolsReady(true);
|
|
94
106
|
}
|
|
@@ -100,35 +112,34 @@ const MlFeatureEditor = (props: MlFeatureEditorProps) => {
|
|
|
100
112
|
const changeHandler = () => {
|
|
101
113
|
if (draw.current) {
|
|
102
114
|
// update drawnFeatures state object
|
|
103
|
-
if (typeof props.onChange ===
|
|
104
|
-
|
|
115
|
+
if (typeof props.onChange === 'function') {
|
|
116
|
+
const currentFeatureCollection = draw.current.getAll?.();
|
|
105
117
|
props.onChange(currentFeatureCollection?.features);
|
|
106
118
|
}
|
|
107
119
|
}
|
|
108
120
|
};
|
|
109
121
|
|
|
110
|
-
mapHook.map.on(
|
|
122
|
+
mapHook.map.on('mouseup', changeHandler);
|
|
111
123
|
|
|
112
|
-
mapHook.map.on(
|
|
124
|
+
mapHook.map.on('touchend', changeHandler);
|
|
113
125
|
|
|
114
126
|
return () => {
|
|
115
127
|
if (!mapHook.map) return;
|
|
116
128
|
|
|
117
|
-
mapHook.map.map.off(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}, [drawToolsReady, mapHook.map])
|
|
129
|
+
mapHook.map.map.off('mouseup', changeHandler);
|
|
130
|
+
mapHook.map.map.off('touchend', changeHandler);
|
|
131
|
+
};
|
|
132
|
+
}, [drawToolsReady, mapHook.map]);
|
|
123
133
|
|
|
124
134
|
useEffect(() => {
|
|
125
135
|
if (draw.current && props.geojson?.geometry) {
|
|
126
|
-
draw.current.set({ type:
|
|
136
|
+
draw.current.set({ type: 'FeatureCollection', features: [props.geojson as any] });
|
|
127
137
|
}
|
|
128
138
|
}, [props.geojson, drawToolsReady]);
|
|
129
139
|
|
|
130
140
|
useEffect(() => {
|
|
131
141
|
if (props.mode && draw.current) {
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
132
143
|
// @ts-ignore
|
|
133
144
|
draw.current.changeMode(props.mode);
|
|
134
145
|
}
|
|
@@ -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
|
+
}
|