@mapcomponents/react-maplibre 0.1.66 → 0.1.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/.github/workflows/node_version_test.yml +1 -1
  2. package/.storybook/main.js +37 -31
  3. package/.storybook/preview.js +21 -0
  4. package/CHANGELOG.md +13 -0
  5. package/coverage/clover.xml +545 -472
  6. package/coverage/coverage-final.json +18 -17
  7. package/coverage/lcov-report/index.html +80 -80
  8. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +50 -26
  9. package/coverage/lcov-report/src/components/MapLibreMap/index.html +5 -5
  10. package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +30 -51
  11. package/coverage/lcov-report/src/components/MlCenterPosition/index.html +3 -3
  12. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +1 -1
  13. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
  14. package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx.html +1 -1
  15. package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +1 -1
  16. package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +1 -1
  17. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +1 -1
  18. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
  19. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
  20. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  21. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +48 -105
  22. package/coverage/lcov-report/src/components/MlFollowGps/index.html +15 -15
  23. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +2 -2
  24. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  25. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js.html +1 -1
  26. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js.html +1 -1
  27. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.tsx.html +1 -1
  28. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.tsx.html +1 -1
  29. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/index.html +1 -1
  30. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx.html +1 -1
  31. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/index.html +1 -1
  32. package/coverage/lcov-report/src/components/MlGpxViewer/MlGpxViewer.tsx.html +1 -1
  33. package/coverage/lcov-report/src/components/MlGpxViewer/index.html +1 -1
  34. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +1 -1
  35. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
  36. package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +1 -1
  37. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  38. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +52 -40
  39. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +10 -10
  40. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +4 -4
  41. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
  42. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
  43. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
  44. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  45. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  46. package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +1 -1
  47. package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
  48. package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +1 -1
  49. package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
  50. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
  51. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  52. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +41 -113
  53. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +15 -15
  54. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
  55. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +1 -1
  56. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  57. package/coverage/lcov-report/src/components/MlScaleReference/{MlScaleReference.js.html → MlScaleReference.tsx.html} +57 -36
  58. package/coverage/lcov-report/src/components/MlScaleReference/index.html +2 -2
  59. package/coverage/lcov-report/src/components/MlShareMapState/{MlShareMapState.js.html → MlShareMapState.tsx.html} +192 -84
  60. package/coverage/lcov-report/src/components/MlShareMapState/index.html +20 -20
  61. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/ColorPicker.tsx.html +1 -1
  62. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerList.tsx.html +1 -1
  63. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerListItem.tsx.html +1 -1
  64. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx.html +2 -2
  65. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/index.html +1 -1
  66. package/coverage/lcov-report/src/components/MlSketchTool/MlSketchTool.tsx.html +2 -2
  67. package/coverage/lcov-report/src/components/MlSketchTool/index.html +1 -1
  68. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.tsx.html +1 -1
  69. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  70. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
  71. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreejsLayer.tsx.html +769 -0
  72. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +25 -10
  73. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +1 -1
  74. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
  75. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  76. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  77. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +22 -10
  78. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +13 -13
  79. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +11 -11
  80. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +11 -11
  81. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +1 -1
  82. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
  83. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +27 -18
  84. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +11 -11
  85. package/coverage/lcov-report/src/contexts/MapContext.tsx.html +72 -27
  86. package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
  87. package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
  88. package/coverage/lcov-report/src/contexts/index.html +1 -1
  89. package/coverage/lcov-report/src/hooks/index.html +21 -21
  90. package/coverage/lcov-report/src/hooks/useCameraFollowPath/index.html +1 -1
  91. package/coverage/lcov-report/src/hooks/useCameraFollowPath/useCameraFollowPath.tsx.html +1 -1
  92. package/coverage/lcov-report/src/hooks/useExportMap/index.html +1 -1
  93. package/coverage/lcov-report/src/hooks/useExportMap/index.ts.html +1 -1
  94. package/coverage/lcov-report/src/hooks/useExportMap/lib.ts.html +2 -2
  95. package/coverage/lcov-report/src/hooks/useGpx/index.html +1 -1
  96. package/coverage/lcov-report/src/hooks/useGpx/useGpx.tsx.html +1 -1
  97. package/coverage/lcov-report/src/hooks/useLayer.ts.html +1 -1
  98. package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +9 -9
  99. package/coverage/lcov-report/src/hooks/useLayerFilter/index.html +1 -1
  100. package/coverage/lcov-report/src/hooks/useLayerFilter/useLayerFilter.ts.html +1 -1
  101. package/coverage/lcov-report/src/hooks/useLayerHoverPopup/index.html +1 -1
  102. package/coverage/lcov-report/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx.html +9 -6
  103. package/coverage/lcov-report/src/hooks/useMap.ts.html +2 -2
  104. package/coverage/lcov-report/src/hooks/useMapState.ts.html +8 -29
  105. package/coverage/lcov-report/src/hooks/useSource.ts.html +10 -10
  106. package/coverage/lcov-report/src/hooks/useWms.ts.html +1 -1
  107. package/coverage/lcov-report/src/index.html +1 -1
  108. package/coverage/lcov-report/src/index.ts.html +105 -12
  109. package/coverage/lcov.info +1038 -917
  110. package/dist/components/MapLibreMap/MapLibreMap.d.ts +3 -3
  111. package/dist/components/MapLibreMap/MapLibreMap.stories.d.ts +5 -0
  112. package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +17 -15
  113. package/dist/components/MlCenterPosition/MlCenterPosition.d.ts +2 -15
  114. package/dist/components/MlCenterPosition/MlCenterPosition.stories.d.ts +2 -15
  115. package/dist/components/MlComponentTemplate/MlComponentTemplate.d.ts +1 -0
  116. package/dist/components/MlComponentTemplate/MlComponentTemplate.stories.d.ts +2 -1
  117. package/dist/components/MlCreatePdfButton/MlCreatePdfButton.d.ts +1 -0
  118. package/dist/components/MlCreatePdfButton/MlCreatePdfButton.stories.d.ts +2 -1
  119. package/dist/components/MlCreatePdfForm/MlCreatePdfForm.d.ts +1 -0
  120. package/dist/components/MlCreatePdfForm/MlCreatePdfForm.stories.d.ts +2 -1
  121. package/dist/components/MlCreatePdfForm/lib/PdfForm.d.ts +1 -0
  122. package/dist/components/MlCreatePdfForm/lib/_PdfPreview.d.ts +1 -0
  123. package/dist/components/MlFeatureEditor/MlFeatureEditor.d.ts +1 -0
  124. package/dist/components/MlFeatureEditor/lib/create_supplementary_points.d.ts +1 -1
  125. package/dist/components/MlFeatureEditor/lib/create_vertex.d.ts +1 -1
  126. package/dist/components/MlFillExtrusionLayer/MlFillExtrusionLayer.d.ts +1 -0
  127. package/dist/components/MlFollowGps/MlFollowGps.d.ts +5 -23
  128. package/dist/components/MlFollowGps/MlFollowGps.stories.d.ts +2 -2
  129. package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +1 -0
  130. package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +2 -1
  131. package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.d.ts +1 -0
  132. package/dist/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.d.ts +1 -0
  133. package/dist/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.d.ts +4 -1
  134. package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.d.ts +1 -0
  135. package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.d.ts +2 -1
  136. package/dist/components/MlGpxViewer/MlGpxViewer.d.ts +1 -0
  137. package/dist/components/MlGpxViewer/MlGpxViewer.stories.d.ts +2 -1
  138. package/dist/components/MlGpxViewer/util/GeoJsonProvider.d.ts +1 -0
  139. package/dist/components/MlGpxViewer/util/MetadataDrawer.d.ts +1 -0
  140. package/dist/components/MlGpxViewer/util/MlGpxDemoLoader.d.ts +1 -0
  141. package/dist/components/MlGpxViewer/util/MlGpxViewerInstructions.d.ts +1 -0
  142. package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.d.ts +1 -0
  143. package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.d.ts +2 -1
  144. package/dist/components/MlLayer/MlLayer.d.ts +1 -0
  145. package/dist/components/MlLayerMagnify/MlLayerMagnify.stories.d.ts +2 -1
  146. package/dist/components/MlLayerSwipe/MlLayerSwipe.stories.d.ts +2 -1
  147. package/dist/components/MlMarker/MlMarker.d.ts +1 -0
  148. package/dist/components/MlMeasureTool/MlMeasureTool.d.ts +1 -0
  149. package/dist/components/MlNavigationCompass/MlNavigationCompass.d.ts +1 -0
  150. package/dist/components/MlNavigationTools/MlNavigationTools.d.ts +5 -0
  151. package/dist/components/MlScaleReference/MlScaleReference.d.ts +8 -1
  152. package/dist/components/MlShareMapState/MlShareMapState.d.ts +33 -13
  153. package/dist/components/MlShareMapState/MlShareMapState.stories.d.ts +16 -9
  154. package/dist/components/MlSketchTool/LayerList/ColorPicker.d.ts +1 -0
  155. package/dist/components/MlSketchTool/LayerList/LayerList.d.ts +1 -0
  156. package/dist/components/MlSketchTool/LayerList/LayerListItem.d.ts +1 -0
  157. package/dist/components/MlSketchTool/LayerList/LayerPropertyForm.d.ts +1 -0
  158. package/dist/components/MlSketchTool/MlSketchTool.d.ts +1 -0
  159. package/dist/components/MlSketchTool/MlSketchTool.stories.d.ts +2 -1
  160. package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.d.ts +1 -0
  161. package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.d.ts +2 -1
  162. package/dist/components/MlSpatialElevationProfile/util/getElevationData.d.ts +1 -1
  163. package/dist/components/MlThreeJsLayer/MlThreeJsLayer.stories.d.ts +2 -1
  164. package/dist/components/MlThreeJsLayer/MlThreejsLayer.d.ts +30 -0
  165. package/dist/components/MlThreeJsLayer/lib/GLTFLoader.d.ts +2 -1
  166. package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +1 -0
  167. package/dist/components/MlVectorTileLayer/MlVectorTileLayer.d.ts +3 -2
  168. package/dist/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.d.ts +2 -1
  169. package/dist/components/MlWmsLayer/MlWmsLayer.d.ts +1 -0
  170. package/dist/components/MlWmsLoader/MlWmsLoader.d.ts +1 -0
  171. package/dist/components/MlWmsLoader/MlWmsLoader.stories.d.ts +2 -1
  172. package/dist/components/MlWmsLoader/utils/MlWmsLoaderInstructions.d.ts +1 -0
  173. package/dist/components/MlWmsLoader/utils/WMSLinks.d.ts +1 -0
  174. package/dist/contexts/MapContext.d.ts +13 -2
  175. package/dist/decorators/EmptyMapDecorator.d.ts +2 -0
  176. package/dist/decorators/MapContextDecorator.d.ts +1 -1
  177. package/dist/decorators/MapContextDecoratorHooks.d.ts +1 -1
  178. package/dist/decorators/MultiMapContextDecorator.d.ts +1 -1
  179. package/dist/decorators/NoNavToolsDecorator.d.ts +1 -1
  180. package/dist/decorators/ThemeDecorator.d.ts +2 -0
  181. package/dist/hooks/useCameraFollowPath/useCameraFollowPath.stories.d.ts +2 -1
  182. package/dist/hooks/useExportMap/lib.d.ts +1 -1
  183. package/dist/hooks/useLayerFilter/useLayerFilter.stories.d.ts +2 -1
  184. package/dist/hooks/useLayerHoverPopup/useLayerHoverPopup.d.ts +1 -0
  185. package/dist/index.d.ts +25 -8
  186. package/dist/index.esm.css +0 -97
  187. package/dist/index.esm.js +2187 -9306
  188. package/dist/index.esm.js.map +1 -1
  189. package/dist/setupTests.d.ts +6 -6
  190. package/dist/ui_components/Dropzone.d.ts +1 -0
  191. package/dist/ui_components/ImageLoader.d.ts +1 -0
  192. package/dist/ui_components/LayerList/LayerList.d.ts +6 -0
  193. package/dist/ui_components/LayerList/LayerList.stories.d.ts +12 -0
  194. package/dist/ui_components/LayerList/LayerListFolder.d.ts +9 -0
  195. package/dist/ui_components/LayerList/LayerListItem.d.ts +18 -0
  196. package/dist/ui_components/LayerList/util/LayerListItemVectorLayer.d.ts +15 -0
  197. package/dist/ui_components/LayerList/util/LayerPropertyForm.d.ts +10 -0
  198. package/dist/ui_components/LayerList/util/input/ColorPicker.d.ts +10 -0
  199. package/dist/ui_components/LoadingOverlayContext.d.ts +0 -1
  200. package/dist/ui_components/MapcomponentsTheme.d.ts +7 -0
  201. package/dist/ui_components/Tooltip.d.ts +1 -0
  202. package/dist/ui_components/TopToolbar.d.ts +1 -0
  203. package/dist/ui_components/UploadButton.d.ts +1 -0
  204. package/dist/util/Instructions.d.ts +1 -0
  205. package/package.json +67 -67
  206. package/public/thumbnails/{MlGPXViewer.png → MlGpxViewer.png} +0 -0
  207. package/rollup.config.js +68 -50
  208. package/src/@types/assets/index.d.ts +20 -0
  209. package/src/App.css +0 -55
  210. package/src/components/MapLibreMap/MapLibreMap.stories.js +38 -32
  211. package/src/components/MapLibreMap/MapLibreMap.tsx +29 -21
  212. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +50 -40
  213. package/src/components/MlCenterPosition/MlCenterPosition.tsx +22 -29
  214. package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +6 -6
  215. package/src/components/MlFollowGps/MlFollowGps.stories.js +28 -10
  216. package/src/components/MlFollowGps/MlFollowGps.tsx +38 -57
  217. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +1 -1
  218. package/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.ts +16 -10
  219. package/src/components/MlGpxViewer/MlGpxViewer.stories.tsx +4 -13
  220. package/src/components/MlGpxViewer/util/MlGpxDemoLoader.tsx +3 -1
  221. package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +21 -17
  222. package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +3 -3
  223. package/src/components/MlNavigationTools/MlNavigationTools.stories.js +4 -5
  224. package/src/components/MlNavigationTools/MlNavigationTools.tsx +30 -54
  225. package/src/components/MlScaleReference/{MlScaleReference.js → MlScaleReference.tsx} +38 -31
  226. package/src/components/MlShareMapState/MlShareMapState.stories.tsx +100 -0
  227. package/src/components/MlShareMapState/{MlShareMapState.js → MlShareMapState.tsx} +94 -58
  228. package/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx +1 -1
  229. package/src/components/MlSketchTool/MlSketchTool.tsx +1 -1
  230. package/src/components/MlThreeJsLayer/MlThreejsLayer.tsx +228 -0
  231. package/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx +7 -3
  232. package/src/components/MlWmsLoader/MlWmsLoader.stories.tsx +3 -11
  233. package/src/components/MlWmsLoader/MlWmsLoader.tsx +7 -4
  234. package/src/components/MlWmsLoader/utils/MlWmsLoaderInstructions.tsx +2 -2
  235. package/src/components/MlWmsLoader/utils/WMSLinks.tsx +1 -1
  236. package/src/contexts/MapContext.tsx +34 -20
  237. package/src/custom.d.ts +4 -0
  238. package/src/decorators/EmptyMapDecorator.js +38 -0
  239. package/src/decorators/MapContextDecorator.js +31 -26
  240. package/src/decorators/MapContextDecoratorHooks.js +29 -24
  241. package/src/decorators/MultiMapContextDecorator.js +71 -71
  242. package/src/decorators/NoNavToolsDecorator.js +25 -23
  243. package/src/decorators/ThemeDecorator.js +24 -0
  244. package/src/decorators/style.css +0 -2
  245. package/src/hooks/useCameraFollowPath/useCameraFollowPath.stories.tsx +13 -19
  246. package/src/hooks/useExportMap/lib.ts +1 -1
  247. package/src/hooks/useGpx/useGpx.stories.js +1 -1
  248. package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.stories.js +1 -1
  249. package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx +5 -4
  250. package/src/hooks/useMap.ts +1 -1
  251. package/src/hooks/useMapState.stories.js +1 -1
  252. package/src/hooks/useMapState.ts +6 -13
  253. package/src/hooks/useSource.ts +1 -1
  254. package/src/hooks/useSources.stories.js +1 -1
  255. package/src/index.ts +40 -8
  256. package/src/ui_components/LayerList/LayerList.stories.tsx +136 -0
  257. package/src/ui_components/LayerList/LayerList.tsx +12 -0
  258. package/src/ui_components/LayerList/LayerListFolder.tsx +82 -0
  259. package/src/ui_components/LayerList/LayerListItem.tsx +180 -0
  260. package/src/ui_components/LayerList/assets/sample_1.json +26 -0
  261. package/src/ui_components/LayerList/assets/sample_2.json +22 -0
  262. package/src/ui_components/LayerList/assets/sample_polygon_1.json +33 -0
  263. package/src/ui_components/LayerList/assets/style.json +2599 -0
  264. package/src/ui_components/LayerList/util/LayerListItemVectorLayer.tsx +92 -0
  265. package/src/ui_components/LayerList/util/LayerPropertyForm.tsx +125 -0
  266. package/src/ui_components/LayerList/util/input/ColorPicker.tsx +44 -0
  267. package/src/ui_components/MapcomponentsTheme.tsx +133 -0
  268. package/src/ui_components/Sidebar.tsx +16 -11
  269. package/src/ui_components/TopToolbar.tsx +1 -3
  270. package/src/util/BubbleForInstructions.js +14 -12
  271. package/tsconfig.json +3 -9
  272. package/dist/components/MlGPXViewer/MlGPXViewer.d.ts +0 -29
  273. package/dist/components/MlGPXViewer/MlGPXViewer.stories.d.ts +0 -16
  274. package/dist/components/MlGPXViewer/MlGPXViewer.test.d.ts +0 -1
  275. package/dist/components/MlGPXViewer/gpxConverter.d.ts +0 -11
  276. package/dist/components/MlGPXViewer/util/GeoJsonContext.d.ts +0 -10
  277. package/dist/components/MlGPXViewer/util/GeoJsonProvider.d.ts +0 -4
  278. package/dist/components/MlLayer/MlLayer.stories.d.ts +0 -10
  279. package/dist/custom.d.d.ts +0 -22
  280. package/dist/decorators/ThemeWrapper.d.ts +0 -3
  281. package/dist/hooks/exportMap/index.d.ts +0 -11
  282. package/dist/hooks/exportMap/lib.d.ts +0 -36
  283. package/dist/ui_components/Legend.d.ts +0 -1
  284. package/dist/ui_components/LoadingOverlay.d.ts +0 -2
  285. package/src/components/MlShareMapState/MlShareMapState.stories.js +0 -100
  286. package/src/custom.d.tsx +0 -26
  287. package/src/decorators/ThemeWrapper.tsx +0 -9
@@ -0,0 +1,228 @@
1
+ import React, { useContext, useRef, useEffect, useState } from 'react';
2
+ import MapContext from '../../contexts/MapContext';
3
+
4
+ import Button from '@mui/material/Button';
5
+ import maplibregl, { CustomLayerInterface, LngLatLike, Map } from 'maplibre-gl';
6
+ import * as THREE from 'three';
7
+ import GLTFLoader from './lib/GLTFLoader';
8
+ import PropTypes from 'prop-types';
9
+ import MapLibreGlWrapper from '../MapLibreMap/lib/MapLibreGlWrapper';
10
+
11
+ /**
12
+ * Renders obj or gltf 3D Models on the MapLibreMap referenced by props.mapId
13
+ *
14
+ * @component
15
+ */
16
+
17
+ export interface MlThreeJsLayerProps {
18
+ mapId?: string;
19
+ init?: object;
20
+ onDone?: () => void;
21
+ }
22
+
23
+ const MlThreeJsLayer = (props: MlThreeJsLayerProps) => {
24
+ const mapContext = useContext(MapContext);
25
+
26
+ const layerName = '3d-model';
27
+ const [showLayer, setShowLayer] = useState(true);
28
+ const showLayerRef = useRef(true);
29
+ const initializedRef = useRef(false);
30
+ const mapRef = useRef<MapLibreGlWrapper>();
31
+ const initFuncRef = useRef(props.init);
32
+
33
+ const cleanup = () => {
34
+ if (mapRef.current && mapRef.current.style) {
35
+ if (mapRef.current.getLayer(layerName)) {
36
+ mapRef.current.removeLayer(layerName);
37
+ }
38
+ mapRef.current = undefined;
39
+ }
40
+ };
41
+
42
+ useEffect(() => {
43
+ if (typeof initFuncRef.current === 'function') {
44
+ initFuncRef.current();
45
+ }
46
+
47
+ return cleanup;
48
+ }, []);
49
+
50
+ useEffect(() => {
51
+ if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
52
+
53
+ initializedRef.current = true;
54
+ mapRef.current = mapContext.getMap(props.mapId);
55
+
56
+ mapRef.current?.setCenter([7.099771581806502, 50.73395746209983]);
57
+ mapRef.current?.setZoom(15);
58
+ mapRef.current?.setPitch(45);
59
+
60
+ // parameters to ensure the model is georeferenced correctly on the map
61
+ const modelOrigin = [7.099771581806502, 50.73395746209983];
62
+ // 50.73395746209983, 7.099771581806502
63
+ const modelAltitude = 0;
64
+ const modelRotate = [Math.PI / 2, 90, 0];
65
+
66
+ const modelAsMercatorCoordinate = maplibregl.MercatorCoordinate.fromLngLat(
67
+ modelOrigin as LngLatLike,
68
+ modelAltitude
69
+ );
70
+
71
+ // transformation parameters to position, rotate and scale the 3D model onto the map
72
+ const modelTransform = {
73
+ translateX: modelAsMercatorCoordinate.x + 0.0000008,
74
+ translateY: modelAsMercatorCoordinate.y + 0.0000018,
75
+ translateZ: modelAsMercatorCoordinate.z,
76
+ rotateX: modelRotate[0],
77
+ rotateY: modelRotate[1],
78
+ rotateZ: modelRotate[2],
79
+ /* Since our 3D model is in real world meters, a scale transform needs to be
80
+ * applied since the CustomLayerInterface expects units in MercatorCoordinates.
81
+ */
82
+ scale: modelAsMercatorCoordinate.meterInMercatorCoordinateUnits() + 0.00000003,
83
+ };
84
+
85
+ //var THREE = window.THREE;
86
+
87
+ // configuration of the custom layer for a 3D model per the CustomLayerInterface
88
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
89
+ // @ts-ignore
90
+ const customLayer: CustomLayerInterface & {
91
+ camera: THREE.Camera | undefined;
92
+ scene: THREE.Scene | undefined;
93
+ map: Map;
94
+ renderer: THREE.WebGLRenderer;
95
+ } = {
96
+ id: '3d-model',
97
+ type: 'custom',
98
+ renderingMode: '3d',
99
+ camera: undefined,
100
+ scene: undefined,
101
+ onAdd: function (map: Map, gl: WebGL2RenderingContext) {
102
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
103
+ const self = this;
104
+ this.camera = new THREE.Camera();
105
+ this.scene = new THREE.Scene();
106
+
107
+ // create two three.js lights to illuminate the model
108
+ const directionalLight = new THREE.DirectionalLight(0xffffff);
109
+ directionalLight.position.set(0, -70, 100).normalize();
110
+ this.scene.add(directionalLight);
111
+
112
+ const directionalLight2 = new THREE.DirectionalLight(0xffffff);
113
+ directionalLight2.position.set(0, 70, 100).normalize();
114
+ this.scene.add(directionalLight2);
115
+
116
+ // use the three.js GLTF loader to add the 3D model to the three.js scene
117
+ const loader = new GLTFLoader();
118
+ loader.load(
119
+ 'assets/3D/godzilla_simple.glb',
120
+ //"https://docs.mapbox.com/mapbox-gl-js/assets/34M_17/34M_17.gltf",
121
+ function (gltf: { scene: THREE.Scene }) {
122
+ self.scene?.add(gltf.scene);
123
+ if (typeof props.onDone === 'function') {
124
+ props.onDone();
125
+ }
126
+ }.bind(this)
127
+ );
128
+ this.map = map;
129
+
130
+ // use the Mapbox GL JS map canvas for three.js
131
+ this.renderer = new THREE.WebGLRenderer({
132
+ canvas: map.getCanvas(),
133
+ context: gl,
134
+ antialias: true,
135
+ });
136
+
137
+ this.renderer.autoClear = false;
138
+ },
139
+ render: function (_gl, matrix) {
140
+ const rotationX = new THREE.Matrix4().makeRotationAxis(
141
+ new THREE.Vector3(1, 0, 0),
142
+ modelTransform.rotateX
143
+ );
144
+ const rotationY = new THREE.Matrix4().makeRotationAxis(
145
+ new THREE.Vector3(0, 1, 0),
146
+ modelTransform.rotateY
147
+ );
148
+ const rotationZ = new THREE.Matrix4().makeRotationAxis(
149
+ new THREE.Vector3(0, 0, 1),
150
+ modelTransform.rotateZ
151
+ );
152
+
153
+ const m = new THREE.Matrix4().fromArray(matrix);
154
+ const l = new THREE.Matrix4()
155
+ .makeTranslation(
156
+ modelTransform.translateX,
157
+ modelTransform.translateY,
158
+ modelTransform.translateZ
159
+ )
160
+ .scale(
161
+ new THREE.Vector3(modelTransform.scale, -modelTransform.scale, modelTransform.scale)
162
+ )
163
+ .multiply(rotationX)
164
+ .multiply(rotationY)
165
+ .multiply(rotationZ);
166
+
167
+ if (this.camera && this.scene) {
168
+ this.camera.projectionMatrix = m.multiply(l);
169
+ this.renderer.resetState();
170
+ this.renderer.render(this.scene, this.camera);
171
+ this.map.triggerRepaint();
172
+ }
173
+ },
174
+ };
175
+
176
+ mapRef.current?.addLayer(customLayer);
177
+
178
+ if (mapRef.current?.getLayer(layerName)) {
179
+ mapRef.current.setLayoutProperty(layerName, 'visibility', 'visible');
180
+ }
181
+ }, [mapContext.mapIds, mapContext, props]);
182
+
183
+ useEffect(() => {
184
+ if (!mapRef.current) return;
185
+
186
+ if (mapRef.current.getLayer(layerName)) {
187
+ // toggle layer visibility by changing the layout object's visibility property
188
+ if (showLayer) {
189
+ mapRef.current.setLayoutProperty(layerName, 'visibility', 'visible');
190
+ } else {
191
+ mapRef.current.setLayoutProperty(layerName, 'visibility', 'none');
192
+ }
193
+ }
194
+ //
195
+ }, [showLayer, mapContext]);
196
+
197
+ return (
198
+ <>
199
+ <Button
200
+ color="primary"
201
+ variant={showLayer ? 'contained' : 'outlined'}
202
+ onClick={() => {
203
+ setShowLayer(!showLayer);
204
+ showLayerRef.current = !showLayer;
205
+ }}
206
+ >
207
+ 3D
208
+ </Button>
209
+ </>
210
+ );
211
+ };
212
+
213
+ MlThreeJsLayer.propTypes = {
214
+ /**
215
+ * Id of the target MapLibre instance in mapContext
216
+ */
217
+ mapId: PropTypes.string,
218
+ /**
219
+ * function that gets called when initialized
220
+ */
221
+ init: PropTypes.func,
222
+ /**
223
+ * function that gets called when models are loaded
224
+ */
225
+ onDone: PropTypes.func,
226
+ };
227
+
228
+ export default MlThreeJsLayer;
@@ -1,9 +1,9 @@
1
- import React, { useRef, useEffect, useCallback } from "react";
1
+ import React, { useRef, useEffect, useCallback } from 'react';
2
2
  import useMap from '../../hooks/useMap';
3
3
  import { LayerSpecification } from 'maplibre-gl';
4
4
  import { VectorSourceSpecification } from 'maplibre-gl';
5
5
 
6
- interface MlVectorTileLayerProps {
6
+ export type MlVectorTileLayerProps = {
7
7
  mapId?: string;
8
8
  insertBeforeLayer?: string;
9
9
  layerId?: string;
@@ -29,6 +29,8 @@ const MlVectorTileLayer = (props: MlVectorTileLayerProps) => {
29
29
  const layerLayoutConfsRef = useRef({});
30
30
  const initializedRef = useRef(false);
31
31
 
32
+ console.log('render vt')
33
+ console.log(props.layers)
32
34
  const createLayers = useCallback(() => {
33
35
  if (!mapHook.map) return;
34
36
 
@@ -43,8 +45,10 @@ const MlVectorTileLayer = (props: MlVectorTileLayerProps) => {
43
45
  layerId.current,
44
46
  {
45
47
  type: 'vector',
46
- tiles: [props.url || ""],
48
+ tiles: [props.url || ''],
47
49
  attribution: '',
50
+ minzoom: 0,
51
+ maxzoom: 14,
48
52
  ...props.sourceOptions,
49
53
  },
50
54
  mapHook.componentId
@@ -46,25 +46,17 @@ const Template = (props: MlWmsLoaderStoryProps) => {
46
46
  <MlWmsLoaderInstructions open={guide} />
47
47
  <WMSLinks open={demoMode} close={() => setDemoMode(false)} load={loader} />
48
48
  <TopToolbar appBarStyle={{ zIndex: 1220 }}>
49
- <Button
50
- variant="contained"
51
- onClick={openGuide}
52
- sx={{ marginRight: '10px' }}
53
- >
49
+ <Button variant="contained" onClick={openGuide} sx={{ marginRight: '10px' }}>
54
50
  Guide me through
55
51
  </Button>
56
- <Button
57
- variant="contained"
58
- onClick={() => setDemoMode(!demoMode)}
59
-
60
- >
52
+ <Button variant="contained" onClick={() => setDemoMode(!demoMode)}>
61
53
  Demo WMS
62
54
  </Button>
63
55
  </TopToolbar>
64
56
 
65
57
  {!mediaIsMobile || (mediaIsMobile && !demoMode) ? (
66
58
  <Sidebar
67
- drawerPaperProps={{ sx: { top: '65px', maxWidth: '20%', padding: '40px' } }}
59
+ drawerPaperProps={{ sx: { top: '64px', maxWidth: '20%', padding: '40px' } }}
68
60
  drawerButtonStyle={{ top: '65px' }}
69
61
  sx={{ wordBreak: 'break-word' }}
70
62
  >
@@ -1,6 +1,6 @@
1
1
  import React, { useRef, useEffect, useContext, useCallback, useState, useMemo } from 'react';
2
2
 
3
- import MapContext from '../../contexts/MapContext';
3
+ import MapContext, { MapContextType } from '../../contexts/MapContext';
4
4
  import { v4 as uuidv4 } from 'uuid';
5
5
 
6
6
  import MlWmsLayer from '../MlWmsLayer/MlWmsLayer';
@@ -13,7 +13,7 @@ import List from '@mui/material/List';
13
13
  import ListItem from '@mui/material/ListItem';
14
14
  import ListItemText from '@mui/material/ListItemText';
15
15
  import IconButton from '@mui/material/IconButton';
16
- import { LngLat } from 'maplibre-gl';
16
+ import { LngLat, MapMouseEvent } from 'maplibre-gl';
17
17
  import MapLibreGlWrapper from '../MapLibreMap/lib/MapLibreGlWrapper';
18
18
  import { Layer2, Layer3 } from 'wms-capabilities';
19
19
  import { useWmsReturnType } from '../../hooks/useWms';
@@ -117,7 +117,8 @@ const MlWmsLoader = (props: MlWmsLoaderProps) => {
117
117
  }, [layers]);
118
118
 
119
119
  const getFeatureInfo = useCallback(
120
- (ev) => {
120
+ // eslint-disable-next-line @typescript-eslint/ban-types
121
+ (ev:(MapMouseEvent & Object)) => {
121
122
  if (!mapRef.current) return;
122
123
  setFeatureInfoLngLat(undefined);
123
124
  setFeatureInfoContent(undefined);
@@ -190,7 +191,9 @@ const MlWmsLoader = (props: MlWmsLoaderProps) => {
190
191
 
191
192
  const _getFeatureInfo = getFeatureInfo;
192
193
 
193
- mapRef.current.on('click', _getFeatureInfo, componentId.current);
194
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
195
+ // @ts-ignore: ts appears not to consider overloads
196
+ mapRef.current.map.on('click', _getFeatureInfo, componentId.current);
194
197
  return () => {
195
198
  mapRef.current?.map.off?.('click', _getFeatureInfo);
196
199
  };
@@ -12,7 +12,7 @@ const steps = [
12
12
  iconTransform: 'rotate(90deg)',
13
13
  iconMarginTop: '-210px',
14
14
  iconMarginLeft: '200px',
15
- zIndex: 1210
15
+ zIndex: 1210,
16
16
  },
17
17
  content: (
18
18
  <>
@@ -31,7 +31,7 @@ const steps = [
31
31
  iconTransform: 'rotate(90deg)',
32
32
  iconMarginTop: '-125px',
33
33
  iconMarginLeft: '280px',
34
- zIndex: 1210
34
+ zIndex: 1210,
35
35
  },
36
36
  content: (
37
37
  <>
@@ -111,7 +111,7 @@ export default function WMSLinks(props: wmsLinksProps) {
111
111
  </Grid>
112
112
  <Grid item xs={2}>
113
113
  <Button onClick={props.close}>
114
- <CloseIcon sx={{ color: 'black' }} />
114
+ <CloseIcon sx={{ color: 'text.primary' }} />
115
115
  </Button>
116
116
  </Grid>
117
117
  </Grid>
@@ -1,8 +1,20 @@
1
- import React, { useState, useRef } from "react";
1
+ import React, { useState, useRef, ReactNode } from 'react';
2
2
  import MapLibreGlWrapper from '../components/MapLibreMap/lib/MapLibreGlWrapper';
3
3
 
4
- const MapContext = React.createContext({} as MapContextType);
4
+ import { ThemeProvider as MUIThemeProvider } from '@mui/material/styles';
5
+ import getTheme from '../ui_components/MapcomponentsTheme';
5
6
 
7
+ export interface MapContextType {
8
+ mapIds: string[];
9
+ mapExists: (map_id: string | undefined) => boolean;
10
+ maps: MapLibreGlWrapper[];
11
+ map: MapLibreGlWrapper | undefined;
12
+ getMap: (map_id: string | undefined) => MapLibreGlWrapper;
13
+ setMap: (map: MapLibreGlWrapper) => void;
14
+ removeMap: (map_id: string | undefined) => void;
15
+ registerMap: (map_id: string | undefined, map: MapLibreGlWrapper) => void;
16
+ }
17
+ const MapContext = React.createContext({} as MapContextType);
6
18
 
7
19
  /**
8
20
  * MapComponentsProvider must be imported and wrapped around component where at least one of its child nodes requires access to a MapLibre-gl or openlayers instance that is registered in this mapContext.
@@ -11,19 +23,18 @@ MapComponentsProvider must be used one level higher than the first use of MapCon
11
23
  * MapComponentsProvider requires at least one use of the MapLibreMap component somewhere down the component tree that will create the MapLibre-gl object and set the reference at MapContext.map. For MapLibre maps it is a good idea to provide a mapId attribute to the MapLibreMap Component even if you are only using a single map instance at start. It will make a later transition to using multiple instances within the same project much easier.
12
24
  */
13
25
 
14
- const MapComponentsProvider = ({ children }:{children:any}) => {
15
- const [map, setMap] = useState<(MapLibreGlWrapper | undefined)>(undefined);
26
+ const MapComponentsProvider = ({ children }: { children: ReactNode }) => {
27
+ const [map, setMap] = useState<MapLibreGlWrapper | undefined>(undefined);
16
28
  const [mapIds, setMapIds] = useState<[...string[]]>([]);
17
- let mapIds_raw = useRef<[...string[]]>([]);
18
- let maps = useRef<any>({});
29
+ const mapIds_raw = useRef<[...string[]]>([]);
30
+ const maps = useRef<{ [key: string]: MapLibreGlWrapper }>({});
19
31
 
20
-
21
- const removeMap = (mapId:string) => {
32
+ const removeMap = (mapId: string) => {
22
33
  if (mapId) {
23
- if (typeof maps.current[mapId] !== "undefined") {
34
+ if (typeof maps.current[mapId] !== 'undefined') {
24
35
  delete maps.current[mapId];
25
36
  }
26
- let mapIdIndex = mapIds_raw.current.indexOf(mapId);
37
+ const mapIdIndex = mapIds_raw.current.indexOf(mapId);
27
38
  if (mapIdIndex > -1) {
28
39
  mapIds_raw.current.splice(mapIdIndex, 1);
29
40
  }
@@ -34,15 +45,15 @@ const MapComponentsProvider = ({ children }:{children:any}) => {
34
45
  }
35
46
  } else {
36
47
  setMap(undefined);
37
- removeMap("anonymous_map");
48
+ removeMap('anonymous_map');
38
49
  }
39
50
  };
40
51
 
41
- const setMapHandler = (mapInstance:MapLibreGlWrapper) => {
52
+ const setMapHandler = (mapInstance: MapLibreGlWrapper) => {
42
53
  setMap(mapInstance);
43
54
 
44
55
  if (mapIds.length === 0) {
45
- let mapId = "anonymous_map";
56
+ const mapId = 'anonymous_map';
46
57
  setMapIds([...mapIds, mapId]);
47
58
  maps.current[mapId] = mapInstance;
48
59
  }
@@ -53,7 +64,7 @@ const MapComponentsProvider = ({ children }:{children:any}) => {
53
64
  setMap: setMapHandler,
54
65
  maps: maps.current,
55
66
  mapIds: mapIds,
56
- registerMap: (mapId:string, mapInstance:MapLibreGlWrapper) => {
67
+ registerMap: (mapId: string, mapInstance: MapLibreGlWrapper) => {
57
68
  if (mapId && mapInstance) {
58
69
  maps.current[mapId] = mapInstance;
59
70
  mapIds_raw.current.push(mapId);
@@ -65,7 +76,7 @@ const MapComponentsProvider = ({ children }:{children:any}) => {
65
76
  }
66
77
  },
67
78
  removeMap,
68
- mapExists: (mapId:string) => {
79
+ mapExists: (mapId: string) => {
69
80
  if (mapId && Object.keys(maps.current).indexOf(mapId) === -1) {
70
81
  return false;
71
82
  } else if (!mapId && !map) {
@@ -73,7 +84,7 @@ const MapComponentsProvider = ({ children }:{children:any}) => {
73
84
  }
74
85
  return true;
75
86
  },
76
- getMap: (mapId:string):(MapLibreGlWrapper | null) => {
87
+ getMap: (mapId: string): MapLibreGlWrapper | null => {
77
88
  if (mapId && mapIds.indexOf(mapId) !== -1) {
78
89
  return maps.current[mapId];
79
90
  } else if (!mapId && map) {
@@ -82,11 +93,14 @@ const MapComponentsProvider = ({ children }:{children:any}) => {
82
93
 
83
94
  return null;
84
95
  },
85
- };
96
+ } as unknown as MapContextType;
86
97
 
87
- //@ts-ignore
88
- return <MapContext.Provider value={value}>{children}</MapContext.Provider>;
98
+ return (
99
+ <MapContext.Provider value={value}>
100
+ <MUIThemeProvider theme={getTheme('light')}>{children}</MUIThemeProvider>
101
+ </MapContext.Provider>
102
+ );
89
103
  };
90
104
 
91
105
  export { MapComponentsProvider };
92
- export default MapContext;
106
+ export default MapContext;
@@ -0,0 +1,4 @@
1
+ import { GeoJSONFeature } from "maplibre-gl";
2
+ import { GeoJSONObject } from '@turf/turf';
3
+
4
+ export type GeoJSON = (GeoJSONFeature & GeoJSONObject);
@@ -0,0 +1,38 @@
1
+ import React, { useMemo } from 'react';
2
+
3
+ import { MapComponentsProvider } from '../index';
4
+ import MapLibreMap from '../components/MapLibreMap/MapLibreMap';
5
+ import './style.css';
6
+ import MlNavgiationTools from '../components/MlNavigationTools/MlNavigationTools';
7
+ import { ThemeProvider as MUIThemeProvider } from '@mui/material/styles';
8
+ import getTheme from '../ui_components/MapcomponentsTheme';
9
+
10
+ const decorators = [
11
+ (Story, context) => {
12
+ const theme = useMemo(() => getTheme(context?.globals?.theme), [context?.globals?.theme]);
13
+
14
+ return (
15
+ <div className="fullscreen_map">
16
+ <MapComponentsProvider>
17
+ <MUIThemeProvider theme={theme}>
18
+ <Story />
19
+ <MapLibreMap
20
+ mapId="map_1"
21
+ options={{
22
+ zoom: 12.5,
23
+ center: [7.0851268, 50.73884],
24
+ }}
25
+ />
26
+ <MlNavgiationTools
27
+ sx={{ bottom: '25px', right: '5px' }}
28
+ showZoomButtons={false}
29
+ mapId="map_1"
30
+ />
31
+ </MUIThemeProvider>
32
+ </MapComponentsProvider>
33
+ </div>
34
+ );
35
+ },
36
+ ];
37
+
38
+ export default decorators;
@@ -1,34 +1,39 @@
1
- import React from "react";
1
+ import React, { useMemo } from 'react';
2
2
 
3
- import { MapComponentsProvider } from "../index";
4
- import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
5
- import "./style.css";
6
- import MlNavgiationTools from "../components/MlNavigationTools/MlNavigationTools";
7
- import ThemeWrapper from "./ThemeWrapper";
3
+ import { MapComponentsProvider } from '../index';
4
+ import MapLibreMap from '../components/MapLibreMap/MapLibreMap';
5
+ import './style.css';
6
+ import MlNavgiationTools from '../components/MlNavigationTools/MlNavigationTools';
7
+ import { ThemeProvider as MUIThemeProvider } from '@mui/material/styles';
8
+ import getTheme from '../ui_components/MapcomponentsTheme';
8
9
 
9
10
  const decorators = [
10
- (Story) => (
11
- <div className="fullscreen_map">
12
- <ThemeWrapper>
11
+ (Story, context) => {
12
+ const theme = useMemo(() => getTheme(context?.globals?.theme), [context?.globals?.theme]);
13
+
14
+ return (
15
+ <div className="fullscreen_map">
13
16
  <MapComponentsProvider>
14
- <Story />
15
- <MapLibreMap
16
- options={{
17
- zoom: 14.5,
18
- style: "https://wms.wheregroup.com/tileserver/style/osm-bright.json",
19
- center: [7.0851268, 50.73884],
20
- }}
21
- mapId="map_1"
22
- />
23
- <MlNavgiationTools
24
- sx={{ bottom: "25px", right: 0 }}
25
- showZoomButtons={false}
26
- mapId="map_1"
27
- />
17
+ <MUIThemeProvider theme={theme}>
18
+ <Story />
19
+ <MapLibreMap
20
+ options={{
21
+ zoom: 14.5,
22
+ style: 'https://wms.wheregroup.com/tileserver/style/osm-bright.json',
23
+ center: [7.0851268, 50.73884],
24
+ }}
25
+ mapId="map_1"
26
+ />
27
+ <MlNavgiationTools
28
+ sx={{ bottom: '25px', right: '5px' }}
29
+ showZoomButtons={false}
30
+ mapId="map_1"
31
+ />
32
+ </MUIThemeProvider>
28
33
  </MapComponentsProvider>
29
- </ThemeWrapper>
30
- </div>
31
- ),
34
+ </div>
35
+ );
36
+ },
32
37
  ];
33
38
 
34
39
  export default decorators;
@@ -1,34 +1,39 @@
1
- import React from "react";
1
+ import React, { useMemo } from 'react';
2
2
 
3
3
  import { MapComponentsProvider } from "../index";
4
4
  import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
5
5
  import "./style.css";
6
6
  import MlNavgiationTools from "../components/MlNavigationTools/MlNavigationTools";
7
- import ThemeWrapper from "./ThemeWrapper";
7
+ import { ThemeProvider as MUIThemeProvider } from '@mui/material/styles';
8
+ import getTheme from '../ui_components/MapcomponentsTheme';
8
9
 
9
10
  const decorators = [
10
- (Story) => (
11
- <div className="fullscreen_map">
12
- <ThemeWrapper>
13
- <MapComponentsProvider>
14
- <Story />
15
- <MapLibreMap
16
- options={{
17
- zoom: 14.5,
18
- style: "https://wms.wheregroup.com/tileserver/style/osm-bright.json",
19
- center: [7.0851268, 50.73884],
20
- }}
21
- mapId="map_1"
22
- />
23
- <MlNavgiationTools
24
- sx={{ bottom: "25px", right: 0 }}
25
- showZoomButtons={false}
26
- mapId="map_1"
27
- />
28
- </MapComponentsProvider>
29
- </ThemeWrapper>
30
- </div>
31
- ),
11
+ (Story, context) => {
12
+ const theme = useMemo(() => getTheme(context?.globals?.theme), [context?.globals?.theme]);
13
+
14
+ return (
15
+ <div className="fullscreen_map">
16
+ <MapComponentsProvider>
17
+ <MUIThemeProvider theme={theme}>
18
+ <Story />
19
+ <MapLibreMap
20
+ options={{
21
+ zoom: 14.5,
22
+ style: 'https://wms.wheregroup.com/tileserver/style/osm-bright.json',
23
+ center: [7.0851268, 50.73884],
24
+ }}
25
+ mapId="map_1"
26
+ />
27
+ <MlNavgiationTools
28
+ sx={{ bottom: '25px', right: '5px' }}
29
+ showZoomButtons={false}
30
+ mapId="map_1"
31
+ />
32
+ </MUIThemeProvider>
33
+ </MapComponentsProvider>
34
+ </div>
35
+ );
36
+ },
32
37
  ];
33
38
 
34
39
  export default decorators;