@mapcomponents/react-maplibre 0.1.45 → 0.1.49

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 (349) hide show
  1. package/.github/workflows/node_version_test.yml +2 -1
  2. package/CHANGELOG.md +23 -0
  3. package/README.md +61 -150
  4. package/coverage/clover.xml +350 -269
  5. package/coverage/coverage-final.json +11 -9
  6. package/coverage/lcov-report/index.html +95 -80
  7. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +61 -31
  8. package/coverage/lcov-report/src/components/MapLibreMap/index.html +17 -17
  9. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +1 -1
  10. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
  11. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +72 -66
  12. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +18 -18
  13. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
  14. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  15. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +1 -1
  16. package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
  17. package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.html +1 -1
  18. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +1 -1
  19. package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
  20. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +1 -1
  21. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  22. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +188 -53
  23. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +21 -21
  24. package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +1 -1
  25. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  26. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +1 -1
  27. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
  28. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +1 -1
  29. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
  30. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +2 -2
  31. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
  32. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  33. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  34. package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +1 -1
  35. package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
  36. package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +265 -0
  37. package/coverage/lcov-report/src/components/MlMeasureTool/index.html +116 -0
  38. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
  39. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  40. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +1 -1
  41. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
  42. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
  43. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +232 -0
  44. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +25 -10
  45. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
  46. package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
  47. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
  48. package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
  49. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +1 -1
  50. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  51. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
  52. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
  53. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +1 -1
  54. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
  55. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  56. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  57. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +74 -20
  58. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +19 -19
  59. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
  60. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
  61. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +80 -20
  62. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +21 -21
  63. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +2 -2
  64. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
  65. package/coverage/lcov-report/src/contexts/MapContext.tsx.html +23 -23
  66. package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
  67. package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
  68. package/coverage/lcov-report/src/contexts/index.html +1 -1
  69. package/coverage/lcov-report/src/hooks/index.html +19 -19
  70. package/coverage/lcov-report/src/hooks/useLayer.ts.html +95 -71
  71. package/coverage/lcov-report/src/hooks/useMap.ts.html +25 -25
  72. package/coverage/lcov-report/src/hooks/useMapState.ts.html +28 -28
  73. package/coverage/lcov-report/src/hooks/useWms.js.html +2 -2
  74. package/coverage/lcov-report/src/index.html +1 -1
  75. package/coverage/lcov-report/src/index.ts.html +12 -6
  76. package/coverage/lcov.info +688 -497
  77. package/dist/components/MapLibreMap/MapLibreMap.d.ts +31 -0
  78. package/dist/components/MapLibreMap/MapLibreMap.stories.d.ts +15 -0
  79. package/dist/components/MapLibreMap/MapLibreMap.test.d.ts +1 -0
  80. package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +75 -0
  81. package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.test.d.ts +1 -0
  82. package/dist/components/MlBasicComponent.d.ts +5 -0
  83. package/dist/components/MlComponentTemplate/MlComponentTemplate.d.ts +22 -0
  84. package/dist/components/MlComponentTemplate/MlComponentTemplate.stories.d.ts +10 -0
  85. package/dist/components/MlCreatePdfButton/MlCreatePdfButton.d.ts +21 -0
  86. package/dist/components/MlCreatePdfButton/MlCreatePdfButton.stories.d.ts +10 -0
  87. package/dist/components/MlCreatePdfButton/lib/createPdf.d.ts +2 -0
  88. package/dist/components/MlCreatePdfButton/lib/nominatimMap.d.ts +2 -0
  89. package/dist/components/MlFeatureEditor/MlFeatureEditor.d.ts +35 -0
  90. package/dist/components/MlFeatureEditor/MlFeatureEditor.stories.d.ts +15 -0
  91. package/dist/components/MlFeatureEditor/MlFeatureEditor.test.d.ts +1 -0
  92. package/dist/components/MlFeatureEditor/custom-direct-select-mode.d.ts +37 -0
  93. package/dist/components/MlFeatureEditor/custom-polygon-mode.d.ts +16 -0
  94. package/dist/components/MlFeatureEditor/custom-select-mode.d.ts +37 -0
  95. package/dist/components/MlFeatureEditor/lib/common_selectors.d.ts +11 -0
  96. package/dist/components/MlFeatureEditor/lib/constants.d.ts +85 -0
  97. package/dist/components/MlFeatureEditor/lib/constrain_feature_movement.d.ts +2 -0
  98. package/dist/components/MlFeatureEditor/lib/create_midpoint.d.ts +15 -0
  99. package/dist/components/MlFeatureEditor/lib/create_supplementary_points.d.ts +2 -0
  100. package/dist/components/MlFeatureEditor/lib/create_vertex.d.ts +13 -0
  101. package/dist/components/MlFeatureEditor/lib/double_click_zoom.d.ts +7 -0
  102. package/dist/components/MlFeatureEditor/lib/euclidean_distance.d.ts +5 -0
  103. package/dist/components/MlFeatureEditor/lib/features_at.d.ts +7 -0
  104. package/dist/components/MlFeatureEditor/lib/get_features_and_set_cursor.d.ts +1 -0
  105. package/dist/components/MlFeatureEditor/lib/is_click.d.ts +1 -0
  106. package/dist/components/MlFeatureEditor/lib/is_event_at_coordinates.d.ts +6 -0
  107. package/dist/components/MlFeatureEditor/lib/is_tap.d.ts +3 -0
  108. package/dist/components/MlFeatureEditor/lib/map_event_to_bounding_box.d.ts +12 -0
  109. package/dist/components/MlFeatureEditor/lib/mode_handler.d.ts +24 -0
  110. package/dist/components/MlFeatureEditor/lib/mouse_event_point.d.ts +11 -0
  111. package/dist/components/MlFeatureEditor/lib/move_features.d.ts +2 -0
  112. package/dist/components/MlFeatureEditor/lib/sort_features.d.ts +2 -0
  113. package/dist/components/MlFeatureEditor/lib/string_set.d.ts +21 -0
  114. package/dist/components/MlFeatureEditor/lib/string_sets_are_equal.d.ts +5 -0
  115. package/dist/components/MlFeatureEditor/lib/theme.d.ts +88 -0
  116. package/dist/components/MlFeatureEditor/lib/to_dense_array.d.ts +12 -0
  117. package/dist/components/MlFeatureEditor/lib/utils.d.ts +10 -0
  118. package/dist/components/MlFillExtrusionLayer/MlFillExtrusionLayer.d.ts +61 -0
  119. package/dist/components/MlFillExtrusionLayer/MlFillExtrusionLayer.stories.d.ts +10 -0
  120. package/dist/components/MlFillExtrusionLayer/MlFillExtrusionLayer.test.d.ts +1 -0
  121. package/dist/components/MlFollowGps/MlFollowGps.d.ts +80 -0
  122. package/dist/components/MlFollowGps/MlFollowGps.stories.d.ts +10 -0
  123. package/dist/components/MlFollowGps/MlFollowGps.test.d.ts +1 -0
  124. package/dist/components/MlGPXViewer/MlGPXViewer.d.ts +29 -0
  125. package/dist/components/MlGPXViewer/MlGPXViewer.stories.d.ts +16 -0
  126. package/dist/components/MlGPXViewer/MlGPXViewer.test.d.ts +1 -0
  127. package/dist/components/MlGPXViewer/gpxConverter.d.ts +11 -0
  128. package/dist/components/MlGPXViewer/util/GeoJsonContext.d.ts +10 -0
  129. package/dist/components/MlGPXViewer/util/GeoJsonProvider.d.ts +4 -0
  130. package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +69 -0
  131. package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +12 -0
  132. package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.test.d.ts +1 -0
  133. package/dist/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.d.ts +2 -0
  134. package/dist/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.d.ts +2 -0
  135. package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.d.ts +29 -0
  136. package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.d.ts +10 -0
  137. package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.test.d.ts +1 -0
  138. package/dist/components/MlLayer/MlLayer.d.ts +26 -0
  139. package/dist/components/MlLayer/MlLayer.stories.d.ts +10 -0
  140. package/dist/components/MlLayer/MlLayer.test.d.ts +1 -0
  141. package/dist/components/MlLayerMagnify/MlLayerMagnify.d.ts +27 -0
  142. package/dist/components/MlLayerMagnify/MlLayerMagnify.stories.d.ts +10 -0
  143. package/dist/components/MlLayerMagnify/MlLayerMagnify.test.d.ts +1 -0
  144. package/dist/components/MlLayerSwipe/MlLayerSwipe.d.ts +16 -0
  145. package/dist/components/MlLayerSwipe/MlLayerSwipe.stories.d.ts +11 -0
  146. package/dist/components/MlLayerSwipe/MlLayerSwipe.test.d.ts +1 -0
  147. package/dist/components/MlLayerSwitcher/MlLayerSwitcher.d.ts +30 -0
  148. package/dist/components/MlLayerSwitcher/MlLayerSwitcher.stories.d.ts +13 -0
  149. package/dist/components/MlLayerSwitcher/components/LayerBox.d.ts +6 -0
  150. package/dist/components/MlMarker/MlMarker.d.ts +33 -0
  151. package/dist/components/MlMarker/MlMarker.stories.d.ts +9 -0
  152. package/dist/components/MlMeasureTool/MlMeasureTool.d.ts +20 -0
  153. package/dist/components/MlMeasureTool/MlMeasureTool.stories.d.ts +11 -0
  154. package/dist/components/MlNavigationCompass/MlNavigationCompass.d.ts +47 -0
  155. package/dist/components/MlNavigationCompass/MlNavigationCompass.stories.d.ts +10 -0
  156. package/dist/components/MlNavigationCompass/MlNavigationCompass.test.d.ts +1 -0
  157. package/dist/components/MlNavigationTools/MlNavigationTools.d.ts +9 -0
  158. package/dist/components/MlNavigationTools/MlNavigationTools.stories.d.ts +13 -0
  159. package/dist/components/MlOsmLayer/MlOsmLayer.d.ts +18 -0
  160. package/dist/components/MlOsmLayer/MlOsmLayer.stories_.d.ts +16 -0
  161. package/dist/components/MlOsmLayer/MlOsmLayer.test.d.ts +1 -0
  162. package/dist/components/MlScaleReference/MlScaleReference.d.ts +2 -0
  163. package/dist/components/MlScaleReference/MlScaleReference.stories.d.ts +14 -0
  164. package/dist/components/MlShareMapState/MlShareMapState.d.ts +22 -0
  165. package/dist/components/MlShareMapState/MlShareMapState.stories.d.ts +10 -0
  166. package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.d.ts +20 -0
  167. package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.d.ts +16 -0
  168. package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.test.d.ts +1 -0
  169. package/dist/components/MlThreeJsLayer/MlThreeJsLayer.d.ts +15 -0
  170. package/dist/components/MlThreeJsLayer/MlThreeJsLayer.stories.d.ts +16 -0
  171. package/dist/components/MlThreeJsLayer/MlThreeJsLayer.test.d.ts +1 -0
  172. package/dist/components/MlThreeJsLayer/lib/GLTFLoader.d.ts +17 -0
  173. package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +68 -0
  174. package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.stories.d.ts +13 -0
  175. package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.test.d.ts +1 -0
  176. package/dist/components/MlTransitionGeoJsonLayer/util/transitionFunctions.d.ts +2 -0
  177. package/dist/components/MlUseMapDebugger/MlUseMapDebugger.d.ts +22 -0
  178. package/dist/components/MlUseMapDebugger/MlUseMapDebugger.stories.d.ts +13 -0
  179. package/dist/components/MlVectorTileLayer/MlVectorTileLayer.d.ts +37 -0
  180. package/dist/components/MlVectorTileLayer/MlVectorTileLayer.stories.d.ts +13 -0
  181. package/dist/components/MlVectorTileLayer/MlVectorTileLayer.test.d.ts +1 -0
  182. package/dist/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.d.ts +22 -0
  183. package/dist/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.d.ts +13 -0
  184. package/dist/components/MlWmsLayer/MlWmsLayer.d.ts +100 -0
  185. package/dist/components/MlWmsLayer/MlWmsLayer.stories.d.ts +13 -0
  186. package/dist/components/MlWmsLayer/MlWmsLayer.test.d.ts +1 -0
  187. package/dist/components/MlWmsLoader/MlWmsLoader.d.ts +48 -0
  188. package/dist/components/MlWmsLoader/MlWmsLoader.stories.d.ts +13 -0
  189. package/dist/contexts/MapComponentsProvider.test.d.ts +1 -0
  190. package/dist/contexts/MapContext.d.ts +13 -0
  191. package/dist/contexts/SimpleDataContext.d.ts +4 -0
  192. package/dist/contexts/SimpleDataProvider.d.ts +8 -0
  193. package/dist/contexts/SimpleDataProvider.test.d.ts +1 -0
  194. package/dist/custom.d.d.ts +22 -0
  195. package/dist/decorators/MapContextDecorator.d.ts +2 -0
  196. package/dist/decorators/MultiMapContextDecorator.d.ts +2 -0
  197. package/dist/hooks/useLayer.d.ts +24 -0
  198. package/dist/hooks/useLayer.test.d.ts +1 -0
  199. package/dist/hooks/useMap.d.ts +14 -0
  200. package/dist/hooks/useMapState.d.ts +62 -0
  201. package/dist/hooks/useMapState.stories.d.ts +14 -0
  202. package/dist/hooks/useWms.d.ts +18 -0
  203. package/dist/index.d.ts +32 -0
  204. package/dist/index.esm.js +193 -60
  205. package/dist/index.esm.js.map +1 -1
  206. package/dist/setupTests.d.ts +12 -0
  207. package/dist/stories/components/Readme.d.ts +2 -0
  208. package/dist/ui_components/ImageLoader.d.ts +2 -0
  209. package/dist/ui_components/Legend.d.ts +1 -0
  210. package/dist/ui_components/LoadingOverlay.d.ts +2 -0
  211. package/dist/ui_components/LoadingOverlayContext.d.ts +11 -0
  212. package/dist/ui_components/Sidebar.d.ts +1 -0
  213. package/dist/ui_components/Tooltip.d.ts +1 -0
  214. package/dist/ui_components/TopToolbar.d.ts +1 -0
  215. package/dist/util/index.d.ts +3 -0
  216. package/dist/util/layerRemovalTest.d.ts +2 -0
  217. package/dist/util/sourceRemovalTest.d.ts +2 -0
  218. package/package.json +2 -1
  219. package/public/catalogue/mc_meta.json +1 -0
  220. package/public/thumbnails/MlMeasureTool.png +0 -0
  221. package/src/components/MapLibreMap/MapLibreMap.stories.js +75 -20
  222. package/src/components/MapLibreMap/MapLibreMap.tsx +12 -2
  223. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +2 -2
  224. package/src/components/MlFeatureEditor/MlFeatureEditor.stories.js +1 -2
  225. package/src/components/MlFeatureEditor/MlFeatureEditor.test.js +3 -3
  226. package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +40 -38
  227. package/src/components/MlFeatureEditor/lib/utils.js +1 -2
  228. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +1 -1
  229. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx +82 -37
  230. package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +1 -1
  231. package/src/components/MlMeasureTool/MlMeasureTool.doc.de.md +3 -0
  232. package/src/components/MlMeasureTool/MlMeasureTool.meta.json +15 -0
  233. package/src/components/MlMeasureTool/MlMeasureTool.stories.js +96 -0
  234. package/src/components/MlMeasureTool/MlMeasureTool.tsx +60 -0
  235. package/src/components/MlOsmLayer/{MlOsmLayer.stories.js → MlOsmLayer.stories_.js} +0 -0
  236. package/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx +26 -8
  237. package/src/components/MlWmsLayer/MlWmsLayer.stories.js +2 -3
  238. package/src/components/MlWmsLayer/MlWmsLayer.tsx +27 -7
  239. package/src/components/MlWmsLoader/MlWmsLoader.stories.js +1 -1
  240. package/src/components/MlWmsLoader/MlWmsLoader.tsx +1 -1
  241. package/src/hooks/useLayer.test.js +205 -0
  242. package/src/hooks/useLayer.ts +15 -7
  243. package/src/hooks/useWms.js +1 -1
  244. package/src/index.ts +5 -4
  245. package/src/util/layerRemovalTest.js +5 -0
  246. package/tsconfig.json +35 -7
  247. package/docs-build/0.20735a16c2ad9677fe7d.manager.bundle.js +0 -1
  248. package/docs-build/0.b1b9b035.iframe.bundle.js +0 -2
  249. package/docs-build/0.b1b9b035.iframe.bundle.js.map +0 -1
  250. package/docs-build/1.c50fb367.iframe.bundle.js +0 -10
  251. package/docs-build/1.c50fb367.iframe.bundle.js.map +0 -1
  252. package/docs-build/17.2e544968.iframe.bundle.js +0 -2
  253. package/docs-build/17.2e544968.iframe.bundle.js.map +0 -1
  254. package/docs-build/18.42087006.iframe.bundle.js +0 -17
  255. package/docs-build/18.42087006.iframe.bundle.js.map +0 -1
  256. package/docs-build/19.7e782442.iframe.bundle.js +0 -14
  257. package/docs-build/19.7e782442.iframe.bundle.js.map +0 -1
  258. package/docs-build/2.e58dc625.iframe.bundle.js +0 -2
  259. package/docs-build/2.e58dc625.iframe.bundle.js.map +0 -1
  260. package/docs-build/20.f009289a.iframe.bundle.js +0 -2
  261. package/docs-build/20.f009289a.iframe.bundle.js.map +0 -1
  262. package/docs-build/21.1cdc9040.iframe.bundle.js +0 -4
  263. package/docs-build/21.1cdc9040.iframe.bundle.js.map +0 -1
  264. package/docs-build/22.c9e6b2d7.iframe.bundle.js +0 -22
  265. package/docs-build/22.c9e6b2d7.iframe.bundle.js.map +0 -1
  266. package/docs-build/3.a8172b89.iframe.bundle.js +0 -2
  267. package/docs-build/3.a8172b89.iframe.bundle.js.map +0 -1
  268. package/docs-build/4.8ac31bba1926f4f011b0.manager.bundle.js +0 -2
  269. package/docs-build/4.8ac31bba1926f4f011b0.manager.bundle.js.LICENSE.txt +0 -8
  270. package/docs-build/5.daf044a6c0f55d839078.manager.bundle.js +0 -1
  271. package/docs-build/6.99fba2cf6af0473f8209.manager.bundle.js +0 -2
  272. package/docs-build/6.99fba2cf6af0473f8209.manager.bundle.js.LICENSE.txt +0 -12
  273. package/docs-build/7.b6a48b90f61cb575c2e4.manager.bundle.js +0 -1
  274. package/docs-build/8.50518a5391398d9d5812.manager.bundle.js +0 -1
  275. package/docs-build/assets/3D/godzilla_simple.glb +0 -0
  276. package/docs-build/assets/dop.png +0 -0
  277. package/docs-build/assets/historic.png +0 -0
  278. package/docs-build/assets/marker.png +0 -0
  279. package/docs-build/assets/osm.png +0 -0
  280. package/docs-build/assets/sample.gpx +0 -716
  281. package/docs-build/catalogue/.gitkeep +0 -0
  282. package/docs-build/catalogue/mc_meta.json +0 -1
  283. package/docs-build/favicon.ico +0 -0
  284. package/docs-build/iframe.html +0 -348
  285. package/docs-build/index.html +0 -59
  286. package/docs-build/logo.png +0 -0
  287. package/docs-build/main.ef9704b1252e8efa56a0.manager.bundle.js +0 -1
  288. package/docs-build/main~24120820.edd86ba9.iframe.bundle.js +0 -2
  289. package/docs-build/main~24120820.edd86ba9.iframe.bundle.js.map +0 -1
  290. package/docs-build/manifest.json +0 -25
  291. package/docs-build/robots.txt +0 -3
  292. package/docs-build/runtime~main.6e6ed7dc9ea4785ef286.manager.bundle.js +0 -1
  293. package/docs-build/static/media/mapcomponents_logo.98b01a05.png +0 -0
  294. package/docs-build/static/media/wg-marker.bf3eeb2d.png +0 -0
  295. package/docs-build/thumbnails/MapLibreMap.png +0 -0
  296. package/docs-build/thumbnails/MlCameraFollowPath.png +0 -0
  297. package/docs-build/thumbnails/MlCreatePdfButton.png +0 -0
  298. package/docs-build/thumbnails/MlDeckGlLayer.png +0 -0
  299. package/docs-build/thumbnails/MlDeckGlTerrainLayer.png +0 -0
  300. package/docs-build/thumbnails/MlDemoDashboard.png +0 -0
  301. package/docs-build/thumbnails/MlFeatureEditor.png +0 -0
  302. package/docs-build/thumbnails/MlFillExtrusionLayer.png +0 -0
  303. package/docs-build/thumbnails/MlFollowGps.png +0 -0
  304. package/docs-build/thumbnails/MlGPXViewer.png +0 -0
  305. package/docs-build/thumbnails/MlGeoJsonLayer.png +0 -0
  306. package/docs-build/thumbnails/MlHillshadeLayer.png +0 -0
  307. package/docs-build/thumbnails/MlIconLayer.png +0 -0
  308. package/docs-build/thumbnails/MlLaermkarte.png +0 -0
  309. package/docs-build/thumbnails/MlLayerMagnify.png +0 -0
  310. package/docs-build/thumbnails/MlLayerSwipe.png +0 -0
  311. package/docs-build/thumbnails/MlMapDrawTools.png +0 -0
  312. package/docs-build/thumbnails/MlMobilerImker.png +0 -0
  313. package/docs-build/thumbnails/MlNavigationCompass.png +0 -0
  314. package/docs-build/thumbnails/MlNavigationTools.png +0 -0
  315. package/docs-build/thumbnails/MlOsmLayer.png +0 -0
  316. package/docs-build/thumbnails/MlScaleReference.png +0 -0
  317. package/docs-build/thumbnails/MlSpatialElevationProfile.png +0 -0
  318. package/docs-build/thumbnails/MlThreeJsLayer.png +0 -0
  319. package/docs-build/thumbnails/MlTransitionGeoJsonLayer.png +0 -0
  320. package/docs-build/thumbnails/MlVectorTileLayer.png +0 -0
  321. package/docs-build/thumbnails/MlWanderApp.png +0 -0
  322. package/docs-build/thumbnails/MlWmsLayer.png +0 -0
  323. package/docs-build/thumbnails/MlWmsLoader.png +0 -0
  324. package/docs-build/vendors~main.4b570b3072ba06ee44b5.manager.bundle.js +0 -2
  325. package/docs-build/vendors~main.4b570b3072ba06ee44b5.manager.bundle.js.LICENSE.txt +0 -104
  326. package/docs-build/vendors~main~0ad7406a.2054ae7c.iframe.bundle.js +0 -8
  327. package/docs-build/vendors~main~0ad7406a.2054ae7c.iframe.bundle.js.map +0 -1
  328. package/docs-build/vendors~main~0f485567.de36692f.iframe.bundle.js +0 -2
  329. package/docs-build/vendors~main~0f485567.de36692f.iframe.bundle.js.map +0 -1
  330. package/docs-build/vendors~main~41a6ab2c.a947ed53.iframe.bundle.js +0 -2
  331. package/docs-build/vendors~main~41a6ab2c.a947ed53.iframe.bundle.js.map +0 -1
  332. package/docs-build/vendors~main~52589227.1d1558cd.iframe.bundle.js +0 -8
  333. package/docs-build/vendors~main~52589227.1d1558cd.iframe.bundle.js.map +0 -1
  334. package/docs-build/vendors~main~57c1f6cb.6a433835.iframe.bundle.js +0 -2
  335. package/docs-build/vendors~main~57c1f6cb.6a433835.iframe.bundle.js.map +0 -1
  336. package/docs-build/vendors~main~73914085.a8e03e3b.iframe.bundle.js +0 -293
  337. package/docs-build/vendors~main~73914085.a8e03e3b.iframe.bundle.js.map +0 -1
  338. package/docs-build/vendors~main~9c5b28f6.7b8beed1.iframe.bundle.js +0 -7
  339. package/docs-build/vendors~main~9c5b28f6.7b8beed1.iframe.bundle.js.map +0 -1
  340. package/docs-build/vendors~main~b5906859.7f66dcaf.iframe.bundle.js +0 -21
  341. package/docs-build/vendors~main~b5906859.7f66dcaf.iframe.bundle.js.map +0 -1
  342. package/docs-build/vendors~main~b8f44717.7053e467.iframe.bundle.js +0 -89
  343. package/docs-build/vendors~main~b8f44717.7053e467.iframe.bundle.js.map +0 -1
  344. package/docs-build/vendors~main~b9cf3951.a4fd68f5.iframe.bundle.js +0 -63
  345. package/docs-build/vendors~main~b9cf3951.a4fd68f5.iframe.bundle.js.map +0 -1
  346. package/docs-build/vendors~main~d939e436.ba1cad1b.iframe.bundle.js +0 -2
  347. package/docs-build/vendors~main~d939e436.ba1cad1b.iframe.bundle.js.map +0 -1
  348. package/docs-build/vendors~main~f420d588.59c93444.iframe.bundle.js +0 -107
  349. package/docs-build/vendors~main~f420d588.59c93444.iframe.bundle.js.map +0 -1
@@ -0,0 +1,12 @@
1
+ export var uuid_regex: string;
2
+ export namespace mockMapLibreMethods {
3
+ const on: any;
4
+ const off: any;
5
+ const addControl: any;
6
+ const removeControl: any;
7
+ const hasControl: any;
8
+ function getCanvas(): HTMLCanvasElement;
9
+ function getContainer(): {
10
+ style: {};
11
+ };
12
+ }
@@ -0,0 +1,2 @@
1
+ export default Readme;
2
+ declare function Readme(): JSX.Element;
@@ -0,0 +1,2 @@
1
+ export default ImageLoader;
2
+ declare function ImageLoader(props: any): JSX.Element;
@@ -0,0 +1 @@
1
+ export default function Legend(props: any): JSX.Element;
@@ -0,0 +1,2 @@
1
+ export default LoadingOverlay;
2
+ declare function LoadingOverlay(): JSX.Element;
@@ -0,0 +1,11 @@
1
+ export const LoadingOverlayContext: React.Context<{}>;
2
+ export function LoadingOverlayProvider({ children }: {
3
+ children: any;
4
+ }): JSX.Element;
5
+ export namespace LoadingOverlayProvider {
6
+ namespace propTypes {
7
+ const children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
8
+ }
9
+ }
10
+ import React from "react";
11
+ import PropTypes from "prop-types";
@@ -0,0 +1 @@
1
+ export default function Sidebar(props: any): JSX.Element;
@@ -0,0 +1 @@
1
+ export default function Legend(props: any): JSX.Element;
@@ -0,0 +1 @@
1
+ export default function TopToolbar(props: any): JSX.Element;
@@ -0,0 +1,3 @@
1
+ import layerRemovalTest from "./layerRemovalTest";
2
+ import sourceRemovalTest from "./sourceRemovalTest";
3
+ export { layerRemovalTest, sourceRemovalTest };
@@ -0,0 +1,2 @@
1
+ export default layerRemovalTest;
2
+ declare function layerRemovalTest(ComponentName: any, Component: any, regexLayerNameTest: any, humanReadableLayerName: any, beforeWrapperInit: any, afterWrapperInit: any, createWrapperFunction: any): void;
@@ -0,0 +1,2 @@
1
+ export default sourceRemovalTest;
2
+ declare function sourceRemovalTest(ComponentName: any, Component: any, regexLayerNameTest: any, humanReadableLayerName: any, beforeWrapperInit: any, afterWrapperInit: any): void;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@mapcomponents/react-maplibre",
3
- "version": "0.1.45",
3
+ "version": "0.1.49",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.esm.js",
7
7
  "source": "src/index.ts",
8
+ "types": "dist/index.d.ts",
8
9
  "scripts": {
9
10
  "build": "rollup -c",
10
11
  "start": "start-storybook -p 6006 -s public",
@@ -0,0 +1 @@
1
+ {"MlCreatePdfButton":{"name":"MlCreatePdfButton","title":"Export PDF","description":"Creates a PDF file with the current map view.","i18n":{"de":{"title":"PDF Export","description":"Erzeugt eine PDF Datei aus der aktuellen Kartenansicht."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlFeatureEditor":{"name":"MlFeatureEditor","title":"Sketch tools","description":"Enables the editing of Point, Linestring and Polygon GeoJSON Files.","i18n":{"de":{"title":"Skizzen Werkzeug","description":"Erzeugen und Bearbeiten von Objekten."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":0},"MlFillExtrusionLayer":{"name":"MlFillExtrusionLayer","title":"Simple 3D buildings","description":"Draws a level, out of the building outline and the height, extrudes 3D Objects as buildings.","i18n":{"de":{"title":"3D Gebäude","description":"Zeichnet eine Ebene mit einfach, aus den Gebäudeumrissen und anhand der Höhen, extrudierten 3D Objekten als Gebäude."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlFollowGps":{"name":"MlFollowGps","title":"GPS tracker","description":"","i18n":{"de":{"title":"GPS-Tracker","description":""}},"tags":[],"category":"","type":"component","price":0},"MlGeoJsonLayer":{"name":"MlGeoJsonLayer","title":"GeoJSON layer","description":"","i18n":{"de":{"title":"GeoJSON Darstellung","description":""}},"tags":[],"category":"","type":"component","price":0},"MlGPXViewer":{"name":"MlGPXViewer","title":"GPX viewer","description":"","i18n":{"de":{"title":"GPX Darstellung","description":""}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlLayerMagnify":{"name":"MlLayerMagnify","title":"Map magnifier","description":"Hides a part of a map that is superimposed on another MapLibre map.","i18n":{"de":{"title":"Kartenlupe","description":"Kartenlupe blendet einen Teil einer, von zwei übereinanderliegenden, MapLibre Karten aus."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlLayerSwipe":{"name":"MlLayerSwipe","title":"Map curtain","description":"Map curtain hides an area of the top one of two overlaying MapLibre maps.","i18n":{"de":{"title":"Kartenvorhang","description":"Kartenvorhangs blendet einen Teil einer, von zwei übereinanderliegenden, MapLibre Karten aus."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlMeasureTool":{"name":"MlMeasureTool","title":"Measure tool","description":"","i18n":{"de":{"title":"Messwerkzeug","description":""}},"tags":[],"category":"","type":"component","price":0},"MlNavigationCompass":{"name":"MlNavigationCompass","title":"Compass","description":"","i18n":{"de":{"title":"Kompass","description":""}},"tags":[],"category":"","type":"component","price":0},"MlNavigationTools":{"name":"MlNavigationTools","title":"Navigation tools","description":"","i18n":{"de":{"title":"Navigationswerkzeuge","description":""}},"tags":[],"category":"","type":"component","price":0},"MlScaleReference":{"name":"MlScaleReference","title":"Reference scale","description":"","i18n":{"de":{"title":"Maßstabsreferenz","description":""}},"tags":[],"category":"","type":"component","price":0},"MlSpatialElevationProfile":{"name":"MlSpatialElevationProfile","title":"3D height profile","description":"Draws a level, out of the building outline and the height, extrudes 3D Objects as buildings.","i18n":{"de":{"title":"3D Höhenprofil","description":"Zeichnet eine Ebene mit einfach, aus den Gebäudeumrissen und anhand der Höhen, extrudierten 3D Objekten als Gebäude."}},"tags":["Map add-on"],"category":"add-ons","type":"component","price":5000},"MlThreeJsLayer":{"name":"MlThreeJsLayer","title":"3D Model","description":"Layer Component, that makes it possible to show 3D Models on the map.","i18n":{"de":{"title":"3D Modelle","description":"Layer Component, das es ermöglicht 3D Modelle auf der Karte darzustellen."}},"tags":["Map layer"],"category":"layer","type":"component","price":5000},"MlTransitionGeoJsonLayer":{"name":"MlTransitionGeoJsonLayer","title":"GeoJSON layer","description":"","i18n":{"de":{"title":"GeoJSON Ebene","description":""}},"tags":[],"category":"","type":"component","price":0},"MlVectorTileLayer":{"name":"MlVectorTileLayer","title":"Vector tile layer","description":"Adds a vector tile layer to the map","i18n":{"de":{"title":"Vector Tiles","description":"Baustein: Vektorenkacheln/Vector Tiles (der Anwendung/Karte hinzufügen)"}},"tags":["Map layer"],"category":"layer","type":"component","price":5000},"MlWmsLoader":{"name":"MlWmsLoader","title":"WMS loader","description":"","i18n":{"de":{"title":"WMS Feature Info","description":""}},"tags":[],"category":"","type":"component","price":0}}
@@ -1,7 +1,11 @@
1
- import React from "react";
1
+ import React, { useState } from "react";
2
2
 
3
3
  import MapLibreMap from "./MapLibreMap";
4
4
  import { MapComponentsProvider } from "../../contexts/MapContext";
5
+ import MlGeoJsonLayer from "../MlGeoJsonLayer/MlGeoJsonLayer";
6
+ import { Button } from "@mui/material";
7
+ import TopToolbar from "../../ui_components/TopToolbar";
8
+ import sample_geojson_1 from "../MlGeoJsonLayer/assets/sample_1.json";
5
9
 
6
10
  const storyoptions = {
7
11
  title: "Core/MapLibreMap",
@@ -16,30 +20,81 @@ const storyoptions = {
16
20
  };
17
21
  export default storyoptions;
18
22
 
19
- const Template = (args) => (
20
- <MapComponentsProvider>
21
- <MapLibreMap
22
- options={args.options}
23
- style={{
24
- position: "absolute",
25
- height: "100vh",
26
- width: "100vw",
27
- top: 0,
28
- right: 0,
29
- left: 0,
30
- bottom: 0,
31
- zIndex: 100,
32
- }}
33
- />
34
- </MapComponentsProvider>
35
- );
23
+ const Template = (args) => {
24
+ return (
25
+ <MapComponentsProvider>
26
+ <MapLibreMap
27
+ options={args.options}
28
+ style={{
29
+ position: "absolute",
30
+ height: "100vh",
31
+ width: "100vw",
32
+ top: 0,
33
+ right: 0,
34
+ left: 0,
35
+ bottom: 0,
36
+ zIndex: 100,
37
+ }}
38
+ />
39
+ </MapComponentsProvider>
40
+ );
41
+ };
36
42
 
37
43
  export const ExampleConfig = Template.bind({});
38
44
  ExampleConfig.args = {
39
45
  options: {
40
46
  style: "https://wms.wheregroup.com/tileserver/style/osm-bright.json",
41
47
  center: [8.607, 53.1409349],
42
- zoom: 14
48
+ zoom: 14,
49
+ },
50
+ };
51
+
52
+ const StyleChangeTemplate = (args) => {
53
+ const [activeStyle, setActiveStyle] = useState(
54
+ "https://wms.wheregroup.com/tileserver/style/osm-fiord-color.json"
55
+ );
56
+
57
+ return (
58
+ <MapComponentsProvider>
59
+ <TopToolbar>
60
+ <Button
61
+ onClick={() =>
62
+ setActiveStyle("https://wms.wheregroup.com/tileserver/style/osm-bright.json")
63
+ }
64
+ >
65
+ OSM-Bright
66
+ </Button>
67
+ <Button
68
+ onClick={() =>
69
+ setActiveStyle("https://wms.wheregroup.com/tileserver/style/osm-fiord-color.json")
70
+ }
71
+ >
72
+ OSM-Fiord-Color
73
+ </Button>
74
+ </TopToolbar>
75
+ <MapLibreMap
76
+ options={{ ...args.options, style: activeStyle }}
77
+ style={{
78
+ position: "absolute",
79
+ height: "100vh",
80
+ width: "100vw",
81
+ top: 0,
82
+ right: 0,
83
+ left: 0,
84
+ bottom: 0,
85
+ zIndex: 100,
86
+ }}
87
+ />
88
+ <MlGeoJsonLayer type="line" geojson={sample_geojson_1} />
89
+ </MapComponentsProvider>
90
+ );
91
+ };
92
+
93
+ export const StyleChangeConfig = StyleChangeTemplate.bind({});
94
+ StyleChangeConfig.args = {
95
+ options: {
96
+ zoom: 14.5,
97
+ center: [7.0851268, 50.73884],
43
98
  },
44
99
  };
45
- ExampleConfig.parameters = {};
100
+ StyleChangeConfig.parameters = {};
@@ -16,7 +16,7 @@ type MapLibreMapProps = {
16
16
  * See https://maplibre.org/maplibre-gl-js-docs/api/map/ for a formal documentation of al
17
17
  * available properties.
18
18
  */
19
- options?: MapOptionsType;
19
+ options?: Partial<MapOptionsType>;
20
20
  /**
21
21
  * css style definition passed to the map container DOM element
22
22
  */
@@ -40,7 +40,7 @@ const defaultProps: MapLibreMapProps = {
40
40
  id: "background",
41
41
  type: "background",
42
42
  paint: {
43
- "background-color": "rgba(80,0,0,0)",
43
+ "background-color": "rgba(0,0,0,0)",
44
44
  },
45
45
  },
46
46
  ],
@@ -66,6 +66,7 @@ const MapLibreMap: FC<MapLibreMapProps> = (props: MapLibreMapProps) => {
66
66
 
67
67
  const mapIdRef = useRef(props.mapId);
68
68
  const initializedRef = useRef(false);
69
+ const currentStyle = useRef(props.options?.style);
69
70
 
70
71
  useEffect(() => {
71
72
  let mapId = mapIdRef.current;
@@ -101,6 +102,15 @@ const MapLibreMap: FC<MapLibreMapProps> = (props: MapLibreMapProps) => {
101
102
  }
102
103
  }, [props.options, props.mapId]);
103
104
 
105
+ useEffect(() => {
106
+ if (map.current?.map && props?.options?.style && currentStyle.current !== props.options.style) {
107
+ console.log("set style");
108
+ currentStyle.current = props.options.style;
109
+ map.current.map.setStyle(props.options.style);
110
+ }
111
+ // @ts-ignore: props.options is either passed or populated with default values
112
+ }, [props.options.style])
113
+
104
114
  return <div ref={mapContainer as RefObject<HTMLDivElement>} className="mapContainer" style={props.style} />;
105
115
  };
106
116
 
@@ -213,7 +213,7 @@ class MapLibreGlWrapper {
213
213
  */
214
214
  buildLayerObjects: () => {
215
215
  // @ts-ignore
216
- return self.style._order
216
+ return self.map.style._order
217
217
  .map((layerId: string) => {
218
218
  return self.wrapper.buildLayerObject(
219
219
  self.map.style._layers[layerId]
@@ -487,7 +487,7 @@ class MapLibreGlWrapper {
487
487
  this[item] = (...props: any[]) => {
488
488
  if (
489
489
  self.map &&
490
- this.map.style &&
490
+ self.map.style &&
491
491
  typeof self.map.style[item] === "function"
492
492
  ) {
493
493
  self.map.style[item](...props);
@@ -15,11 +15,10 @@ export default storyoptions;
15
15
  const Template = (args) => {
16
16
  return (
17
17
  <MlFeatureEditor
18
- debug={true}
18
+ {...args}
19
19
  onChange={(features) => {
20
20
  console.log(features);
21
21
  }}
22
- {...args}
23
22
  />
24
23
  );
25
24
  };
@@ -82,7 +82,7 @@ describe("<MlFeatureEditor>", () => {
82
82
  );
83
83
 
84
84
  // MapLibreGlWrapper now subscribes to "data", "move" events on its own
85
- await waitFor(() => expect(mockMapLibreMethods.on).toHaveBeenCalledTimes(6));
85
+ await waitFor(() => expect(mockMapLibreMethods.on).toHaveBeenCalledTimes(7));
86
86
  });
87
87
 
88
88
  it("should deregister 2 event listeners to the maplibre instance", async () => {
@@ -93,11 +93,11 @@ describe("<MlFeatureEditor>", () => {
93
93
  );
94
94
 
95
95
  // MapLibreGlWrapper now subscribes to "data", "move" events on its own
96
- expect(mockMapLibreMethods.on).toHaveBeenCalledTimes(6);
96
+ expect(mockMapLibreMethods.on).toHaveBeenCalledTimes(7);
97
97
 
98
98
  wrapper.find(".toggle_layer_visible").simulate("click");
99
99
 
100
- expect(mockMapLibreMethods.off).toHaveBeenCalledTimes(2);
100
+ expect(mockMapLibreMethods.off).toHaveBeenCalledTimes(3);
101
101
  });
102
102
 
103
103
  it("should add MapBox-Gl-draw instance using map.addControl to the maplibre instance", async () => {
@@ -9,26 +9,25 @@ import CustomDirectSelectMode from "./custom-direct-select-mode.js";
9
9
 
10
10
  import useMap from "../../hooks/useMap";
11
11
 
12
-
13
12
  interface MlFeatureEditorProps {
14
13
  /**
15
14
  * Id of the target MapLibre instance in mapContext
16
15
  */
17
- mapId: string;
16
+ mapId?: string;
18
17
  /**
19
18
  * Id of an existing layer in the mapLibre instance to help specify the layer order
20
19
  * This layer will be visually beneath the layer with the "insertBeforeLayer" id.
21
20
  */
22
- insertBeforeLayer: string;
21
+ insertBeforeLayer?: string;
23
22
  /**
24
23
  * Input GeoJson data at initialization
25
24
  */
26
- geojson: any;
25
+ geojson?: any;
27
26
  /**
28
27
  * Callback function that is called each time the GeoJson data within has changed within MlFeatureEditor.
29
28
  * First parameter is the new GeoJson feature.
30
29
  */
31
- onChange?: Function
30
+ onChange?: Function;
32
31
  /**
33
32
  * Feature editor mode:
34
33
  * - "custom_select" edit features
@@ -36,40 +35,30 @@ interface MlFeatureEditorProps {
36
35
  * - "draw_point" draw Point
37
36
  * - "draw_line_string" draw LineString
38
37
  */
39
- mode?:string
38
+ mode?: string;
40
39
  }
41
40
 
42
41
  /**
43
42
  * GeoJson Feature editor that allows to create or manipulate GeoJson data
44
43
  */
45
- const MlFeatureEditor = (props:MlFeatureEditorProps) => {
44
+ const MlFeatureEditor = (props: MlFeatureEditorProps) => {
46
45
  const draw = useRef<MapboxDraw>();
47
46
  const mapHook = useMap({
48
47
  mapId: props.mapId,
49
48
  waitForLayer: props.insertBeforeLayer,
50
49
  });
51
- const onChangeRef = useRef(props.onChange);
52
50
 
53
51
  const drawToolsInitialized = useRef(false);
54
52
  const [drawToolsReady, setDrawToolsReady] = useState(false);
55
53
 
56
- const [mouseUpTrigger, setMouseUpTrigger] = useState(0);
57
54
 
58
- const modeChangeHandler = (e:any) => {
55
+ const modeChangeHandler = (e: any) => {
59
56
  console.log("MlFeatureEditor mode change to " + e.mode);
60
57
  //setDrawMode(e.mode);
61
58
  };
62
59
 
63
- const mouseUpHandler = () => {
64
- setMouseUpTrigger(Math.random());
65
- };
66
-
67
60
  useEffect(() => {
68
- if (
69
- mapHook.map &&
70
- !drawToolsInitialized.current
71
- ) {
72
-
61
+ if (mapHook.map && !drawToolsInitialized.current) {
73
62
  drawToolsInitialized.current = true;
74
63
 
75
64
  if (
@@ -96,34 +85,47 @@ const MlFeatureEditor = (props:MlFeatureEditorProps) => {
96
85
  ),
97
86
  });
98
87
 
99
- mapHook.map.on("draw.modechange", modeChangeHandler, mapHook.componentId);
100
-
101
88
  mapHook.map.addControl(draw.current, "top-left", mapHook.componentId);
102
89
 
103
- mapHook.map.on("mouseup", mouseUpHandler, mapHook.componentId);
90
+
91
+ mapHook.map.on("draw.modechange", modeChangeHandler, mapHook.componentId);
104
92
 
105
93
  setDrawToolsReady(true);
106
94
  }
107
- }, [mapHook.map, props, drawToolsInitialized]);
95
+ }, [mapHook.map, props, drawToolsInitialized]);
108
96
 
109
97
  useEffect(() => {
110
- if (
111
- draw.current &&
112
- props.geojson?.geometry
113
- ) {
114
- draw.current.set({ type: "FeatureCollection", features: [props.geojson] });
98
+ if (!mapHook.map || !drawToolsReady) return;
99
+
100
+ const changeHandler = () => {
101
+ if (draw.current) {
102
+ // update drawnFeatures state object
103
+ if (typeof props.onChange === "function") {
104
+ let currentFeatureCollection = draw.current.getAll?.();
105
+ props.onChange(currentFeatureCollection?.features);
106
+ }
107
+ }
108
+ };
109
+
110
+ mapHook.map.on("mouseup", changeHandler);
111
+
112
+ mapHook.map.on("touchend", changeHandler);
113
+
114
+ return () => {
115
+ if (!mapHook.map) return;
116
+
117
+ mapHook.map.map.off("mouseup", changeHandler);
118
+
119
+ mapHook.map.map.off("touchend", changeHandler);
115
120
  }
116
- }, [props.geojson, drawToolsReady]);
121
+
122
+ }, [drawToolsReady, mapHook.map])
117
123
 
118
124
  useEffect(() => {
119
- if (draw.current && mouseUpTrigger) {
120
- // update drawnFeatures state object
121
- let currentFeatureCollection = draw.current.getAll();
122
- if (typeof onChangeRef.current === "function") {
123
- onChangeRef.current(currentFeatureCollection.features);
124
- }
125
+ if (draw.current && props.geojson?.geometry) {
126
+ draw.current.set({ type: "FeatureCollection", features: [props.geojson] });
125
127
  }
126
- }, [mouseUpTrigger]);
128
+ }, [props.geojson, drawToolsReady]);
127
129
 
128
130
  useEffect(() => {
129
131
  if (props.mode && draw.current) {
@@ -132,7 +134,7 @@ const MlFeatureEditor = (props:MlFeatureEditorProps) => {
132
134
  }
133
135
  }, [props.mode]);
134
136
 
135
- return (<></>);
136
- }
137
+ return <></>;
138
+ };
137
139
 
138
140
  export default MlFeatureEditor;
@@ -39,8 +39,7 @@ const drawUtils = {
39
39
  getDrawInstance: (map) => {
40
40
  for (var i = map._controls.length - 1; i >= 0; i--) {
41
41
  if (
42
- map._controls[i].options &&
43
- map._controls[i].options.defaultMode === "custom_select"
42
+ map._controls[i]?.modes?.SIMPLE_SELECT === "simple_select"
44
43
  ) {
45
44
  return map._controls[i];
46
45
  }
@@ -3,7 +3,7 @@ import { uuid_regex } from "../../setupTests";
3
3
 
4
4
  import MlImageMarkerLayer from "./MlImageMarkerLayer";
5
5
 
6
- const testComponent = <MlImageMarkerLayer options={{ source: {} }} imgSrc="testImage" />;
6
+ const testComponent = <MlImageMarkerLayer options={{ source: {} }} />;
7
7
 
8
8
  layerRemovalTest(
9
9
  "<MlImageMarkerLayer />",
@@ -1,7 +1,7 @@
1
1
  import React, { useRef, useCallback, useEffect } from "react";
2
2
 
3
3
  import { GeoJSONSource } from "maplibre-gl";
4
- import useMap from "../../hooks/useMap";
4
+ import useMap, { useMapType } from "../../hooks/useMap";
5
5
 
6
6
  interface MlImageMarkerLayerProps {
7
7
  /**
@@ -37,12 +37,12 @@ const MlImageMarkerLayer = (props: MlImageMarkerLayerProps) => {
37
37
  waitForLayer: props.insertBeforeLayer,
38
38
  });
39
39
 
40
- const layerInitializedRef = useRef(false);
40
+ const initializedRef = useRef(false);
41
+ const recreationInProgress = useRef(false);
41
42
  const imageIdRef = useRef(props.imageId || "img_" + new Date().getTime());
42
- const layerId = useRef(
43
- props.layerId || "MlImageMarkerLayer-" + mapHook.componentId
44
- );
43
+ const layerId = useRef(props.layerId || "MlImageMarkerLayer-" + mapHook.componentId);
45
44
 
45
+ // effect to sync Layer paint & layout properties
46
46
  useEffect(() => {
47
47
  if (
48
48
  !mapHook.map ||
@@ -50,32 +50,53 @@ const MlImageMarkerLayer = (props: MlImageMarkerLayerProps) => {
50
50
  !props.options
51
51
  )
52
52
  return;
53
- // the MapLibre-gl instance (mapContext.map) is accessible here
54
- // initialize the layer and add it to the MapLibre-gl instance or do something else with it
53
+
55
54
  var key;
56
55
 
57
56
  if (props.options.layout) {
58
57
  for (key in props.options.layout) {
59
- mapHook.map.map.setLayoutProperty(
60
- layerId.current,
61
- key,
62
- props.options.layout[key]
63
- );
58
+ mapHook.map.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);
64
59
  }
65
60
  }
66
61
  if (props.options.paint) {
67
62
  for (key in props.options.paint) {
68
- mapHook.map.map.setPaintProperty(
69
- layerId.current,
70
- key,
71
- props.options.paint[key]
72
- );
63
+ mapHook.map.map.setPaintProperty(layerId.current, key, props.options.paint[key]);
73
64
  }
74
65
  }
75
66
  }, [props.options, layerId.current, props.mapId]);
76
67
 
77
- const addLayer = useCallback(() => {
78
- if(!mapHook.map)return;
68
+ const createImage = (mapHook: useMapType, props: MlImageMarkerLayerProps, callback: Function) => {
69
+ if (!mapHook.map) {
70
+ initializedRef.current = false;
71
+
72
+ return;
73
+ }
74
+
75
+ if (props.imgSrc && !mapHook.map.map.hasImage(imageIdRef.current)) {
76
+ mapHook.map.map.loadImage(props.imgSrc, function (error, image) {
77
+ if (error) throw error;
78
+
79
+ if (!mapHook.map || mapHook.map.map.hasImage(imageIdRef.current)) return;
80
+
81
+ mapHook.map.addImage(imageIdRef.current, image, mapHook.componentId);
82
+
83
+ if (typeof callback === "function") {
84
+ callback();
85
+ }
86
+ });
87
+ } else {
88
+ if (typeof callback === "function") {
89
+ callback();
90
+ }
91
+ }
92
+ };
93
+
94
+ const createLayer = (
95
+ mapHook: useMapType,
96
+ props: MlImageMarkerLayerProps,
97
+ createMapLibreElements: Function
98
+ ) => {
99
+ if (!props.options || !mapHook.map || mapHook.map?.map.getLayer(layerId.current)) return;
79
100
 
80
101
  let tmpOptions = {
81
102
  id: layerId.current,
@@ -83,31 +104,55 @@ const MlImageMarkerLayer = (props: MlImageMarkerLayerProps) => {
83
104
  ...props.options,
84
105
  };
85
106
  tmpOptions.layout["icon-image"] = imageIdRef.current;
86
- mapHook.map.addLayer(
87
- tmpOptions,
88
- props.insertBeforeLayer,
107
+ mapHook.map.addLayer(tmpOptions, props.insertBeforeLayer, mapHook.componentId);
108
+
109
+ // recreate layer if map style.json has changed
110
+ mapHook.map.on(
111
+ "styledata",
112
+ () => {
113
+ if (
114
+ initializedRef.current &&
115
+ !mapHook.map?.map.getLayer(layerId.current) &&
116
+ !recreationInProgress.current
117
+ ) {
118
+ initializedRef.current = false;
119
+ recreationInProgress.current = true;
120
+ console.log("Recreate Layer " + layerId.current);
121
+ createMapLibreElements();
122
+ }
123
+ },
89
124
  mapHook.componentId
90
125
  );
91
- }, [props, mapHook.map]);
92
126
 
93
- useEffect(() => {
94
- if (!props.options || !mapHook.map || layerInitializedRef.current)
127
+ if (recreationInProgress.current) {
128
+ recreationInProgress.current = false;
129
+ }
130
+ };
131
+
132
+ const createMapLibreElements = useCallback(() => {
133
+ if (!mapHook.map || initializedRef.current || mapHook.map?.map.getLayer(layerId.current))
95
134
  return;
96
135
 
97
- layerInitializedRef.current = true;
136
+ initializedRef.current = true;
98
137
 
99
- if (props.imgSrc) {
100
- mapHook.map.map.loadImage(props.imgSrc, function (error, image) {
101
- if (error) throw error;
102
-
103
- if(!mapHook.map)return;
138
+ if (recreationInProgress.current) {
139
+ mapHook.cleanup();
140
+ }
104
141
 
105
- mapHook.map.addImage(imageIdRef.current, image, mapHook.componentId);
142
+ if (props.imgSrc) {
143
+ createImage(mapHook, props, () => {
144
+ createLayer(mapHook, props, createMapLibreElements);
106
145
  });
146
+ } else {
147
+ createLayer(mapHook, props, createMapLibreElements);
107
148
  }
149
+ }, [props, mapHook]);
108
150
 
109
- addLayer();
110
- }, [mapHook.map, addLayer, props]);
151
+ useEffect(() => {
152
+ if (initializedRef.current) return;
153
+
154
+ createMapLibreElements();
155
+ }, [createMapLibreElements]);
111
156
 
112
157
  useEffect(() => {
113
158
  if (
@@ -118,9 +163,9 @@ const MlImageMarkerLayer = (props: MlImageMarkerLayerProps) => {
118
163
  return;
119
164
  }
120
165
 
121
- (mapHook.map.map
122
- .getSource(layerId.current) as GeoJSONSource)
123
- .setData(props.options.source.data);
166
+ (mapHook.map.map.getSource(layerId.current) as GeoJSONSource).setData(
167
+ props.options.source.data
168
+ );
124
169
  }, [props.options.source.data, props]);
125
170
 
126
171
  return <></>;
@@ -1,6 +1,6 @@
1
1
  import "./MlLayerSwitcher.css";
2
2
  //External
3
- import { useEffect, useContext, useState } from "react";
3
+ import React, { useEffect, useContext, useState } from "react";
4
4
  import PropTypes from "prop-types";
5
5
  import { useTranslation } from "react-i18next";
6
6
  import { Card, CardContent, Typography, Box } from "@mui/material";