@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.
Files changed (197) hide show
  1. package/.babelrc +21 -2
  2. package/.eslintrc.js +8 -1
  3. package/.storybook/main.js +0 -1
  4. package/.storybook/preview.js +0 -2
  5. package/CHANGELOG.md +23 -0
  6. package/coverage/clover.xml +265 -89
  7. package/coverage/coverage-final.json +14 -6
  8. package/coverage/lcov-report/favicon.png +0 -0
  9. package/coverage/lcov-report/index.html +84 -39
  10. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  11. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +1 -1
  12. package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
  13. package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +1 -1
  14. package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
  15. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +1 -1
  16. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
  17. package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx.html +148 -0
  18. package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +2 -8
  19. package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +22 -7
  20. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +73 -40
  21. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +15 -15
  22. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
  23. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  24. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +1 -1
  25. package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
  26. package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.html +9 -3
  27. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +1 -1
  28. package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
  29. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +59 -29
  30. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  31. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js.html +652 -0
  32. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js.html +649 -0
  33. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/index.html +131 -0
  34. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx.html +1 -1
  35. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/index.html +1 -1
  36. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +1 -1
  37. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
  38. package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +1 -1
  39. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  40. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +1 -1
  41. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
  42. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +1 -1
  43. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
  44. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
  45. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
  46. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  47. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  48. package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +1 -1
  49. package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
  50. package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +1 -1
  51. package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
  52. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
  53. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  54. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +1 -1
  55. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
  56. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
  57. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +1 -1
  58. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  59. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
  60. package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
  61. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
  62. package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
  63. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/ColorPicker.tsx.html +214 -0
  64. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerList.tsx.html +121 -0
  65. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerListItem.tsx.html +412 -0
  66. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx.html +463 -0
  67. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/index.html +161 -0
  68. package/coverage/lcov-report/src/components/MlSketchTool/MlSketchTool.tsx.html +898 -0
  69. package/coverage/lcov-report/src/components/MlSketchTool/index.html +116 -0
  70. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +1 -1
  71. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  72. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
  73. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
  74. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +1 -1
  75. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
  76. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  77. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  78. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +1 -1
  79. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
  80. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
  81. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
  82. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +1 -1
  83. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
  84. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +1 -1
  85. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
  86. package/coverage/lcov-report/src/contexts/MapContext.tsx.html +1 -1
  87. package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
  88. package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
  89. package/coverage/lcov-report/src/contexts/index.html +1 -1
  90. package/coverage/lcov-report/src/hooks/index.html +11 -11
  91. package/coverage/lcov-report/src/hooks/useCameraFollowPath/index.html +1 -1
  92. package/coverage/lcov-report/src/hooks/useCameraFollowPath/useCameraFollowPath.tsx.html +1 -1
  93. package/coverage/lcov-report/src/hooks/useExportMap/index.html +14 -14
  94. package/coverage/lcov-report/src/hooks/useExportMap/index.ts.html +1 -1
  95. package/coverage/lcov-report/src/hooks/useExportMap/lib.ts.html +21 -108
  96. package/coverage/lcov-report/src/hooks/useLayer.ts.html +1 -1
  97. package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +9 -9
  98. package/coverage/lcov-report/src/hooks/useMap.ts.html +1 -1
  99. package/coverage/lcov-report/src/hooks/useMapState.ts.html +1 -1
  100. package/coverage/lcov-report/src/hooks/useSource.ts.html +1 -1
  101. package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
  102. package/coverage/lcov-report/src/index.html +1 -1
  103. package/coverage/lcov-report/src/index.ts.html +5 -2
  104. package/coverage/lcov.info +564 -161
  105. package/cypress/support/commands.ts +37 -0
  106. package/cypress/support/component-index.html +12 -0
  107. package/cypress/support/component.ts +46 -0
  108. package/cypress.config.ts +101 -0
  109. package/dist/components/MapLibreMap/MapLibreMap.d.ts +1 -1
  110. package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +3 -3
  111. package/dist/components/MlCreatePdfForm/MlCreatePdfForm.cy.d.ts +1 -0
  112. package/dist/components/MlCreatePdfForm/MlCreatePdfForm.stories.d.ts +1 -0
  113. package/dist/components/MlCreatePdfForm/lib/PdfContext.d.ts +3 -16
  114. package/dist/components/MlCreatePdfForm/lib/PdfPreview.d.ts +19 -6
  115. package/dist/components/MlCreatePdfForm/lib/_PdfPreview.d.ts +13 -0
  116. package/dist/components/MlFeatureEditor/MlFeatureEditor.d.ts +10 -4
  117. package/dist/components/MlFeatureEditor/lib/double_click_zoom.d.ts +0 -2
  118. package/dist/components/MlFeatureEditor/lib/theme.d.ts +1 -1
  119. package/dist/components/MlGPXViewer/util/GeoJsonContext.d.ts +1 -1
  120. package/dist/components/MlGPXViewer/util/MlGPXViewerInstructions.d.ts +1 -0
  121. package/dist/components/MlGPXViewer/util/SampleLayer.d.ts +0 -0
  122. package/dist/components/MlGPXViewer/util/demoViewer.d.ts +5 -0
  123. package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +4 -4
  124. package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +103 -11
  125. package/dist/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.d.ts +2 -0
  126. package/dist/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.d.ts +2 -0
  127. package/dist/components/MlSketchTool/LayerList/ColorPicker.d.ts +9 -0
  128. package/dist/components/MlSketchTool/LayerList/LayerList.d.ts +5 -0
  129. package/dist/components/MlSketchTool/LayerList/LayerListItem.d.ts +11 -0
  130. package/dist/components/MlSketchTool/LayerList/LayerPropertyForm.d.ts +9 -0
  131. package/dist/components/MlSketchTool/MlSketchTool.d.ts +29 -0
  132. package/dist/components/MlSketchTool/MlSketchTool.stories.d.ts +10 -0
  133. package/dist/contexts/SimpleDataProvider.d.ts +1 -1
  134. package/dist/custom.d.d.ts +1 -1
  135. package/dist/hooks/useLayer.d.ts +1 -1
  136. package/dist/hooks/useMap.d.ts +1 -1
  137. package/dist/hooks/useMapState.d.ts +3 -3
  138. package/dist/hooks/useSource.d.ts +1 -1
  139. package/dist/index.d.ts +1 -0
  140. package/dist/index.esm.css +1 -1
  141. package/dist/index.esm.js +3473 -4386
  142. package/dist/index.esm.js.map +1 -1
  143. package/dist/ui_components/LoadingOverlayContext.d.ts +1 -1
  144. package/dist/ui_components/Sidebar.d.ts +9 -1
  145. package/dist/ui_components/TopToolbar.d.ts +6 -1
  146. package/package.json +22 -15
  147. package/public/assets/sample1.gpx +3003 -0
  148. package/public/assets/sample2.gpx +1264 -0
  149. package/public/assets/sample3.gpx +912 -0
  150. package/public/index.html +0 -4
  151. package/public/thumbnails/MlSketchTool.png +0 -0
  152. package/public/thumbnails/useCameraFollowPath.png +0 -0
  153. package/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx +21 -0
  154. package/src/components/MlCreatePdfForm/MlCreatePdfForm.stories.tsx +14 -1
  155. package/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx +0 -2
  156. package/src/components/MlCreatePdfForm/lib/PdfContext.tsx +16 -18
  157. package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +79 -6
  158. package/src/components/MlCreatePdfForm/lib/PdfPreview.tsx +285 -357
  159. package/src/components/MlCreatePdfForm/lib/_PdfPreview.tsx +399 -0
  160. package/src/components/MlCreatePdfForm/lib/pdfContext.d.ts +24 -0
  161. package/src/components/MlCreatePdfForm/lib/preview.css +114 -0
  162. package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +1 -1
  163. package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +39 -28
  164. package/src/components/MlGPXViewer/MlGPXViewer.stories.js +75 -15
  165. package/src/components/MlGPXViewer/MlGPXViewer.tsx +3 -1
  166. package/src/components/MlGPXViewer/util/MlGPXViewerInstructions.js +145 -0
  167. package/src/components/MlGPXViewer/util/SampleLayer.js +2 -0
  168. package/src/components/MlGPXViewer/util/demoViewer.js +254 -0
  169. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.tsx +102 -0
  170. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +33 -23
  171. package/src/components/MlGeoJsonLayer/assets/sample_1.json +138 -24
  172. package/src/components/MlGeoJsonLayer/assets/sample_2.json +140 -20
  173. package/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js +189 -0
  174. package/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js +188 -0
  175. package/src/components/MlSketchTool/LayerList/ColorPicker.tsx +43 -0
  176. package/src/components/MlSketchTool/LayerList/LayerList.tsx +12 -0
  177. package/src/components/MlSketchTool/LayerList/LayerListItem.tsx +109 -0
  178. package/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx +126 -0
  179. package/src/components/MlSketchTool/MlSketchTool.doc.de.md +3 -0
  180. package/src/components/MlSketchTool/MlSketchTool.meta.json +15 -0
  181. package/src/components/MlSketchTool/MlSketchTool.stories.js +26 -0
  182. package/src/components/MlSketchTool/MlSketchTool.tsx +271 -0
  183. package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.meta.json +2 -2
  184. package/src/hooks/useExportMap/lib.ts +14 -43
  185. package/src/index.ts +1 -0
  186. package/src/ui_components/Sidebar.tsx +80 -0
  187. package/src/ui_components/TopToolbar.tsx +24 -0
  188. package/tsconfig.json +39 -58
  189. package/config/getHttpsConfig.js +0 -66
  190. package/config/modules.js +0 -134
  191. package/config/pnpTs.js +0 -35
  192. package/config/webpack.config.js +0 -757
  193. package/config/webpackDevServer.config.js +0 -130
  194. package/scripts/start.js +0 -166
  195. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +0 -66
  196. package/src/ui_components/Sidebar.js +0 -100
  197. package/src/ui_components/TopToolbar.js +0 -29
@@ -0,0 +1,271 @@
1
+ import React, { useState, useCallback } from 'react';
2
+ import PanoramaFishEyeIcon from '@mui/icons-material/PanoramaFishEye';
3
+ import ShowChartIcon from '@mui/icons-material/ShowChart';
4
+ import PentagonIcon from '@mui/icons-material/Pentagon';
5
+ import { Box } from '@mui/system';
6
+ //import useMediaQuery from '@mui/material/useMediaQuery';
7
+ import MlFeatureEditor from '../MlFeatureEditor/MlFeatureEditor';
8
+ import List from '@mui/material/List';
9
+ import EditIcon from '@mui/icons-material/Edit';
10
+ import SettingsIcon from '@mui/icons-material/Settings';
11
+ import MlGeoJsonLayer from '../MlGeoJsonLayer/MlGeoJsonLayer';
12
+ import useMap from '../../hooks/useMap';
13
+ import DeleteIcon from '@mui/icons-material/Delete';
14
+ import * as turf from '@turf/turf';
15
+ import ButtonGroup from '@mui/material/ButtonGroup';
16
+ import IconButton from '@mui/material/IconButton';
17
+ import Tooltip from '@mui/material/Tooltip';
18
+ import LayerListItem from './LayerList/LayerListItem';
19
+ import GpsFixedIcon from '@mui/icons-material/GpsFixed';
20
+ import { Feature } from '@turf/turf';
21
+ import { LngLatLike } from '!maplibre-gl';
22
+ import { SxProps } from '@mui/system/styleFunctionSx/styleFunctionSx';
23
+
24
+ interface MlSketchToolProps {
25
+ /**
26
+ * Id of the target MapLibre instance in mapContext
27
+ */
28
+ mapId?: string;
29
+ /**
30
+ * Id of an existing layer in the mapLibre instance to help specify the layer order
31
+ * This layer will be visually beneath the layer with the "insertBeforeLayer" id.
32
+ */
33
+ insertBeforeLayer?: string;
34
+ /**
35
+ * Style attribute for the button-style
36
+ * https://mui.com/system/getting-started/the-sx-prop/
37
+ */
38
+ buttonStyleOverride?: SxProps;
39
+ }
40
+
41
+ /**
42
+ * Component template
43
+ *
44
+ */
45
+
46
+ const MlSketchTool = (props: MlSketchToolProps) => {
47
+ type SketchStateType = {
48
+ selectedGeoJson: Feature | undefined;
49
+ activeGeometryIndex: number;
50
+ geometries: Feature[];
51
+ drawMode: string;
52
+ };
53
+ const mapHook = useMap({
54
+ mapId: props.mapId,
55
+ waitForLayer: props.insertBeforeLayer,
56
+ });
57
+ //const mediaIsMobile = useMediaQuery('(max-width:900px)');
58
+ const [hoveredGeometry, setHoveredGeometry] = useState<Feature>();
59
+ const [sketchState, setSketchState] = useState<SketchStateType>({
60
+ activeGeometryIndex: 0,
61
+ selectedGeoJson: undefined,
62
+ geometries: [],
63
+ drawMode: '',
64
+ });
65
+
66
+ const buttonStyle = {
67
+ ...props.buttonStyleOverride,
68
+ };
69
+
70
+ const buttonClickHandler = useCallback(
71
+ (buttonDrawMode: string) => {
72
+ console.log(buttonDrawMode);
73
+ sketchState.drawMode !== buttonDrawMode
74
+ ? setSketchState((_sketchTool) => ({
75
+ drawMode: buttonDrawMode,
76
+ geometries: _sketchTool.geometries,
77
+ activeGeometryIndex: 0,
78
+ selectedGeoJson: undefined,
79
+ }))
80
+ : setSketchState((_sketchTool) => ({
81
+ drawMode: '',
82
+ geometries: _sketchTool.geometries,
83
+ activeGeometryIndex: 0,
84
+ selectedGeoJson: undefined,
85
+ }));
86
+ },
87
+ [sketchState]
88
+ );
89
+
90
+ const removeGeoJson = (geoJson: Feature): void => {
91
+ setSketchState((_sketchState) => {
92
+ const tempGeometries = [..._sketchState.geometries];
93
+ tempGeometries.splice(tempGeometries.indexOf(geoJson), 1);
94
+
95
+ return {
96
+ ..._sketchState,
97
+ geometries: tempGeometries,
98
+ activeGeometryIndex: _sketchState.activeGeometryIndex - 1,
99
+ };
100
+ });
101
+ };
102
+
103
+ return (
104
+ <>
105
+ <Box
106
+ sx={{
107
+ zIndex: 104,
108
+ }}
109
+ >
110
+ <ButtonGroup>
111
+ <Tooltip title={'point'}>
112
+ <IconButton sx={buttonStyle} onClick={() => buttonClickHandler('draw_point')}>
113
+ <PanoramaFishEyeIcon />
114
+ </IconButton>
115
+ </Tooltip>
116
+ <Tooltip title={'Line'}>
117
+ <IconButton sx={buttonStyle} onClick={() => buttonClickHandler('draw_line_string')}>
118
+ <ShowChartIcon />
119
+ </IconButton>
120
+ </Tooltip>
121
+ <Tooltip title={'Polygon'}>
122
+ <IconButton sx={buttonStyle} onClick={() => buttonClickHandler('custom_polygon')}>
123
+ <PentagonIcon />
124
+ </IconButton>
125
+ </Tooltip>
126
+ </ButtonGroup>
127
+ </Box>
128
+
129
+ {sketchState.drawMode && (
130
+ <MlFeatureEditor
131
+ mode={
132
+ sketchState.drawMode === 'edit'
133
+ ? sketchState.selectedGeoJson?.geometry?.type === 'LineString'
134
+ ? 'simple_select'
135
+ : 'custom_select'
136
+ : sketchState.drawMode
137
+ }
138
+ geojson={sketchState.drawMode === 'edit' ? sketchState.selectedGeoJson : undefined}
139
+ onChange={(feature: object) => {
140
+ setSketchState((_sketchState) => {
141
+ const _geometries = [...sketchState.geometries];
142
+ if (sketchState.drawMode === 'edit' && sketchState.selectedGeoJson) {
143
+ _geometries[_geometries.indexOf(sketchState.selectedGeoJson)] = feature[0];
144
+ } else {
145
+ if (!sketchState.activeGeometryIndex) {
146
+ const tempFeature = feature[0];
147
+ tempFeature.properties.id = tempFeature.id;
148
+
149
+ _geometries.push(tempFeature);
150
+ } else {
151
+ _geometries[sketchState.activeGeometryIndex] = feature[0];
152
+ }
153
+ }
154
+ return {
155
+ ..._sketchState,
156
+ activeGeometryIndex:
157
+ _sketchState.drawMode !== 'edit' && feature[0].geometry.type !== 'Point'
158
+ ? _geometries.length - 1
159
+ : _sketchState.activeGeometryIndex,
160
+ geometries: _geometries,
161
+ };
162
+ });
163
+ }}
164
+ onFinish={() => {
165
+ setSketchState((_sketchState) => ({
166
+ ..._sketchState,
167
+ drawMode: '',
168
+ activeGeometryIndex:
169
+ _sketchState.drawMode !== 'draw_point' ? 0 : _sketchState.activeGeometryIndex,
170
+ selectedGeoJson:
171
+ _sketchState.drawMode !== 'draw_point' ? undefined : _sketchState.selectedGeoJson,
172
+ }));
173
+ }}
174
+ />
175
+ )}
176
+
177
+ <List sx={{ zIndex: 105 }}>
178
+ {sketchState.geometries.map((el) => (
179
+ <>
180
+ <Box key={el.id} sx={{ display: 'flex', flexDirection: 'column' }}>
181
+ <br />
182
+ <Box
183
+ flexDirection={'row'}
184
+ sx={{
185
+ '&:hover': {
186
+ backgroundColor: 'rgb(177, 177, 177, 0.2)',
187
+ },
188
+ }}
189
+ onMouseOver={() => {
190
+ setHoveredGeometry(el);
191
+ }}
192
+ onMouseLeave={() => {
193
+ setHoveredGeometry(undefined);
194
+ }}
195
+ >
196
+ {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
197
+ {/* @ts-ignore-next-line */}
198
+ <LayerListItem
199
+ sx={buttonStyle}
200
+ visible={true}
201
+ configurable={true}
202
+ layerComponent={
203
+ <MlGeoJsonLayer mapId={props.mapId} geojson={el} layerId={String(el.id)} />
204
+ }
205
+ type={'layer'}
206
+ name={String(el.id)}
207
+ description={el.geometry.type}
208
+ >
209
+ <SettingsIcon />
210
+ </LayerListItem>
211
+ <IconButton
212
+ onClick={() => {
213
+ mapHook?.map?.map.setCenter(
214
+ el.geometry.type === 'Point'
215
+ ? (el.geometry.coordinates as LngLatLike)
216
+ : (turf.centerOfMass(el).geometry.coordinates as LngLatLike)
217
+ );
218
+ }}
219
+ >
220
+ <GpsFixedIcon />
221
+ </IconButton>
222
+ <IconButton
223
+ sx={buttonStyle}
224
+ onClick={() => {
225
+ setSketchState((_sketchState) => ({
226
+ ..._sketchState,
227
+ selectedGeoJson: el,
228
+ drawMode: 'edit',
229
+ }));
230
+ }}
231
+ >
232
+ <EditIcon />
233
+ </IconButton>
234
+ <IconButton
235
+ sx={buttonStyle}
236
+ onClick={() => {
237
+ removeGeoJson(el);
238
+ }}
239
+ >
240
+ <DeleteIcon />
241
+ </IconButton>
242
+ </Box>
243
+ </Box>
244
+ </>
245
+ ))}
246
+ {hoveredGeometry && (
247
+ <MlGeoJsonLayer
248
+ mapId={props.mapId}
249
+ geojson={{ type: 'FeatureCollection', features: [hoveredGeometry] }}
250
+ type={'line'}
251
+ layerId={'highlightBorder'}
252
+ paint={{
253
+ 'line-color': '#dd9900',
254
+ 'line-opacity': 0.4,
255
+ 'line-width': 10,
256
+ }}
257
+ />
258
+ )}
259
+ </List>
260
+ {sketchState.drawMode === 'edit' && (
261
+ <Box>Edit {sketchState.selectedGeoJson?.geometry?.type}</Box>
262
+ )}
263
+ </>
264
+ );
265
+ };
266
+
267
+ MlSketchTool.defaultProps = {
268
+ mapId: undefined,
269
+ buttonStyleOverride: {},
270
+ };
271
+ export default MlSketchTool;
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "MlTransitionGeoJsonLayer",
3
- "title": "GeoJSON layer",
3
+ "title": "Transition GeoJSON layer",
4
4
  "description": "",
5
5
  "i18n": {
6
6
  "de": {
7
- "title": "GeoJSON Ebene",
7
+ "title": "Animierte GeoJSON Ebene",
8
8
  "description": ""
9
9
  }
10
10
  },
@@ -1,8 +1,7 @@
1
- import { LngLatLike, Map } from '!maplibre-gl';
1
+ import { Map } from '!maplibre-gl';
2
2
  import jsPDF from 'jspdf';
3
3
  import MapLibreGlWrapper from '../../components/MapLibreMap/lib/MapLibreGlWrapper';
4
4
 
5
- import * as turf from '@turf/turf';
6
5
  import { BBox } from '@turf/turf';
7
6
 
8
7
  interface createExportOptions {
@@ -59,54 +58,26 @@ const createExport = (options: createExportOptions) => {
59
58
  style: style,
60
59
  });
61
60
 
62
- let _previewGeojson = turf.bboxPolygon([
63
- options.bbox[0],
64
- options.bbox[1],
65
- options.bbox[2],
66
- options.bbox[3],
67
- ]);
68
- _previewGeojson = turf.transformRotate(_previewGeojson, options.bearing);
69
-
70
- // use original unrotated bbox and bearing 0 to calculate the correct zoom value as the function always adds a padding if used on the rotated feature coordinates
71
61
  const bboxCamera = renderMap._cameraForBoxAndBearing(
72
62
  [options.bboxUnrotated[0], options.bboxUnrotated[1]],
73
63
  [options.bboxUnrotated[2], options.bboxUnrotated[3]],
74
- 0
75
- );
76
- const geometryCamera = renderMap._cameraForBoxAndBearing(
77
- _previewGeojson.geometry.coordinates[0][0] as LngLatLike,
78
- _previewGeojson.geometry.coordinates[0][2] as LngLatLike,
79
- options.bearing
64
+ options.bearing+options.map.map.getBearing()
80
65
  );
81
- geometryCamera.zoom = bboxCamera.zoom;
82
66
 
83
- renderMap._fitInternal(geometryCamera);
67
+ renderMap._fitInternal(bboxCamera);
84
68
  return new Promise<createExportResolverParams>((resolve) => {
85
- renderMap.once('idle', function () {
86
- if (renderMap.getLayer('pdfPreviewGeojsonOutline')) {
87
- renderMap.setLayoutProperty('pdfPreviewGeojsonOutline', 'visibility', 'none');
88
- }
89
- if (renderMap.getLayer('pdfPreviewGeojson')) {
90
- renderMap.setLayoutProperty('pdfPreviewGeojson', 'visibility', 'none');
91
- }
92
- if (renderMap.getLayer('pdfPreviewGeojsonResizeHandle')) {
93
- renderMap.setLayoutProperty('pdfPreviewGeojsonResizeHandle', 'visibility', 'none');
94
- }
95
- if (renderMap.getLayer('pdfPreviewGeojsonRotationHandle')) {
96
- renderMap.setLayoutProperty('pdfPreviewGeojsonRotationHandle', 'visibility', 'none');
97
- }
69
+ console.log('before idle');
98
70
 
99
- renderMap.once('idle', function () {
100
- const params: createExportResolverParams = {
101
- ...options,
102
- renderMap,
103
- hiddenContainer,
104
- createPdf: (_options?: createJsPdfOptions) =>
105
- createJsPdf({ ...options, renderMap, hiddenContainer, ..._options }),
106
- };
107
-
108
- resolve(params);
109
- });
71
+ renderMap.once('idle', function () {
72
+ const params: createExportResolverParams = {
73
+ ...options,
74
+ renderMap,
75
+ hiddenContainer,
76
+ createPdf: (_options?: createJsPdfOptions) =>
77
+ createJsPdf({ ...options, renderMap, hiddenContainer, ..._options }),
78
+ };
79
+
80
+ resolve(params);
110
81
  });
111
82
  });
112
83
  };
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export { default as MapLibreMap } from "./components/MapLibreMap/MapLibreMap";
2
2
  export { default as MlComponentTemplate } from "./components/MlComponentTemplate/MlComponentTemplate";
3
3
  export { default as MlCreatePdfButton } from "./components/MlCreatePdfButton/MlCreatePdfButton";
4
4
  export { default as MlCreatePdfForm } from "./components/MlCreatePdfForm/MlCreatePdfForm";
5
+ export { default as MlPdfPreview } from "./components/MlCreatePdfForm/lib/PdfPreview";
5
6
  export { default as MlFeatureEditor } from "./components/MlFeatureEditor/MlFeatureEditor";
6
7
  export { default as MlFillExtrusionLayer } from "./components/MlFillExtrusionLayer/MlFillExtrusionLayer";
7
8
  export { default as MlFollowGps } from "./components/MlFollowGps/MlFollowGps";
@@ -0,0 +1,80 @@
1
+ import React, { useState } from 'react';
2
+ import { styled } from '@mui/material/styles';
3
+ import Drawer from '@mui/material/Drawer';
4
+ import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
5
+ import MenuIcon from '@mui/icons-material/Menu';
6
+ import { IconButton, PaperProps } from '@mui/material';
7
+ import useMediaQuery from '@mui/material/useMediaQuery';
8
+ import Box from '@mui/material/Box';
9
+ import { JsxChildren } from 'typedoc/dist/lib/utils/jsx.elements';
10
+
11
+ const DrawerHeader = styled('div')(() => ({
12
+ display: 'flex',
13
+ alignItems: 'center',
14
+ }));
15
+
16
+ interface SidebarProps {
17
+ drawerPaperProps: PaperProps;
18
+ drawerHeaderProps: Headers;
19
+ children: JsxChildren;
20
+ }
21
+
22
+ export default function Sidebar({ drawerPaperProps, drawerHeaderProps, ...props }: SidebarProps) {
23
+ const mediaIsMobile = useMediaQuery('(max-width:900px)');
24
+
25
+ const [drawerOpen, setDrawerOpen] = useState(true);
26
+
27
+ const handleDrawerOpen = () => {
28
+ setDrawerOpen(true);
29
+ };
30
+ const handleDrawerClose = () => {
31
+ setDrawerOpen(false);
32
+ };
33
+
34
+ return (
35
+ <>
36
+ <IconButton
37
+ onClick={handleDrawerOpen}
38
+ style={{
39
+ zIndex: 101,
40
+ position: 'relative',
41
+ padding: '20px',
42
+ }}
43
+ >
44
+ <MenuIcon />
45
+ </IconButton>
46
+ <Drawer
47
+ transitionDuration={0}
48
+ variant="persistent"
49
+ anchor="left"
50
+ open={drawerOpen}
51
+ PaperProps={{
52
+ sx: {
53
+ maxWidth: '20%',
54
+ padding: '40px',
55
+ },
56
+ ...drawerPaperProps,
57
+ }}
58
+ sx={{
59
+ flexGrow: 1,
60
+ zIndex: 105,
61
+ position: 'absolute',
62
+ top: 0,
63
+ backgroundColor: '#fafafa',
64
+ display: 'flex',
65
+ flexDirection: 'column',
66
+ maxWidth: mediaIsMobile ? '90vw' : '20vw',
67
+ ...(drawerOpen ? {} : { left: mediaIsMobile ? '-90vw' : '-20vw' }),
68
+ }}
69
+ {...props}
70
+ >
71
+ <DrawerHeader {...drawerHeaderProps}>
72
+ <IconButton onClick={handleDrawerClose}>
73
+ <ChevronLeftIcon />
74
+ </IconButton>
75
+ </DrawerHeader>
76
+ <Box>{props.children}</Box>
77
+ </Drawer>
78
+ </>
79
+ );
80
+ }
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import AppBar from '@mui/material/AppBar';
3
+ import { Toolbar, AppBarProps, ToolbarProps } from '@mui/material';
4
+
5
+ interface TopToolbarProps extends AppBarProps {
6
+ toolbarProps: ToolbarProps;
7
+ }
8
+ export default function TopToolbar({ toolbarProps, ...props }: TopToolbarProps) {
9
+ return (
10
+ <AppBar
11
+ sx={{
12
+ minHeight: '62px',
13
+ backgroundColor: '#f1f1f1',
14
+ position: 'absolute',
15
+ zIndex: 120,
16
+ }}
17
+ color="primary"
18
+ position="static"
19
+ {...props}
20
+ >
21
+ <Toolbar {...toolbarProps}>{props.children}</Toolbar>
22
+ </AppBar>
23
+ );
24
+ }
package/tsconfig.json CHANGED
@@ -1,59 +1,40 @@
1
1
  {
2
- "compilerOptions": {
3
- "checkJs": false,
4
- "esModuleInterop": true,
5
- "importHelpers": false,
6
- "isolatedModules": true,
7
- "resolveJsonModule": true,
8
- "skipLibCheck": true,
9
- "sourceMap": true,
10
- "strict": false,
11
- "types": [
12
- "node",
13
- "jest",
14
- "geojson"
15
- ],
16
- "outDir": "build/esm",
17
- "module": "esnext",
18
- "target": "es5",
19
- "lib": [
20
- "es6",
21
- "dom",
22
- "es2016",
23
- "es2017"
24
- ],
25
- "jsx": "react",
26
- "declaration": true,
27
- "declarationDir": "./dist",
28
- "moduleResolution": "node",
29
- "noUnusedLocals": true,
30
- "noUnusedParameters": true,
31
- "noImplicitReturns": true,
32
- "noImplicitThis": true,
33
- "noImplicitAny": true,
34
- "strictNullChecks": true,
35
- "suppressImplicitAnyIndexErrors": true,
36
- "allowSyntheticDefaultImports": true,
37
- "allowJs": true,
38
- "baseUrl": ".",
39
- "paths": {
40
- "!maplibre-gl": [
41
- "node_modules/maplibre-gl"
42
- ] // This mapping is relative to "baseUrl"
43
- }
44
- },
45
- "include": [
46
- "src",
47
- "src/custom.d.tsx"
48
- ],
49
- "exclude": [
50
- "node_modules",
51
- "lib"
52
- ],
53
- "typedocOptions": {
54
- "entryPoints": [
55
- "src/index.ts"
56
- ],
57
- "out": "docs",
58
- }
59
- }
2
+ "compilerOptions": {
3
+ "checkJs": false,
4
+ "esModuleInterop": true,
5
+ "importHelpers": false,
6
+ "isolatedModules": true,
7
+ "resolveJsonModule": true,
8
+ "skipLibCheck": true,
9
+ "sourceMap": true,
10
+ "strict": false,
11
+ "types": ["node", "jest", "geojson", "cypress", "./support"],
12
+ "outDir": "build/esm",
13
+ "module": "esnext",
14
+ "target": "es5",
15
+ "lib": ["es6", "dom", "es2016", "es2017"],
16
+ "jsx": "react",
17
+ "declaration": true,
18
+ "declarationDir": "./dist",
19
+ "moduleResolution": "node",
20
+ "noUnusedLocals": true,
21
+ "noUnusedParameters": true,
22
+ "noImplicitReturns": true,
23
+ "noImplicitThis": true,
24
+ "noImplicitAny": true,
25
+ "strictNullChecks": true,
26
+ "suppressImplicitAnyIndexErrors": true,
27
+ "allowSyntheticDefaultImports": true,
28
+ "allowJs": true,
29
+ "baseUrl": ".",
30
+ "paths": {
31
+ "!maplibre-gl": ["node_modules/maplibre-gl"] // This mapping is relative to "baseUrl"
32
+ }
33
+ },
34
+ "include": ["src", "src/custom.d.tsx"],
35
+ "exclude": ["node_modules", "lib"],
36
+ "typedocOptions": {
37
+ "entryPoints": ["src/index.ts"],
38
+ "out": "docs"
39
+ }
40
+ }
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- const fs = require('fs');
4
- const path = require('path');
5
- const crypto = require('crypto');
6
- const chalk = require('react-dev-utils/chalk');
7
- const paths = require('./paths');
8
-
9
- // Ensure the certificate and key provided are valid and if not
10
- // throw an easy to debug error
11
- function validateKeyAndCerts({ cert, key, keyFile, crtFile }) {
12
- let encrypted;
13
- try {
14
- // publicEncrypt will throw an error with an invalid cert
15
- encrypted = crypto.publicEncrypt(cert, Buffer.from('test'));
16
- } catch (err) {
17
- throw new Error(
18
- `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}`
19
- );
20
- }
21
-
22
- try {
23
- // privateDecrypt will throw an error with an invalid key
24
- crypto.privateDecrypt(key, encrypted);
25
- } catch (err) {
26
- throw new Error(
27
- `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${
28
- err.message
29
- }`
30
- );
31
- }
32
- }
33
-
34
- // Read file and throw an error if it doesn't exist
35
- function readEnvFile(file, type) {
36
- if (!fs.existsSync(file)) {
37
- throw new Error(
38
- `You specified ${chalk.cyan(
39
- type
40
- )} in your env, but the file "${chalk.yellow(file)}" can't be found.`
41
- );
42
- }
43
- return fs.readFileSync(file);
44
- }
45
-
46
- // Get the https config
47
- // Return cert files if provided in env, otherwise just true or false
48
- function getHttpsConfig() {
49
- const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env;
50
- const isHttps = HTTPS === 'true';
51
-
52
- if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) {
53
- const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE);
54
- const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE);
55
- const config = {
56
- cert: readEnvFile(crtFile, 'SSL_CRT_FILE'),
57
- key: readEnvFile(keyFile, 'SSL_KEY_FILE'),
58
- };
59
-
60
- validateKeyAndCerts({ ...config, keyFile, crtFile });
61
- return config;
62
- }
63
- return isHttps;
64
- }
65
-
66
- module.exports = getHttpsConfig;