@mapcomponents/react-maplibre 0.1.57 → 0.1.59

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 (276) hide show
  1. package/.eslintignore +11 -0
  2. package/.eslintrc.js +20 -0
  3. package/.github/workflows/check-formatting.yml +46 -0
  4. package/.prettierignore +11 -0
  5. package/.prettierrc.json +6 -0
  6. package/CHANGELOG.md +18 -0
  7. package/coverage/clover.xml +229 -77
  8. package/coverage/coverage-final.json +43 -37
  9. package/coverage/lcov-report/index.html +65 -20
  10. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +83 -83
  11. package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
  12. package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +66 -66
  13. package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
  14. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +30 -30
  15. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
  16. package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +202 -0
  17. package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +116 -0
  18. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +99 -99
  19. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
  20. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +66 -66
  21. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  22. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +221 -221
  23. package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
  24. package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.html +308 -308
  25. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +497 -497
  26. package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
  27. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +85 -85
  28. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  29. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx.html +469 -0
  30. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/index.html +116 -0
  31. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +140 -140
  32. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
  33. package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +37 -37
  34. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  35. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +179 -179
  36. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
  37. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +113 -113
  38. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
  39. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +181 -181
  40. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +58 -58
  41. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  42. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  43. package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +108 -108
  44. package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
  45. package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +39 -39
  46. package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
  47. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +183 -183
  48. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  49. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +163 -163
  50. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
  51. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +50 -50
  52. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +30 -30
  53. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  54. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +83 -83
  55. package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
  56. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +204 -204
  57. package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
  58. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +180 -180
  59. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  60. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +163 -163
  61. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
  62. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +136 -136
  63. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
  64. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +53 -53
  65. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  66. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +123 -123
  67. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
  68. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +35 -35
  69. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
  70. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +155 -155
  71. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
  72. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +255 -255
  73. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
  74. package/coverage/lcov-report/src/contexts/MapContext.tsx.html +66 -66
  75. package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
  76. package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +48 -48
  77. package/coverage/lcov-report/src/contexts/index.html +1 -1
  78. package/coverage/lcov-report/src/hooks/exportMap/index.html +131 -0
  79. package/coverage/lcov-report/src/hooks/exportMap/index.ts.html +175 -0
  80. package/coverage/lcov-report/src/hooks/exportMap/lib.ts.html +646 -0
  81. package/coverage/lcov-report/src/hooks/index.html +48 -18
  82. package/coverage/lcov-report/src/hooks/useLayer.ts.html +230 -188
  83. package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +232 -0
  84. package/coverage/lcov-report/src/hooks/useMap.ts.html +72 -69
  85. package/coverage/lcov-report/src/hooks/useMapState.ts.html +145 -145
  86. package/coverage/lcov-report/src/hooks/useSource.ts.html +337 -0
  87. package/coverage/lcov-report/src/hooks/useWms.js.html +72 -72
  88. package/coverage/lcov-report/src/index.html +1 -1
  89. package/coverage/lcov-report/src/index.ts.html +11 -2
  90. package/coverage/lcov.info +448 -151
  91. package/dist/components/MlCreatePdfForm/MlCreatePdfForm.d.ts +24 -0
  92. package/dist/components/MlCreatePdfForm/MlCreatePdfForm.stories.d.ts +13 -0
  93. package/dist/components/MlCreatePdfForm/lib/PdfContext.d.ts +21 -0
  94. package/dist/components/MlCreatePdfForm/lib/PdfForm.d.ts +10 -0
  95. package/dist/components/MlCreatePdfForm/lib/PdfPreview.d.ts +13 -0
  96. package/dist/components/MlCreatePdfForm/lib/pdf.templates.d.ts +11 -0
  97. package/dist/components/MlFeatureEditor/lib/create_vertex.d.ts +1 -1
  98. package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.d.ts +22 -0
  99. package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.d.ts +10 -0
  100. package/dist/components/MlLayerSwipe/MlLayerSwipe.d.ts +1 -1
  101. package/dist/components/MlWmsLayer/MlWmsLayer.d.ts +2 -2
  102. package/dist/decorators/MapContextDecoratorHooks.d.ts +2 -0
  103. package/dist/hooks/exportMap/index.d.ts +11 -0
  104. package/dist/hooks/exportMap/lib.d.ts +36 -0
  105. package/dist/hooks/useLayer.d.ts +6 -5
  106. package/dist/hooks/useLayerEvent.d.ts +2 -0
  107. package/dist/hooks/useMap.d.ts +1 -1
  108. package/dist/hooks/useMapState.stories.d.ts +2 -2
  109. package/dist/hooks/useSource.d.ts +17 -0
  110. package/dist/hooks/useSources.stories.d.ts +13 -0
  111. package/dist/index.d.ts +3 -0
  112. package/dist/index.esm.js +1055 -315
  113. package/dist/index.esm.js.map +1 -1
  114. package/eslintErrorTest.js +10 -0
  115. package/package.json +7 -1
  116. package/public/thumbnails/MlCreatePdfForm.png +0 -0
  117. package/src/components/MapLibreMap/MapLibreMap.stories.js +72 -72
  118. package/src/components/MapLibreMap/MapLibreMap.test.js +60 -60
  119. package/src/components/MapLibreMap/MapLibreMap.tsx +82 -82
  120. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.test.js +343 -343
  121. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +619 -619
  122. package/src/components/MlBasicComponent.js +25 -25
  123. package/src/components/MlCenterPosition/MlCenterPosition.stories.js +6 -6
  124. package/src/components/MlCenterPosition/MlCenterPosition.tsx +65 -65
  125. package/src/components/MlComponentTemplate/MlComponentTemplate.stories.js +5 -5
  126. package/src/components/MlComponentTemplate/MlComponentTemplate.tsx +23 -23
  127. package/src/components/MlCreatePdfButton/{MlCreatePdfButton.meta.json → MlCreatePdfButton.meta_.json} +0 -0
  128. package/src/components/MlCreatePdfButton/MlCreatePdfButton.stories.js +16 -16
  129. package/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx +29 -29
  130. package/src/components/MlCreatePdfButton/lib/createPdf.ts +175 -175
  131. package/src/components/MlCreatePdfButton/lib/nominatimMap.ts +51 -51
  132. package/src/components/MlCreatePdfForm/MlCreatePdfForm.doc.de.md +3 -0
  133. package/src/components/MlCreatePdfForm/MlCreatePdfForm.meta.json +15 -0
  134. package/src/components/MlCreatePdfForm/MlCreatePdfForm.stories.tsx +152 -0
  135. package/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx +39 -0
  136. package/src/components/MlCreatePdfForm/lib/PdfContext.tsx +53 -0
  137. package/src/components/MlCreatePdfForm/lib/PdfForm.tsx +161 -0
  138. package/src/components/MlCreatePdfForm/lib/PdfPreview.tsx +399 -0
  139. package/src/components/MlCreatePdfForm/lib/pdf.templates.ts +82 -0
  140. package/src/components/MlFeatureEditor/MlFeatureEditor.stories.js +55 -55
  141. package/src/components/MlFeatureEditor/MlFeatureEditor.test.js +105 -105
  142. package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +119 -119
  143. package/src/components/MlFeatureEditor/custom-direct-select-mode.js +208 -208
  144. package/src/components/MlFeatureEditor/custom-polygon-mode.js +148 -148
  145. package/src/components/MlFeatureEditor/custom-select-mode.js +314 -314
  146. package/src/components/MlFeatureEditor/lib/common_selectors.js +34 -34
  147. package/src/components/MlFeatureEditor/lib/constants.js +61 -61
  148. package/src/components/MlFeatureEditor/lib/constrain_feature_movement.js +51 -51
  149. package/src/components/MlFeatureEditor/lib/create_midpoint.js +30 -30
  150. package/src/components/MlFeatureEditor/lib/create_supplementary_points.js +82 -82
  151. package/src/components/MlFeatureEditor/lib/create_vertex.js +16 -16
  152. package/src/components/MlFeatureEditor/lib/double_click_zoom.js +23 -23
  153. package/src/components/MlFeatureEditor/lib/euclidean_distance.js +3 -3
  154. package/src/components/MlFeatureEditor/lib/features_at.js +23 -23
  155. package/src/components/MlFeatureEditor/lib/get_features_and_set_cursor.js +15 -15
  156. package/src/components/MlFeatureEditor/lib/is_click.js +8 -8
  157. package/src/components/MlFeatureEditor/lib/is_event_at_coordinates.js +2 -2
  158. package/src/components/MlFeatureEditor/lib/is_tap.js +6 -6
  159. package/src/components/MlFeatureEditor/lib/map_event_to_bounding_box.js +4 -4
  160. package/src/components/MlFeatureEditor/lib/mode_handler.js +105 -105
  161. package/src/components/MlFeatureEditor/lib/mouse_event_point.js +5 -5
  162. package/src/components/MlFeatureEditor/lib/move_features.js +33 -33
  163. package/src/components/MlFeatureEditor/lib/sort_features.js +25 -25
  164. package/src/components/MlFeatureEditor/lib/string_set.js +36 -36
  165. package/src/components/MlFeatureEditor/lib/string_sets_are_equal.js +2 -2
  166. package/src/components/MlFeatureEditor/lib/theme.js +230 -230
  167. package/src/components/MlFeatureEditor/lib/to_dense_array.js +1 -1
  168. package/src/components/MlFeatureEditor/lib/utils.js +40 -40
  169. package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.stories.js +9 -9
  170. package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.test.js +4 -4
  171. package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx +65 -65
  172. package/src/components/MlFollowGps/MlFollowGps.stories.js +6 -6
  173. package/src/components/MlFollowGps/MlFollowGps.test.js +44 -44
  174. package/src/components/MlFollowGps/MlFollowGps.tsx +220 -220
  175. package/src/components/MlGPXViewer/MlGPXViewer.stories.js +15 -15
  176. package/src/components/MlGPXViewer/MlGPXViewer.test.js +12 -12
  177. package/src/components/MlGPXViewer/MlGPXViewer.tsx +345 -345
  178. package/src/components/MlGPXViewer/gpxConverter.js +496 -496
  179. package/src/components/MlGPXViewer/util/GeoJsonContext.ts +4 -4
  180. package/src/components/MlGPXViewer/util/GeoJsonProvider.tsx +16 -16
  181. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +34 -34
  182. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.test.js +8 -8
  183. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +84 -84
  184. package/src/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.ts +21 -21
  185. package/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.ts +27 -27
  186. package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.doc.de.md +3 -0
  187. package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.meta_.json +15 -0
  188. package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.js +19 -0
  189. package/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx +128 -0
  190. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.js +28 -28
  191. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +8 -8
  192. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx +162 -162
  193. package/src/components/MlLayer/MlLayer.stories.js +5 -5
  194. package/src/components/MlLayer/MlLayer.test.js +86 -86
  195. package/src/components/MlLayer/MlLayer.tsx +36 -36
  196. package/src/components/MlLayerMagnify/MlLayerMagnify.stories.js +21 -21
  197. package/src/components/MlLayerMagnify/MlLayerMagnify.test.js +54 -54
  198. package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +201 -201
  199. package/src/components/MlLayerSwipe/MlLayerSwipe.stories.js +20 -20
  200. package/src/components/MlLayerSwipe/MlLayerSwipe.test.js +54 -54
  201. package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +130 -130
  202. package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +194 -194
  203. package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +85 -85
  204. package/src/components/MlLayerSwitcher/components/LayerBox.js +57 -57
  205. package/src/components/MlMarker/MlMarker.stories.js +7 -7
  206. package/src/components/MlMarker/MlMarker.tsx +119 -119
  207. package/src/components/MlMeasureTool/MlMeasureTool.stories.js +64 -64
  208. package/src/components/MlMeasureTool/MlMeasureTool.tsx +38 -38
  209. package/src/components/MlNavigationCompass/MlNavigationCompass.stories.js +45 -45
  210. package/src/components/MlNavigationCompass/MlNavigationCompass.test.js +40 -40
  211. package/src/components/MlNavigationCompass/MlNavigationCompass.tsx +192 -192
  212. package/src/components/MlNavigationTools/MlNavigationTools.stories.js +18 -18
  213. package/src/components/MlNavigationTools/MlNavigationTools.tsx +173 -173
  214. package/src/components/MlOsmLayer/MlOsmLayer.js +49 -49
  215. package/src/components/MlOsmLayer/MlOsmLayer.stories_.js +29 -29
  216. package/src/components/MlOsmLayer/MlOsmLayer.test.js +8 -8
  217. package/src/components/MlScaleReference/MlScaleReference.js +82 -82
  218. package/src/components/MlScaleReference/MlScaleReference.stories.js +27 -27
  219. package/src/components/MlShareMapState/MlShareMapState.js +203 -203
  220. package/src/components/MlShareMapState/MlShareMapState.stories.js +68 -68
  221. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js +201 -201
  222. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +35 -35
  223. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.test.js +8 -8
  224. package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +186 -186
  225. package/src/components/MlThreeJsLayer/MlThreeJsLayer.stories.js +21 -21
  226. package/src/components/MlThreeJsLayer/MlThreeJsLayer.test.js +24 -24
  227. package/src/components/MlThreeJsLayer/lib/GLTFLoader.js +3327 -3327
  228. package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.stories.js +31 -30
  229. package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.test.js +8 -8
  230. package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx +146 -146
  231. package/src/components/MlTransitionGeoJsonLayer/util/transitionFunctions.js +207 -207
  232. package/src/components/MlUseMapDebugger/MlUseMapDebugger.js +52 -52
  233. package/src/components/MlUseMapDebugger/MlUseMapDebugger.stories.js +13 -13
  234. package/src/components/MlVectorTileLayer/MlVectorTileLayer.stories.js +27 -27
  235. package/src/components/MlVectorTileLayer/MlVectorTileLayer.test.js +27 -27
  236. package/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx +137 -137
  237. package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js +34 -34
  238. package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.js +7 -7
  239. package/src/components/MlWmsLayer/MlWmsLayer.stories.js +26 -26
  240. package/src/components/MlWmsLayer/MlWmsLayer.test.js +8 -8
  241. package/src/components/MlWmsLayer/MlWmsLayer.tsx +167 -167
  242. package/src/components/MlWmsLoader/MlWmsLoader.stories.js +27 -27
  243. package/src/components/MlWmsLoader/MlWmsLoader.tsx +254 -254
  244. package/src/contexts/MapComponentsProvider.test.js +229 -229
  245. package/src/contexts/MapContext.tsx +65 -65
  246. package/src/contexts/SimpleDataProvider.js +47 -47
  247. package/src/contexts/SimpleDataProvider.test.js +29 -29
  248. package/src/custom.d.tsx +14 -14
  249. package/src/decorators/MapContextDecorator.js +22 -22
  250. package/src/decorators/MapContextDecoratorHooks.js +34 -0
  251. package/src/decorators/MultiMapContextDecorator.js +63 -63
  252. package/src/decorators/NoNavToolsDecorator.js +17 -17
  253. package/src/decorators/ThemeWrapper.jsx +1 -1
  254. package/src/hooks/assets/pointWG.json +13 -0
  255. package/src/hooks/exportMap/index.ts +30 -0
  256. package/src/hooks/exportMap/lib.ts +187 -0
  257. package/src/hooks/useLayer.test.js +188 -188
  258. package/src/hooks/useLayer.ts +194 -180
  259. package/src/hooks/useLayerEvent.js +49 -0
  260. package/src/hooks/useMap.ts +67 -66
  261. package/src/hooks/useMapState.stories.js +78 -78
  262. package/src/hooks/useMapState.ts +161 -161
  263. package/src/hooks/useSource.ts +84 -0
  264. package/src/hooks/useSources.stories.js +232 -0
  265. package/src/hooks/useWms.js +71 -71
  266. package/src/index.ts +3 -0
  267. package/src/setupTests.js +86 -86
  268. package/src/ui_components/ImageLoader.js +62 -62
  269. package/src/ui_components/Legend.js +34 -34
  270. package/src/ui_components/LoadingOverlay.js +29 -29
  271. package/src/ui_components/LoadingOverlayContext.js +68 -68
  272. package/src/ui_components/Sidebar.js +80 -80
  273. package/src/ui_components/Tooltip.js +9 -9
  274. package/src/ui_components/TopToolbar.js +23 -23
  275. package/src/util/layerRemovalTest.js +111 -111
  276. package/src/util/sourceRemovalTest.js +103 -103
package/dist/index.esm.js CHANGED
@@ -7,10 +7,10 @@ import { Map as Map$2, Popup } from 'maplibre-gl';
7
7
  import jsPDF from 'jspdf';
8
8
  import styled$3 from '@emotion/styled';
9
9
  import { keyframes } from '@emotion/react';
10
- import MapboxDraw from '@mapbox/mapbox-gl-draw';
11
- import { Button as Button$2 } from '@mui/material';
12
10
  import * as turf from '@turf/turf';
13
11
  import { point, circle, lineArc, bbox, lineOffset, distance } from '@turf/turf';
12
+ import { FormControl, InputLabel, Select, MenuItem, FormLabel, RadioGroup, FormControlLabel, Radio, Button as Button$2 } from '@mui/material';
13
+ import MapboxDraw from '@mapbox/mapbox-gl-draw';
14
14
  import { css } from '@emotion/css';
15
15
  import syncMove from '@mapbox/mapbox-gl-sync-move';
16
16
  import * as ReactDOM from 'react-dom';
@@ -293,18 +293,18 @@ var MapLibreGlWrapper = /** @class */ (function () {
293
293
  //let paint = {};
294
294
  //let values = layer.paint?._values;
295
295
  //Object.keys(values || {}).map((propName) => {
296
- // paint[propName] =
297
- // typeof values[propName].value !== "undefined"
298
- // ? values[propName].value.value
299
- // : values[propName];
296
+ // paint[propName] =
297
+ // typeof values[propName].value !== "undefined"
298
+ // ? values[propName].value.value
299
+ // : values[propName];
300
300
  //});
301
301
  //let layout = {};
302
302
  //values = layer.layout?._values;
303
303
  //Object.keys(values || {}).map((propName) => {
304
- // layout[propName] =
305
- // typeof values[propName].value !== "undefined"
306
- // ? values[propName].value.value
307
- // : values[propName];
304
+ // layout[propName] =
305
+ // typeof values[propName].value !== "undefined"
306
+ // ? values[propName].value.value
307
+ // : values[propName];
308
308
  //});
309
309
  return {
310
310
  id: layer.id,
@@ -598,7 +598,7 @@ var MapLibreGlWrapper = /** @class */ (function () {
598
598
  };
599
599
  });
600
600
  this.addNativeMaplibreFunctionsAndProps = function () {
601
- // add MapLibre-gl functions
601
+ // add MapLibre-gl functions
602
602
  Object.getOwnPropertyNames(Object.getPrototypeOf(_this.map)).forEach(function (item) {
603
603
  if (typeof _this[item] === "undefined") {
604
604
  _this[item] = function () {
@@ -611,7 +611,7 @@ var MapLibreGlWrapper = /** @class */ (function () {
611
611
  };
612
612
  }
613
613
  });
614
- // add MapLibre-gl properties
614
+ // add MapLibre-gl properties
615
615
  Object.keys(_this.map).forEach(function (item) {
616
616
  if (typeof _this[item] === "undefined") {
617
617
  _this[item] = self.map[item];
@@ -957,13 +957,12 @@ function useMap(props) {
957
957
  },
958
958
  });
959
959
  var initializedRef = useRef(false);
960
- var mapRef = useRef(undefined);
960
+ var mapRef = useRef();
961
961
  var componentId = useRef(v4());
962
962
  var _b = useState(false), mapIsReady = _b[0], setMapIsReady = _b[1];
963
963
  var cleanup = function () {
964
964
  if (mapRef.current) {
965
965
  mapRef.current.cleanup(componentId.current);
966
- mapRef.current = undefined;
967
966
  }
968
967
  initializedRef.current = false;
969
968
  };
@@ -971,6 +970,7 @@ function useMap(props) {
971
970
  return function () {
972
971
  cleanup();
973
972
  setMapIsReady(false);
973
+ mapRef.current = undefined;
974
974
  };
975
975
  }, []);
976
976
  useEffect(function () {
@@ -9923,75 +9923,965 @@ MlCreatePdfButton.defaultProps = {
9923
9923
  mapId: undefined,
9924
9924
  };
9925
9925
 
9926
- /**
9927
- * Code from https://github.com/mapbox/mapbox-gl-draw
9928
- * and licensed under ISC
9929
- */
9930
- var classes = {
9931
- CONTROL_BASE: 'mapboxgl-ctrl',
9932
- CONTROL_PREFIX: 'mapboxgl-ctrl-',
9933
- CONTROL_BUTTON: 'mapbox-gl-draw_ctrl-draw-btn',
9934
- CONTROL_BUTTON_LINE: 'mapbox-gl-draw_line',
9935
- CONTROL_BUTTON_POLYGON: 'mapbox-gl-draw_polygon',
9936
- CONTROL_BUTTON_POINT: 'mapbox-gl-draw_point',
9937
- CONTROL_BUTTON_TRASH: 'mapbox-gl-draw_trash',
9938
- CONTROL_BUTTON_COMBINE_FEATURES: 'mapbox-gl-draw_combine',
9939
- CONTROL_BUTTON_UNCOMBINE_FEATURES: 'mapbox-gl-draw_uncombine',
9940
- CONTROL_GROUP: 'mapboxgl-ctrl-group',
9941
- ATTRIBUTION: 'mapboxgl-ctrl-attrib',
9942
- ACTIVE_BUTTON: 'active',
9943
- BOX_SELECT: 'mapbox-gl-draw_boxselect'
9944
- };
9945
- var cursors = {
9946
- ADD: 'add',
9947
- MOVE: 'move',
9948
- DRAG: 'drag',
9949
- POINTER: 'pointer',
9950
- NONE: 'none'
9951
- };
9952
- var types$1 = {
9953
- POLYGON: 'polygon',
9954
- LINE: 'line_string',
9955
- POINT: 'point'
9956
- };
9957
- var geojsonTypes = {
9958
- FEATURE: 'Feature',
9959
- POLYGON: 'Polygon',
9960
- LINE_STRING: 'LineString',
9961
- POINT: 'Point',
9962
- FEATURE_COLLECTION: 'FeatureCollection',
9963
- MULTI_PREFIX: 'Multi',
9964
- MULTI_POINT: 'MultiPoint',
9965
- MULTI_LINE_STRING: 'MultiLineString',
9966
- MULTI_POLYGON: 'MultiPolygon'
9967
- };
9968
- var events = {
9969
- CREATE: 'draw.create',
9970
- DELETE: 'draw.delete',
9971
- UPDATE: 'draw.update',
9972
- SELECTION_CHANGE: 'draw.selectionchange',
9973
- MODE_CHANGE: 'draw.modechange',
9974
- ACTIONABLE: 'draw.actionable',
9975
- RENDER: 'draw.render',
9976
- COMBINE_FEATURES: 'draw.combine',
9977
- UNCOMBINE_FEATURES: 'draw.uncombine'
9926
+ var legalLayerTypes = [
9927
+ 'fill',
9928
+ 'line',
9929
+ 'symbol',
9930
+ 'circle',
9931
+ 'heatmap',
9932
+ 'fill-extrusion',
9933
+ 'raster',
9934
+ 'hillshade',
9935
+ 'background',
9936
+ ];
9937
+ function useLayer(props) {
9938
+ var mapHook = useMap({
9939
+ mapId: props.mapId,
9940
+ waitForLayer: props.insertBeforeLayer,
9941
+ });
9942
+ var layerTypeRef = useRef('');
9943
+ var layerPaintConfRef = useRef('');
9944
+ var layerLayoutConfRef = useRef('');
9945
+ var _a = useState(), layer = _a[0], setLayer = _a[1];
9946
+ var initializedRef = useRef(false);
9947
+ var layerId = useRef(props.layerId || (props.idPrefix ? props.idPrefix : 'Layer-') + mapHook.componentId);
9948
+ var createLayer = useCallback(function () {
9949
+ var _a, _b;
9950
+ if (!mapHook.map)
9951
+ return;
9952
+ if (mapHook.map.map.getLayer(layerId.current)) {
9953
+ mapHook.cleanup();
9954
+ }
9955
+ if (mapHook.map.map.getSource(layerId.current)) {
9956
+ mapHook.map.map.removeSource(layerId.current);
9957
+ }
9958
+ if (typeof props.source === 'string') {
9959
+ if (props.source === '' || !mapHook.map.map.getSource(props.source)) {
9960
+ return;
9961
+ }
9962
+ }
9963
+ initializedRef.current = true;
9964
+ mapHook.map.addLayer(__assign(__assign(__assign(__assign({}, props.options), (props.geojson && !props.source
9965
+ ? {
9966
+ source: {
9967
+ type: 'geojson',
9968
+ data: props.geojson,
9969
+ },
9970
+ }
9971
+ : {})), (props.source
9972
+ ? {
9973
+ source: props.source,
9974
+ }
9975
+ : {})), { id: layerId.current }), props.insertBeforeLayer
9976
+ ? props.insertBeforeLayer
9977
+ : props.insertBeforeFirstSymbolLayer
9978
+ ? mapHook.map.firstSymbolLayer
9979
+ : undefined, mapHook.componentId);
9980
+ setLayer(mapHook.map.map.getLayer(layerId.current));
9981
+ if (typeof props.onHover !== 'undefined') {
9982
+ mapHook.map.on('mousemove', layerId.current, props.onHover, mapHook.componentId);
9983
+ }
9984
+ if (typeof props.onClick !== 'undefined') {
9985
+ mapHook.map.on('click', layerId.current, props.onClick, mapHook.componentId);
9986
+ }
9987
+ if (typeof props.onLeave !== 'undefined') {
9988
+ mapHook.map.on('mouseleave', layerId.current, props.onLeave, mapHook.componentId);
9989
+ }
9990
+ // recreate layer if style has changed
9991
+ mapHook.map.on('styledata', function () {
9992
+ var _a;
9993
+ if (initializedRef.current && !((_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map.getLayer(layerId.current))) {
9994
+ console.log('Recreate Layer');
9995
+ createLayer();
9996
+ }
9997
+ }, mapHook.componentId);
9998
+ layerPaintConfRef.current = JSON.stringify((_a = props.options) === null || _a === void 0 ? void 0 : _a.paint);
9999
+ layerLayoutConfRef.current = JSON.stringify((_b = props.options) === null || _b === void 0 ? void 0 : _b.layout);
10000
+ layerTypeRef.current = props.options.type;
10001
+ }, [props, mapHook.map]);
10002
+ useEffect(function () {
10003
+ if (!mapHook.map)
10004
+ return;
10005
+ if (initializedRef.current &&
10006
+ (legalLayerTypes.indexOf(props.options.type) === -1 ||
10007
+ (legalLayerTypes.indexOf(props.options.type) !== -1 &&
10008
+ props.options.type === layerTypeRef.current))) {
10009
+ return;
10010
+ }
10011
+ createLayer();
10012
+ }, [mapHook.map, props.options, createLayer]);
10013
+ useEffect(function () {
10014
+ var _a, _b, _c, _d;
10015
+ if (!initializedRef.current || !((_b = (_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.getSource(layerId.current)))
10016
+ return;
10017
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10018
+ //@ts-ignore setData only exists on GeoJsonSource
10019
+ (_d = (_c = mapHook.map.map.getSource(layerId.current)) === null || _c === void 0 ? void 0 : _c.setData) === null || _d === void 0 ? void 0 : _d.call(_c, props.geojson);
10020
+ }, [props.geojson, mapHook.map, props.options.type]);
10021
+ useEffect(function () {
10022
+ var _a, _b, _c, _d, _e;
10023
+ if (!mapHook.map ||
10024
+ !((_c = (_b = (_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.getLayer) === null || _c === void 0 ? void 0 : _c.call(_b, layerId.current)) ||
10025
+ !initializedRef.current ||
10026
+ props.options.type !== layerTypeRef.current)
10027
+ return;
10028
+ var key;
10029
+ var layoutString = JSON.stringify(props.options.layout);
10030
+ if (props.options.layout && layoutString !== layerLayoutConfRef.current) {
10031
+ var oldLayout = JSON.parse(layerLayoutConfRef.current);
10032
+ for (key in props.options.layout) {
10033
+ if (((_d = props.options.layout) === null || _d === void 0 ? void 0 : _d[key]) && props.options.layout[key] !== oldLayout[key]) {
10034
+ mapHook.map.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);
10035
+ }
10036
+ }
10037
+ layerLayoutConfRef.current = layoutString;
10038
+ }
10039
+ var paintString = JSON.stringify(props.options.paint);
10040
+ if (paintString !== layerPaintConfRef.current) {
10041
+ var oldPaint = JSON.parse(layerPaintConfRef.current);
10042
+ for (key in props.options.paint) {
10043
+ if (((_e = props.options.paint) === null || _e === void 0 ? void 0 : _e[key]) && props.options.paint[key] !== oldPaint[key]) {
10044
+ mapHook.map.map.setPaintProperty(layerId.current, key, props.options.paint[key]);
10045
+ }
10046
+ }
10047
+ layerPaintConfRef.current = paintString;
10048
+ }
10049
+ }, [props.options, mapHook.map]);
10050
+ useEffect(function () {
10051
+ return function () {
10052
+ initializedRef.current = false;
10053
+ mapHook.cleanup();
10054
+ };
10055
+ }, []);
10056
+ return {
10057
+ map: mapHook.map,
10058
+ layer: layer,
10059
+ layerId: layerId.current,
10060
+ componentId: mapHook.componentId,
10061
+ mapHook: mapHook,
10062
+ };
10063
+ }
10064
+
10065
+ var getDefaultPaintPropsByType = function (type, defaultPaintOverrides) {
10066
+ switch (type) {
10067
+ case "fill":
10068
+ if (defaultPaintOverrides === null || defaultPaintOverrides === void 0 ? void 0 : defaultPaintOverrides.fill) {
10069
+ return defaultPaintOverrides.fill;
10070
+ }
10071
+ return {
10072
+ "fill-color": "rgba(10,240,256,0.6)",
10073
+ };
10074
+ case "line":
10075
+ if (defaultPaintOverrides === null || defaultPaintOverrides === void 0 ? void 0 : defaultPaintOverrides.line) {
10076
+ return defaultPaintOverrides.line;
10077
+ }
10078
+ return {
10079
+ "line-color": "rgb(203,211,2)",
10080
+ "line-width": 5,
10081
+ };
10082
+ case "circle":
10083
+ default:
10084
+ if (defaultPaintOverrides === null || defaultPaintOverrides === void 0 ? void 0 : defaultPaintOverrides.circle) {
10085
+ return defaultPaintOverrides.circle;
10086
+ }
10087
+ return {
10088
+ "circle-color": "rgba(10,240,256,0.8)",
10089
+ "circle-stroke-color": "#fff",
10090
+ "circle-stroke-width": 2,
10091
+ };
10092
+ }
9978
10093
  };
9979
- var updateActions = {
9980
- MOVE: 'move',
9981
- CHANGE_COORDINATES: 'change_coordinates'
10094
+
10095
+ var mapGeometryTypesToLayerTypes = {
10096
+ Position: "circle",
10097
+ Point: "circle",
10098
+ MultiPoint: "circle",
10099
+ LineString: "line",
10100
+ MultiLineString: "line",
10101
+ Polygon: "fill",
10102
+ MultiPolygon: "fill",
10103
+ GeometryCollection: "circle",
10104
+ };
10105
+ var getDefaulLayerTypeByGeometry = function (geojson) {
10106
+ var _a;
10107
+ if ((geojson === null || geojson === void 0 ? void 0 : geojson.type) === "Feature") {
10108
+ return (mapGeometryTypesToLayerTypes === null || mapGeometryTypesToLayerTypes === void 0 ? void 0 : mapGeometryTypesToLayerTypes[(_a = geojson === null || geojson === void 0 ? void 0 : geojson.geometry) === null || _a === void 0 ? void 0 : _a.type])
10109
+ ? mapGeometryTypesToLayerTypes[geojson.geometry.type]
10110
+ : "circle";
10111
+ }
10112
+ if ((geojson === null || geojson === void 0 ? void 0 : geojson.type) === "FeatureCollection") {
10113
+ if (geojson.features.length) {
10114
+ return getDefaulLayerTypeByGeometry(geojson.features[0]);
10115
+ }
10116
+ return "circle";
10117
+ }
10118
+ return "fill";
9982
10119
  };
9983
- var meta = {
9984
- FEATURE: 'feature',
9985
- MIDPOINT: 'midpoint',
9986
- VERTEX: 'vertex'
10120
+
10121
+ /**
10122
+ * Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
10123
+ *
10124
+ * @component
10125
+ */
10126
+ var MlGeoJsonLayer = function (props) {
10127
+ var layerType = props.type || getDefaulLayerTypeByGeometry(props.geojson);
10128
+ // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
10129
+ useLayer({
10130
+ mapId: props.mapId,
10131
+ layerId: props.layerId || "MlGeoJsonLayer-" + v4(),
10132
+ geojson: props.geojson,
10133
+ options: __assign(__assign({ paint: props.paint ||
10134
+ getDefaultPaintPropsByType(layerType, props.defaultPaintOverrides), layout: props.layout || {} }, props.options), { type: layerType }),
10135
+ insertBeforeLayer: props.insertBeforeLayer,
10136
+ onHover: props.onHover,
10137
+ onClick: props.onClick,
10138
+ onLeave: props.onLeave,
10139
+ });
10140
+ return (React__default.createElement(React__default.Fragment, null));
9987
10141
  };
9988
- var activeStates = {
9989
- ACTIVE: 'true',
9990
- INACTIVE: 'false'
10142
+
10143
+ var touchEquivalents = {
10144
+ mousedown: 'touchstart',
10145
+ mouseup: 'touchend',
10146
+ mousemove: 'touchmove'
9991
10147
  };
9992
- var LAT_MIN$1 = -90;
9993
- var LAT_RENDERED_MIN$1 = -85;
9994
- var LAT_MAX$1 = 90;
10148
+ var touchEquivalentsKeys = Object.keys(touchEquivalents);
10149
+
10150
+ function useLayerEvent(props) {
10151
+ var mapState = useMapState({
10152
+ mapId: props.mapId,
10153
+ watch: {
10154
+ layers: true
10155
+ }
10156
+ });
10157
+ var mapHook = useMap({
10158
+ mapId: props.mapId
10159
+ });
10160
+ useEffect(function () {
10161
+ if (!mapHook.map) return true;
10162
+ if (typeof props.condition !== 'undefined' && props.condition === false) return; //console.log('useLayerEvent');
10163
+ //console.log(mapState);
10164
+
10165
+ if (mapHook.map.map.getLayer(props.layerId)) {
10166
+ //console.log("layer avail");
10167
+ var _event = props.event;
10168
+ var _layerId = props.layerId;
10169
+ var _eventHandler = props.eventHandler; //console.log(_event);
10170
+
10171
+ mapHook.map.on(_event, _layerId, _eventHandler, mapHook.componentId);
10172
+
10173
+ if ((props === null || props === void 0 ? void 0 : props.addTouchEvents) === true) {
10174
+ if (touchEquivalentsKeys.indexOf(_event) !== -1) {
10175
+ mapHook.map.on(touchEquivalents[_event], _layerId, _eventHandler, mapHook.componentId);
10176
+ }
10177
+ }
10178
+
10179
+ return function () {
10180
+ mapHook.map.off(_event, _layerId, _eventHandler);
10181
+
10182
+ if ((props === null || props === void 0 ? void 0 : props.addTouchEvents) === true) {
10183
+ if (touchEquivalentsKeys.indexOf(_event) !== -1) {
10184
+ mapHook.map.off(touchEquivalents[_event], _layerId, _eventHandler, mapHook.componentId);
10185
+ }
10186
+ }
10187
+ };
10188
+ }
10189
+ }, [props, mapState, mapHook.map]);
10190
+ return {};
10191
+ }
10192
+
10193
+ var PdfTemplates = {
10194
+ A4: {
10195
+ '300dpi': {
10196
+ width: 2480,
10197
+ height: 3508,
10198
+ },
10199
+ '150dpi': {
10200
+ width: 1240,
10201
+ height: 1754,
10202
+ },
10203
+ '72dpi': {
10204
+ width: 595,
10205
+ height: 842,
10206
+ },
10207
+ },
10208
+ A3: {
10209
+ '300dpi': {
10210
+ width: 3505,
10211
+ height: 4961,
10212
+ },
10213
+ '150dpi': {
10214
+ width: 1754,
10215
+ height: 2480,
10216
+ },
10217
+ '72dpi': {
10218
+ width: 842,
10219
+ height: 1191,
10220
+ },
10221
+ },
10222
+ A2: {
10223
+ '300dpi': {
10224
+ width: 4961,
10225
+ height: 7016,
10226
+ },
10227
+ '150dpi': {
10228
+ width: 2480,
10229
+ height: 3508,
10230
+ },
10231
+ '72dpi': {
10232
+ width: 1191,
10233
+ height: 1684,
10234
+ },
10235
+ },
10236
+ A1: {
10237
+ '300dpi': {
10238
+ width: 7016,
10239
+ height: 9933,
10240
+ },
10241
+ '150dpi': {
10242
+ width: 3508,
10243
+ height: 4967,
10244
+ },
10245
+ '72dpi': {
10246
+ width: 1684,
10247
+ height: 2384,
10248
+ },
10249
+ },
10250
+ A0: {
10251
+ '300dpi': {
10252
+ width: 9933,
10253
+ height: 14043,
10254
+ },
10255
+ '150dpi': {
10256
+ width: 4967,
10257
+ height: 7022,
10258
+ },
10259
+ '72dpi': {
10260
+ width: 2384,
10261
+ height: 3370,
10262
+ },
10263
+ },
10264
+ };
10265
+
10266
+ var PdfContext = React__default.createContext({});
10267
+ var defaultTemplate = PdfTemplates['A4']['72dpi'];
10268
+ var PdfContextProvider = function (_a) {
10269
+ var children = _a.children;
10270
+ var _b = useState('A4'), format = _b[0], setFormat = _b[1];
10271
+ var _c = useState('72dpi'), quality = _c[0], setQuality = _c[1];
10272
+ var _d = useState('portrait'), orientation = _d[0], setOrientation = _d[1];
10273
+ var geojsonRef = useRef();
10274
+ var template = useMemo(function () {
10275
+ if (typeof PdfTemplates[format][quality] !== 'undefined') {
10276
+ return orientation === 'portrait'
10277
+ ? PdfTemplates[format][quality]
10278
+ : {
10279
+ width: PdfTemplates[format][quality].height,
10280
+ height: PdfTemplates[format][quality].width,
10281
+ };
10282
+ }
10283
+ return defaultTemplate;
10284
+ }, [format, quality, orientation]);
10285
+ var value = {
10286
+ format: format,
10287
+ setFormat: setFormat,
10288
+ quality: quality,
10289
+ setQuality: setQuality,
10290
+ orientation: orientation,
10291
+ setOrientation: setOrientation,
10292
+ geojsonRef: geojsonRef,
10293
+ template: template,
10294
+ };
10295
+ return React__default.createElement(PdfContext.Provider, { value: value }, children);
10296
+ };
10297
+
10298
+ var createPreviewGeojson = function (geojsonProps, orientation) {
10299
+ var topLeftAngle = orientation === 'portrait' ? -35.3 : -54.7;
10300
+ var bottomRightAngle = orientation === 'portrait' ? 144.7 : 125.3;
10301
+ var topLeft = turf.destination([geojsonProps.center.lng, geojsonProps.center.lat], geojsonProps.distance, topLeftAngle);
10302
+ var bottomRight = turf.destination([geojsonProps.center.lng, geojsonProps.center.lat], geojsonProps.distance, bottomRightAngle);
10303
+ var bbox = [
10304
+ topLeft.geometry.coordinates[0],
10305
+ topLeft.geometry.coordinates[1],
10306
+ bottomRight.geometry.coordinates[0],
10307
+ bottomRight.geometry.coordinates[1],
10308
+ ];
10309
+ var _previewGeojson = turf.bboxPolygon(bbox);
10310
+ _previewGeojson = turf.transformRotate(_previewGeojson, geojsonProps.bearing);
10311
+ if (!(_previewGeojson === null || _previewGeojson === void 0 ? void 0 : _previewGeojson.properties)) {
10312
+ _previewGeojson.properties = {};
10313
+ }
10314
+ _previewGeojson.properties.bearing = geojsonProps.bearing;
10315
+ return _previewGeojson;
10316
+ };
10317
+ function PdfPreview(props) {
10318
+ var _a;
10319
+ var pdfContext = useContext(PdfContext);
10320
+ var initializedRef = useRef(false);
10321
+ var activeFeature = useRef();
10322
+ var dragging = useRef(false);
10323
+ var draggingResizeHandle = useRef(false);
10324
+ var draggingRotationHandle = useRef(false);
10325
+ var _b = useState({
10326
+ center: { lng: 0, lat: 0 },
10327
+ distance: 10,
10328
+ bearing: 0,
10329
+ geojson: undefined,
10330
+ }), geojsonProps = _b[0], setGeojsonProps = _b[1];
10331
+ var mapHook = useMap({
10332
+ mapId: props.mapId,
10333
+ waitForLayer: props.insertBeforeLayer,
10334
+ });
10335
+ useEffect(function () {
10336
+ if (!mapHook.map ||
10337
+ !pdfContext.geojsonRef ||
10338
+ !pdfContext.orientation ||
10339
+ !pdfContext.template ||
10340
+ initializedRef.current)
10341
+ return;
10342
+ initializedRef.current = true;
10343
+ var center = mapHook.map.map.getCenter();
10344
+ var canvasHeight = mapHook.map.map._canvas.height;
10345
+ var canvasWidth = mapHook.map.map._canvas.width;
10346
+ var bboxPixelHeight = Math.ceil(canvasHeight / 2);
10347
+ var bboxPixelWidth = Math.ceil((pdfContext.template.width / pdfContext.template.height) * bboxPixelHeight);
10348
+ var topLeft = mapHook.map.map.unproject([
10349
+ Math.floor(canvasWidth / 2 - bboxPixelWidth / 2),
10350
+ Math.floor(canvasHeight / 2 - bboxPixelHeight / 2),
10351
+ ]);
10352
+ var distance = turf.distance([center.lng, center.lat], [topLeft.lng, topLeft.lat]);
10353
+ var tmpGeojsonProps = {
10354
+ center: center,
10355
+ distance: distance,
10356
+ bearing: 0,
10357
+ geojson: createPreviewGeojson({ center: center, distance: distance, bearing: 0 }, pdfContext.orientation),
10358
+ };
10359
+ setGeojsonProps(tmpGeojsonProps);
10360
+ pdfContext.geojsonRef.current = tmpGeojsonProps.geojson;
10361
+ }, [mapHook.map]);
10362
+ useEffect(function () {
10363
+ if (!pdfContext.orientation || !pdfContext.geojsonRef)
10364
+ return;
10365
+ var tmpGeojsonProps = JSON.parse(JSON.stringify(geojsonProps));
10366
+ tmpGeojsonProps.geojson = createPreviewGeojson(tmpGeojsonProps, pdfContext.orientation);
10367
+ setGeojsonProps(tmpGeojsonProps);
10368
+ pdfContext.geojsonRef.current = tmpGeojsonProps.geojson;
10369
+ }, [pdfContext.orientation]);
10370
+ // Resize handle events
10371
+ useLayerEvent({
10372
+ event: 'mouseenter',
10373
+ layerId: 'pdfPreviewGeojsonResizeHandle',
10374
+ eventHandler: function () {
10375
+ if (!mapHook.map)
10376
+ return;
10377
+ mapHook.map.map._canvas.style.cursor = 'nwse-resize';
10378
+ mapHook.map.map.dragPan.disable();
10379
+ },
10380
+ });
10381
+ useLayerEvent({
10382
+ event: 'mouseleave',
10383
+ layerId: 'pdfPreviewGeojsonResizeHandle',
10384
+ eventHandler: function () {
10385
+ if (!mapHook.map)
10386
+ return;
10387
+ mapHook.map.map._canvas.style.cursor = '';
10388
+ mapHook.map.map.dragPan.enable();
10389
+ },
10390
+ });
10391
+ useLayerEvent({
10392
+ event: 'mousedown',
10393
+ layerId: 'pdfPreviewGeojsonResizeHandle',
10394
+ addTouchEvents: true,
10395
+ eventHandler: function (e) {
10396
+ e.preventDefault();
10397
+ if (!mapHook.map)
10398
+ return;
10399
+ dragging.current = false;
10400
+ draggingRotationHandle.current = false;
10401
+ draggingResizeHandle.current = true;
10402
+ mapHook.map.map._canvas.style.cursor = 'move';
10403
+ function onMove(e) {
10404
+ if (!pdfContext.geojsonRef || !draggingResizeHandle.current || !pdfContext.orientation)
10405
+ return;
10406
+ var tmpGeojsonProps = JSON.parse(JSON.stringify(geojsonProps));
10407
+ var _distance = turf.distance([tmpGeojsonProps.center.lng, tmpGeojsonProps.center.lat], [e.lngLat.lng, e.lngLat.lat]);
10408
+ // limit max diagonal distance of PDF area to 120km as larger area lead to distortions for northern and southern areas
10409
+ if (_distance > 60) {
10410
+ _distance = 60;
10411
+ }
10412
+ tmpGeojsonProps.distance = _distance;
10413
+ tmpGeojsonProps.geojson = createPreviewGeojson(tmpGeojsonProps, pdfContext.orientation);
10414
+ pdfContext.geojsonRef.current = tmpGeojsonProps.geojson;
10415
+ setGeojsonProps(tmpGeojsonProps);
10416
+ }
10417
+ function onUp() {
10418
+ if (!draggingResizeHandle.current || !mapHook.map)
10419
+ return;
10420
+ mapHook.map.map._canvas.style.cursor = '';
10421
+ draggingResizeHandle.current = false;
10422
+ mapHook.map.map.dragPan.enable();
10423
+ // Unbind mouse events
10424
+ mapHook.map.map.off('mousemove', onMove);
10425
+ mapHook.map.map.off('touchmove', onMove);
10426
+ }
10427
+ // Mouse events
10428
+ mapHook.map.map.on('mousemove', onMove);
10429
+ mapHook.map.map.on('touchmove', onMove);
10430
+ mapHook.map.map.once('mouseup', onUp);
10431
+ mapHook.map.map.once('touchend', onUp);
10432
+ },
10433
+ });
10434
+ // Rotation handle events
10435
+ useLayerEvent({
10436
+ event: 'mouseenter',
10437
+ layerId: 'pdfPreviewGeojsonRotationHandle',
10438
+ eventHandler: function () {
10439
+ if (!mapHook.map)
10440
+ return;
10441
+ mapHook.map.map._canvas.style.cursor = 'nwse-resize';
10442
+ mapHook.map.map.dragPan.disable();
10443
+ },
10444
+ });
10445
+ useLayerEvent({
10446
+ event: 'mouseleave',
10447
+ layerId: 'pdfPreviewGeojsonRotationHandle',
10448
+ eventHandler: function () {
10449
+ if (!mapHook.map)
10450
+ return;
10451
+ mapHook.map.map._canvas.style.cursor = '';
10452
+ mapHook.map.map.dragPan.enable();
10453
+ },
10454
+ });
10455
+ useLayerEvent({
10456
+ event: 'mousedown',
10457
+ layerId: 'pdfPreviewGeojsonRotationHandle',
10458
+ addTouchEvents: true,
10459
+ eventHandler: function (e) {
10460
+ e.preventDefault();
10461
+ if (!mapHook.map || !pdfContext.orientation)
10462
+ return;
10463
+ dragging.current = false;
10464
+ draggingResizeHandle.current = false;
10465
+ draggingRotationHandle.current = true;
10466
+ mapHook.map.map._canvas.style.cursor = 'move';
10467
+ function onMove(e) {
10468
+ e.preventDefault();
10469
+ if (!draggingRotationHandle.current || !pdfContext.orientation || !pdfContext.geojsonRef)
10470
+ return;
10471
+ var tmpGeojsonProps = JSON.parse(JSON.stringify(geojsonProps));
10472
+ var _bearing = turf.bearing([tmpGeojsonProps.center.lng, tmpGeojsonProps.center.lat], [e.lngLat.lng, e.lngLat.lat]);
10473
+ tmpGeojsonProps.bearing = 144.7 + _bearing;
10474
+ tmpGeojsonProps.geojson = createPreviewGeojson(tmpGeojsonProps, pdfContext.orientation);
10475
+ pdfContext.geojsonRef.current = tmpGeojsonProps.geojson;
10476
+ setGeojsonProps(tmpGeojsonProps);
10477
+ }
10478
+ function onUp() {
10479
+ if (!draggingRotationHandle.current || !mapHook.map)
10480
+ return;
10481
+ mapHook.map.map._canvas.style.cursor = '';
10482
+ draggingRotationHandle.current = false;
10483
+ mapHook.map.map.dragPan.enable();
10484
+ // Unbind mouse events
10485
+ mapHook.map.map.off('mousemove', onMove);
10486
+ mapHook.map.map.off('touchmove', onMove);
10487
+ }
10488
+ // Mouse events
10489
+ mapHook.map.map.on('mousemove', onMove);
10490
+ mapHook.map.map.on('touchmove', onMove);
10491
+ mapHook.map.map.once('mouseup', onUp);
10492
+ mapHook.map.map.once('touchend', onUp);
10493
+ },
10494
+ });
10495
+ // drag & drop events
10496
+ useLayerEvent({
10497
+ event: 'mouseenter',
10498
+ layerId: 'pdfPreviewGeojson',
10499
+ eventHandler: function (e) {
10500
+ var _a;
10501
+ if (!mapHook.map || !((_a = e === null || e === void 0 ? void 0 : e.features) === null || _a === void 0 ? void 0 : _a.length))
10502
+ return;
10503
+ mapHook.map.map._canvas.style.cursor = 'move';
10504
+ activeFeature.current = e.features[0];
10505
+ },
10506
+ });
10507
+ useLayerEvent({
10508
+ event: 'mouseleave',
10509
+ layerId: 'pdfPreviewGeojson',
10510
+ eventHandler: function () {
10511
+ if (!mapHook.map)
10512
+ return;
10513
+ mapHook.map.map._canvas.style.cursor = '';
10514
+ mapHook.map.map.dragPan.enable();
10515
+ activeFeature.current = undefined;
10516
+ },
10517
+ });
10518
+ useLayerEvent({
10519
+ event: 'mousedown',
10520
+ addTouchEvents: true,
10521
+ layerId: 'pdfPreviewGeojson',
10522
+ eventHandler: function (e) {
10523
+ e.preventDefault();
10524
+ console.log('mousedown');
10525
+ if (!mapHook.map)
10526
+ return;
10527
+ draggingResizeHandle.current = false;
10528
+ draggingRotationHandle.current = false;
10529
+ dragging.current = true;
10530
+ mapHook.map.map._canvas.style.cursor = 'move';
10531
+ function onMove(e) {
10532
+ e.preventDefault();
10533
+ if (!dragging.current || !pdfContext.geojsonRef || !pdfContext.orientation)
10534
+ return;
10535
+ var tmpGeojsonProps = JSON.parse(JSON.stringify(geojsonProps));
10536
+ tmpGeojsonProps.center = e.lngLat;
10537
+ tmpGeojsonProps.geojson = createPreviewGeojson(tmpGeojsonProps, pdfContext.orientation);
10538
+ pdfContext.geojsonRef.current = tmpGeojsonProps.geojson;
10539
+ setGeojsonProps(tmpGeojsonProps);
10540
+ }
10541
+ function onUp() {
10542
+ if (!dragging.current || !mapHook.map)
10543
+ return;
10544
+ mapHook.map.map._canvas.style.cursor = '';
10545
+ dragging.current = false;
10546
+ mapHook.map.map.dragPan.enable();
10547
+ // Unbind mouse events
10548
+ mapHook.map.map.off('mousemove', onMove);
10549
+ mapHook.map.map.off('touchmove', onMove);
10550
+ }
10551
+ // Mouse events
10552
+ mapHook.map.map.on('mousemove', onMove);
10553
+ mapHook.map.map.on('touchmove', onMove);
10554
+ mapHook.map.map.once('mouseup', onUp);
10555
+ mapHook.map.map.once('touchend', onUp);
10556
+ },
10557
+ });
10558
+ //map.on('mouseleave', 'point', function() {
10559
+ // map.setPaintProperty('point', 'circle-color', '#3887be');
10560
+ // canvas.style.cursor = '';
10561
+ // isCursorOverPoint = false;
10562
+ // map.dragPan.enable();
10563
+ //});
10564
+ return (React__default.createElement(React__default.Fragment, null, ((_a = geojsonProps === null || geojsonProps === void 0 ? void 0 : geojsonProps.geojson) === null || _a === void 0 ? void 0 : _a.bbox) && (React__default.createElement(React__default.Fragment, null,
10565
+ React__default.createElement(MlGeoJsonLayer, { paint: { 'line-color': '#616161', 'line-width': 4 }, type: "line", layerId: "pdfPreviewGeojsonOutline", geojson: geojsonProps.geojson }),
10566
+ React__default.createElement(MlGeoJsonLayer, { paint: { 'fill-opacity': 0 }, type: "fill", layerId: "pdfPreviewGeojson", geojson: geojsonProps.geojson }),
10567
+ React__default.createElement(MlGeoJsonLayer, { layerId: "pdfPreviewGeojsonResizeHandle", paint: {
10568
+ 'circle-radius': 10,
10569
+ 'circle-color': '#1976d2',
10570
+ 'circle-stroke-width': 2,
10571
+ 'circle-stroke-color': '#ffffff',
10572
+ }, geojson: {
10573
+ type: 'Feature',
10574
+ geometry: {
10575
+ type: 'Point',
10576
+ //coordinates: [geojsonProps.geojson.bbox[2], geojsonProps.geojson.bbox[3]],
10577
+ coordinates: geojsonProps.geojson.geometry.coordinates[0][2],
10578
+ },
10579
+ properties: {},
10580
+ } }),
10581
+ React__default.createElement(MlGeoJsonLayer, { layerId: "pdfPreviewGeojsonRotationHandle", paint: {
10582
+ 'circle-radius': 10,
10583
+ 'circle-color': '#86dd71',
10584
+ 'circle-stroke-width': 2,
10585
+ 'circle-stroke-color': '#ffffff',
10586
+ }, geojson: {
10587
+ type: 'Feature',
10588
+ geometry: {
10589
+ type: 'Point',
10590
+ //coordinates: [geojsonProps.geojson.bbox[0], geojsonProps.geojson.bbox[3]],
10591
+ coordinates: geojsonProps.geojson.geometry.coordinates[0][3],
10592
+ },
10593
+ properties: {},
10594
+ } })))));
10595
+ }
10596
+
10597
+ var createExport = function (options) {
10598
+ var width = options.width;
10599
+ var height = options.height;
10600
+ // Create map container
10601
+ var hiddenContainer = document.createElement('div');
10602
+ hiddenContainer.className = 'hidden-map';
10603
+ document.body.appendChild(hiddenContainer);
10604
+ var container = document.createElement('div');
10605
+ container.style.width = width + 'px';
10606
+ container.style.height = height + 'px';
10607
+ hiddenContainer.appendChild(container);
10608
+ var style = options.map.map.getStyle();
10609
+ var _loop_1 = function (name_1) {
10610
+ var src = style.sources[name_1];
10611
+ Object.keys(src).forEach(function (key) {
10612
+ // delete property if value is undefined.
10613
+ // for instance, raster-dem might have undefined value in "url" and "bounds"
10614
+ if (!src[key]) {
10615
+ delete src[key];
10616
+ }
10617
+ });
10618
+ };
10619
+ // delete undefined source properties
10620
+ for (var name_1 in style.sources) {
10621
+ _loop_1(name_1);
10622
+ }
10623
+ // Create a new MapLibre-gl instance
10624
+ var renderMap = new Map$2({
10625
+ container: container,
10626
+ center: options.map.map.getCenter(),
10627
+ zoom: options.map.map.getZoom(),
10628
+ bearing: 0,
10629
+ pitch: 0,
10630
+ interactive: false,
10631
+ preserveDrawingBuffer: true,
10632
+ fadeDuration: 0,
10633
+ attributionControl: false,
10634
+ style: style,
10635
+ });
10636
+ var _previewGeojson = turf.bboxPolygon([
10637
+ options.bbox[0],
10638
+ options.bbox[1],
10639
+ options.bbox[2],
10640
+ options.bbox[3],
10641
+ ]);
10642
+ _previewGeojson = turf.transformRotate(_previewGeojson, options.bearing);
10643
+ // use original unrotated bbox and bearing 0 to calculate the correct zoom value as the function always adds a padding if used on the rotated feature coordinates
10644
+ var bboxCamera = renderMap._cameraForBoxAndBearing([options.bboxUnrotated[0], options.bboxUnrotated[1]], [options.bboxUnrotated[2], options.bboxUnrotated[3]], 0);
10645
+ var geometryCamera = renderMap._cameraForBoxAndBearing(_previewGeojson.geometry.coordinates[0][0], _previewGeojson.geometry.coordinates[0][2], options.bearing);
10646
+ geometryCamera.zoom = bboxCamera.zoom;
10647
+ renderMap._fitInternal(geometryCamera);
10648
+ return new Promise(function (resolve) {
10649
+ renderMap.once('idle', function () {
10650
+ if (renderMap.getLayer('pdfPreviewGeojsonOutline')) {
10651
+ renderMap.setLayoutProperty('pdfPreviewGeojsonOutline', 'visibility', 'none');
10652
+ }
10653
+ if (renderMap.getLayer('pdfPreviewGeojson')) {
10654
+ renderMap.setLayoutProperty('pdfPreviewGeojson', 'visibility', 'none');
10655
+ }
10656
+ if (renderMap.getLayer('pdfPreviewGeojsonResizeHandle')) {
10657
+ renderMap.setLayoutProperty('pdfPreviewGeojsonResizeHandle', 'visibility', 'none');
10658
+ }
10659
+ if (renderMap.getLayer('pdfPreviewGeojsonRotationHandle')) {
10660
+ renderMap.setLayoutProperty('pdfPreviewGeojsonRotationHandle', 'visibility', 'none');
10661
+ }
10662
+ renderMap.once('idle', function () {
10663
+ var params = __assign(__assign({}, options), { renderMap: renderMap, hiddenContainer: hiddenContainer, createPdf: function (_options) {
10664
+ return createJsPdf(__assign(__assign(__assign({}, options), { renderMap: renderMap, hiddenContainer: hiddenContainer }), _options));
10665
+ } });
10666
+ resolve(params);
10667
+ });
10668
+ });
10669
+ });
10670
+ };
10671
+ function createJsPdf(options) {
10672
+ var pdf = new jsPDF({
10673
+ orientation: (options === null || options === void 0 ? void 0 : options.orientation) === 'portrait' ? 'p' : 'l',
10674
+ unit: 'mm',
10675
+ compress: true,
10676
+ format: options.format,
10677
+ });
10678
+ Object.defineProperty(window, 'devicePixelRatio', {
10679
+ get: function () {
10680
+ return 300 / 96;
10681
+ },
10682
+ });
10683
+ return new Promise(function (resolve) {
10684
+ var _a;
10685
+ //Render map image
10686
+ pdf.addImage(options.renderMap.getCanvas().toDataURL('image/png'), 'png', 0, 0, pdf.internal.pageSize.getWidth(), pdf.internal.pageSize.getHeight(), undefined, 'FAST');
10687
+ // remove DOM Elements
10688
+ options.renderMap.remove();
10689
+ (_a = options.hiddenContainer.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(options.hiddenContainer);
10690
+ var params = __assign(__assign({}, options), { pdf: pdf, downloadPdf: function (_options) { return downloadPdf(__assign(__assign({}, params), _options)); } });
10691
+ resolve(params);
10692
+ });
10693
+ }
10694
+ function downloadPdf(options) {
10695
+ options.pdf.save('Map.pdf');
10696
+ return new Promise(function (resolve) {
10697
+ resolve(__assign({}, options));
10698
+ });
10699
+ }
10700
+
10701
+ function exportMap(props) {
10702
+ var mapHook = useMap({ mapId: props.mapId });
10703
+ var _createExport = useMemo(function () {
10704
+ if (mapHook.map) {
10705
+ return function (options) {
10706
+ return createExport(__assign({ map: mapHook.map }, options));
10707
+ };
10708
+ }
10709
+ return;
10710
+ }, [mapHook.map]);
10711
+ return {
10712
+ createExport: _createExport,
10713
+ };
10714
+ }
10715
+
10716
+ var qualityOptions = [
10717
+ {
10718
+ value: '72dpi',
10719
+ label: 'Draft (72dpi)',
10720
+ },
10721
+ {
10722
+ value: '150dpi',
10723
+ label: 'Medium (150dpi)',
10724
+ },
10725
+ {
10726
+ value: '300dpi',
10727
+ label: 'High (300dpi)',
10728
+ },
10729
+ ];
10730
+ function PdfForm(props) {
10731
+ var pdfContext = useContext(PdfContext);
10732
+ var mapHook = useMap({
10733
+ // eslint-disable-next-line react/prop-types
10734
+ mapId: props.mapId,
10735
+ });
10736
+ var mapExporter = exportMap({ mapId: props.mapId });
10737
+ var createPdfHandler = useCallback(function () {
10738
+ var _a, _b, _c, _d, _e;
10739
+ if (mapHook.map &&
10740
+ mapExporter.createExport &&
10741
+ pdfContext.template &&
10742
+ pdfContext.format &&
10743
+ pdfContext.orientation &&
10744
+ ((_b = (_a = pdfContext.geojsonRef) === null || _a === void 0 ? void 0 : _a.current) === null || _b === void 0 ? void 0 : _b.bbox) &&
10745
+ ((_c = pdfContext.geojsonRef) === null || _c === void 0 ? void 0 : _c.current)) {
10746
+ var bbox = turf.bbox(pdfContext.geojsonRef.current);
10747
+ mapExporter
10748
+ .createExport({
10749
+ width: pdfContext.template.width,
10750
+ height: pdfContext.template.height,
10751
+ bbox: bbox,
10752
+ bboxUnrotated: pdfContext.geojsonRef.current.bbox,
10753
+ bearing: ((_e = (_d = pdfContext.geojsonRef.current) === null || _d === void 0 ? void 0 : _d.properties) === null || _e === void 0 ? void 0 : _e.bearing) || 0,
10754
+ format: pdfContext.format.toLowerCase(),
10755
+ orientation: pdfContext.orientation,
10756
+ })
10757
+ .then(function (res) { return res.createPdf(); })
10758
+ .then(function (res) {
10759
+ if (typeof props.onCreatePdf === 'function') {
10760
+ props.onCreatePdf(res);
10761
+ }
10762
+ return res.downloadPdf();
10763
+ })
10764
+ .catch(function (error) {
10765
+ console.log(error);
10766
+ });
10767
+ }
10768
+ }, [mapHook.map, pdfContext]);
10769
+ var formControlStyles = useMemo(function () {
10770
+ return {
10771
+ margin: '5px 0 15px 0 ',
10772
+ //...props.formControlStyles,
10773
+ };
10774
+ }, [
10775
+ /*props.formControlStyles*/
10776
+ ]);
10777
+ return (React__default.createElement(React__default.Fragment, null,
10778
+ React__default.createElement(FormControl, { fullWidth: true, sx: formControlStyles },
10779
+ React__default.createElement(InputLabel, { id: "format-select-label" }, "Format"),
10780
+ React__default.createElement(Select, { labelId: "format-select-label", id: "format-select", label: "Format", value: pdfContext.format, onChange: function (event) {
10781
+ var _a;
10782
+ (_a = pdfContext.setFormat) === null || _a === void 0 ? void 0 : _a.call(pdfContext, event.target.value);
10783
+ } }, Object.keys(PdfTemplates).map(function (el) { return (React__default.createElement(MenuItem, { key: el, value: el }, el)); }))),
10784
+ React__default.createElement(FormControl, { fullWidth: true, sx: formControlStyles },
10785
+ React__default.createElement(FormLabel, { id: "orientation-radio-buttons-group-label" }, "Orientation"),
10786
+ React__default.createElement(RadioGroup, { row: true, "aria-labelledby": "orientation-radio-buttons-group-label", name: "orientation-radio-buttons-group", value: pdfContext.orientation, onChange: function (event) {
10787
+ var _a;
10788
+ (_a = pdfContext.setOrientation) === null || _a === void 0 ? void 0 : _a.call(pdfContext, event.target.value);
10789
+ } },
10790
+ React__default.createElement(FormControlLabel, { value: "portrait", control: React__default.createElement(Radio, null), label: "Portrait" }),
10791
+ React__default.createElement(FormControlLabel, { value: "landscape", control: React__default.createElement(Radio, null), label: "Landscape" }))),
10792
+ React__default.createElement(FormControl, { fullWidth: true, sx: formControlStyles },
10793
+ React__default.createElement(InputLabel, { id: "quality-select-label" }, "Quality"),
10794
+ React__default.createElement(Select, { labelId: "quality-select-label", id: "quality-select", label: "Qualit\u00E4t", value: pdfContext.quality, onChange: function (event) {
10795
+ var _a;
10796
+ (_a = pdfContext.setQuality) === null || _a === void 0 ? void 0 : _a.call(pdfContext, event.target.value);
10797
+ } }, qualityOptions.map(function (el) { return (React__default.createElement(MenuItem, { key: el.value, value: el.value }, el.label)); }))),
10798
+ React__default.createElement(FormControl, { fullWidth: true, sx: formControlStyles },
10799
+ React__default.createElement(Button$2, { variant: "contained", onClick: createPdfHandler }, "PDF erstellen"))));
10800
+ }
10801
+
10802
+ /**
10803
+ * Create PDF Form Component
10804
+ *
10805
+ */
10806
+ var MlCreatePdfForm = function (props) {
10807
+ return (React__default.createElement(React__default.Fragment, null,
10808
+ React__default.createElement(PdfContextProvider, null,
10809
+ React__default.createElement(PdfForm, __assign({}, props)),
10810
+ React__default.createElement(PdfPreview, null))));
10811
+ };
10812
+ MlCreatePdfForm.defaultProps = {
10813
+ mapId: undefined,
10814
+ };
10815
+
10816
+ /**
10817
+ * Code from https://github.com/mapbox/mapbox-gl-draw
10818
+ * and licensed under ISC
10819
+ */
10820
+ var classes = {
10821
+ CONTROL_BASE: 'mapboxgl-ctrl',
10822
+ CONTROL_PREFIX: 'mapboxgl-ctrl-',
10823
+ CONTROL_BUTTON: 'mapbox-gl-draw_ctrl-draw-btn',
10824
+ CONTROL_BUTTON_LINE: 'mapbox-gl-draw_line',
10825
+ CONTROL_BUTTON_POLYGON: 'mapbox-gl-draw_polygon',
10826
+ CONTROL_BUTTON_POINT: 'mapbox-gl-draw_point',
10827
+ CONTROL_BUTTON_TRASH: 'mapbox-gl-draw_trash',
10828
+ CONTROL_BUTTON_COMBINE_FEATURES: 'mapbox-gl-draw_combine',
10829
+ CONTROL_BUTTON_UNCOMBINE_FEATURES: 'mapbox-gl-draw_uncombine',
10830
+ CONTROL_GROUP: 'mapboxgl-ctrl-group',
10831
+ ATTRIBUTION: 'mapboxgl-ctrl-attrib',
10832
+ ACTIVE_BUTTON: 'active',
10833
+ BOX_SELECT: 'mapbox-gl-draw_boxselect'
10834
+ };
10835
+ var cursors = {
10836
+ ADD: 'add',
10837
+ MOVE: 'move',
10838
+ DRAG: 'drag',
10839
+ POINTER: 'pointer',
10840
+ NONE: 'none'
10841
+ };
10842
+ var types$1 = {
10843
+ POLYGON: 'polygon',
10844
+ LINE: 'line_string',
10845
+ POINT: 'point'
10846
+ };
10847
+ var geojsonTypes = {
10848
+ FEATURE: 'Feature',
10849
+ POLYGON: 'Polygon',
10850
+ LINE_STRING: 'LineString',
10851
+ POINT: 'Point',
10852
+ FEATURE_COLLECTION: 'FeatureCollection',
10853
+ MULTI_PREFIX: 'Multi',
10854
+ MULTI_POINT: 'MultiPoint',
10855
+ MULTI_LINE_STRING: 'MultiLineString',
10856
+ MULTI_POLYGON: 'MultiPolygon'
10857
+ };
10858
+ var events = {
10859
+ CREATE: 'draw.create',
10860
+ DELETE: 'draw.delete',
10861
+ UPDATE: 'draw.update',
10862
+ SELECTION_CHANGE: 'draw.selectionchange',
10863
+ MODE_CHANGE: 'draw.modechange',
10864
+ ACTIONABLE: 'draw.actionable',
10865
+ RENDER: 'draw.render',
10866
+ COMBINE_FEATURES: 'draw.combine',
10867
+ UNCOMBINE_FEATURES: 'draw.uncombine'
10868
+ };
10869
+ var updateActions = {
10870
+ MOVE: 'move',
10871
+ CHANGE_COORDINATES: 'change_coordinates'
10872
+ };
10873
+ var meta = {
10874
+ FEATURE: 'feature',
10875
+ MIDPOINT: 'midpoint',
10876
+ VERTEX: 'vertex'
10877
+ };
10878
+ var activeStates = {
10879
+ ACTIVE: 'true',
10880
+ INACTIVE: 'false'
10881
+ };
10882
+ var LAT_MIN$1 = -90;
10883
+ var LAT_RENDERED_MIN$1 = -85;
10884
+ var LAT_MAX$1 = 90;
9995
10885
  var LAT_RENDERED_MAX$1 = 85;
9996
10886
  var LNG_MIN$1 = -270;
9997
10887
  var LNG_MAX$1 = 270;
@@ -10091,7 +10981,7 @@ function isEventAtCoordinates(event, coordinates) {
10091
10981
  * @param {string} parentId
10092
10982
  * @param {Array<number>} coordinates
10093
10983
  * @param {string} path - Dot-separated numbers indicating exactly
10094
- * where the point exists within its parent feature's coordinates.
10984
+ * where the point exists within its parent feature's coordinates.
10095
10985
  * @param {boolean} selected
10096
10986
  * @return {GeoJSON} Point
10097
10987
  */
@@ -11368,7 +12258,7 @@ var LAT_MIN = LAT_MIN$1,
11368
12258
  LNG_MAX = LNG_MAX$1; // Ensure that we do not drag north-south far enough for
11369
12259
  // - any part of any feature to exceed the poles
11370
12260
  // - any feature to be completely lost in the space between the projection's
11371
- // edge and the poles, such that it couldn't be re-selected and moved back
12261
+ // edge and the poles, such that it couldn't be re-selected and moved back
11372
12262
 
11373
12263
  var constrain_feature_movement = function constrain_feature_movement(geojsonFeatures, delta) {
11374
12264
  // "inner edge" = a feature's latitude closest to the equator
@@ -11617,7 +12507,7 @@ CustomSelectMode.clickOnVertex = function (state, e) {
11617
12507
  this.changeMode("custom_direct_select", {
11618
12508
  featureId: e.featureTarget.properties.parent,
11619
12509
  coordPath: e.featureTarget.properties.coord_path,
11620
- startPos: e.lngLat // groupMove_vertices: matchingVertices,
12510
+ startPos: e.lngLat // groupMove_vertices: matchingVertices,
11621
12511
 
11622
12512
  });
11623
12513
  this.updateUIClasses({
@@ -12267,135 +13157,6 @@ var MlFeatureEditor = function (props) {
12267
13157
  return React__default.createElement(React__default.Fragment, null);
12268
13158
  };
12269
13159
 
12270
- var legalLayerTypes = [
12271
- "fill",
12272
- "line",
12273
- "symbol",
12274
- "circle",
12275
- "heatmap",
12276
- "fill-extrusion",
12277
- "raster",
12278
- "hillshade",
12279
- "background",
12280
- ];
12281
- function useLayer(props) {
12282
- var mapHook = useMap({
12283
- mapId: props.mapId,
12284
- waitForLayer: props.insertBeforeLayer,
12285
- });
12286
- var layerTypeRef = useRef("");
12287
- var layerPaintConfRef = useRef("");
12288
- var layerLayoutConfRef = useRef("");
12289
- var _a = useState(), layer = _a[0], setLayer = _a[1];
12290
- var initializedRef = useRef(false);
12291
- var layerId = useRef(props.layerId || (props.idPrefix ? props.idPrefix : "Layer-") + mapHook.componentId);
12292
- var createLayer = useCallback(function () {
12293
- var _a, _b;
12294
- if (!mapHook.map)
12295
- return;
12296
- if (mapHook.map.map.getLayer(layerId.current)) {
12297
- mapHook.cleanup();
12298
- }
12299
- if (mapHook.map.map.getSource(layerId.current)) {
12300
- mapHook.map.map.removeSource(layerId.current);
12301
- }
12302
- initializedRef.current = true;
12303
- mapHook.map.addLayer(__assign(__assign(__assign({}, props.options), (props.geojson
12304
- ? {
12305
- source: {
12306
- type: "geojson",
12307
- data: props.geojson,
12308
- },
12309
- }
12310
- : {})), { id: layerId.current }), props.insertBeforeLayer
12311
- ? props.insertBeforeLayer
12312
- : props.insertBeforeFirstSymbolLayer
12313
- ? mapHook.map.firstSymbolLayer
12314
- : undefined, mapHook.componentId);
12315
- setLayer(mapHook.map.map.getLayer(layerId.current));
12316
- if (typeof props.onHover !== "undefined") {
12317
- mapHook.map.on("mousemove", layerId.current, props.onHover, mapHook.componentId);
12318
- }
12319
- if (typeof props.onClick !== "undefined") {
12320
- mapHook.map.on("click", layerId.current, props.onClick, mapHook.componentId);
12321
- }
12322
- if (typeof props.onLeave !== "undefined") {
12323
- mapHook.map.on("mouseleave", layerId.current, props.onLeave, mapHook.componentId);
12324
- }
12325
- // recreate layer if style has changed
12326
- mapHook.map.on("styledata", function () {
12327
- var _a;
12328
- if (initializedRef.current && !((_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map.getLayer(layerId.current))) {
12329
- console.log("Recreate Layer");
12330
- createLayer();
12331
- }
12332
- }, mapHook.componentId);
12333
- layerPaintConfRef.current = JSON.stringify((_a = props.options) === null || _a === void 0 ? void 0 : _a.paint);
12334
- layerLayoutConfRef.current = JSON.stringify((_b = props.options) === null || _b === void 0 ? void 0 : _b.layout);
12335
- layerTypeRef.current = props.options.type;
12336
- }, [props, mapHook.map]);
12337
- useEffect(function () {
12338
- if (!mapHook.map)
12339
- return;
12340
- if (initializedRef.current &&
12341
- (legalLayerTypes.indexOf(props.options.type) === -1 ||
12342
- (legalLayerTypes.indexOf(props.options.type) !== -1 &&
12343
- props.options.type === layerTypeRef.current))) {
12344
- return;
12345
- }
12346
- createLayer();
12347
- }, [mapHook.map, props.options, createLayer]);
12348
- useEffect(function () {
12349
- var _a, _b, _c, _d;
12350
- if (!initializedRef.current || !((_b = (_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.getSource(layerId.current)))
12351
- return;
12352
- //@ts-ignore setData only exists on GeoJsonSource
12353
- (_d = (_c = mapHook.map.map.getSource(layerId.current)) === null || _c === void 0 ? void 0 : _c.setData) === null || _d === void 0 ? void 0 : _d.call(_c, props.geojson);
12354
- }, [props.geojson, mapHook.map, props.options.type]);
12355
- useEffect(function () {
12356
- var _a, _b, _c, _d, _e;
12357
- if (!mapHook.map ||
12358
- !((_c = (_b = (_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.getLayer) === null || _c === void 0 ? void 0 : _c.call(_b, layerId.current)) ||
12359
- !initializedRef.current ||
12360
- props.options.type !== layerTypeRef.current)
12361
- return;
12362
- var key;
12363
- var layoutString = JSON.stringify(props.options.layout);
12364
- if (props.options.layout && layoutString !== layerLayoutConfRef.current) {
12365
- var oldLayout = JSON.parse(layerLayoutConfRef.current);
12366
- for (key in props.options.layout) {
12367
- if (((_d = props.options.layout) === null || _d === void 0 ? void 0 : _d[key]) && props.options.layout[key] !== oldLayout[key]) {
12368
- mapHook.map.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);
12369
- }
12370
- }
12371
- layerLayoutConfRef.current = layoutString;
12372
- }
12373
- var paintString = JSON.stringify(props.options.paint);
12374
- if (paintString !== layerPaintConfRef.current) {
12375
- var oldPaint = JSON.parse(layerPaintConfRef.current);
12376
- for (key in props.options.paint) {
12377
- if (((_e = props.options.paint) === null || _e === void 0 ? void 0 : _e[key]) && props.options.paint[key] !== oldPaint[key]) {
12378
- mapHook.map.map.setPaintProperty(layerId.current, key, props.options.paint[key]);
12379
- }
12380
- }
12381
- layerPaintConfRef.current = paintString;
12382
- }
12383
- }, [props.options, mapHook.map]);
12384
- useEffect(function () {
12385
- return function () {
12386
- initializedRef.current = false;
12387
- mapHook.cleanup();
12388
- };
12389
- }, []);
12390
- return {
12391
- map: mapHook.map,
12392
- layer: layer,
12393
- layerId: layerId.current,
12394
- componentId: mapHook.componentId,
12395
- mapHook: mapHook,
12396
- };
12397
- }
12398
-
12399
13160
  /**
12400
13161
  * Adds a fill extrusion layer to the MapLibre instance reference by props.mapId
12401
13162
  *
@@ -12432,84 +13193,6 @@ MlFillExtrusionLayer.defaultProps = {
12432
13193
  },
12433
13194
  };
12434
13195
 
12435
- var getDefaultPaintPropsByType = function (type, defaultPaintOverrides) {
12436
- switch (type) {
12437
- case "fill":
12438
- if (defaultPaintOverrides === null || defaultPaintOverrides === void 0 ? void 0 : defaultPaintOverrides.fill) {
12439
- return defaultPaintOverrides.fill;
12440
- }
12441
- return {
12442
- "fill-color": "rgba(10,240,256,0.6)",
12443
- };
12444
- case "line":
12445
- if (defaultPaintOverrides === null || defaultPaintOverrides === void 0 ? void 0 : defaultPaintOverrides.line) {
12446
- return defaultPaintOverrides.line;
12447
- }
12448
- return {
12449
- "line-color": "rgb(203,211,2)",
12450
- "line-width": 5,
12451
- };
12452
- case "circle":
12453
- default:
12454
- if (defaultPaintOverrides === null || defaultPaintOverrides === void 0 ? void 0 : defaultPaintOverrides.circle) {
12455
- return defaultPaintOverrides.circle;
12456
- }
12457
- return {
12458
- "circle-color": "rgba(10,240,256,0.8)",
12459
- "circle-stroke-color": "#fff",
12460
- "circle-stroke-width": 2,
12461
- };
12462
- }
12463
- };
12464
-
12465
- var mapGeometryTypesToLayerTypes = {
12466
- Position: "circle",
12467
- Point: "circle",
12468
- MultiPoint: "circle",
12469
- LineString: "line",
12470
- MultiLineString: "line",
12471
- Polygon: "fill",
12472
- MultiPolygon: "fill",
12473
- GeometryCollection: "circle",
12474
- };
12475
- var getDefaulLayerTypeByGeometry = function (geojson) {
12476
- var _a;
12477
- if ((geojson === null || geojson === void 0 ? void 0 : geojson.type) === "Feature") {
12478
- return (mapGeometryTypesToLayerTypes === null || mapGeometryTypesToLayerTypes === void 0 ? void 0 : mapGeometryTypesToLayerTypes[(_a = geojson === null || geojson === void 0 ? void 0 : geojson.geometry) === null || _a === void 0 ? void 0 : _a.type])
12479
- ? mapGeometryTypesToLayerTypes[geojson.geometry.type]
12480
- : "circle";
12481
- }
12482
- if ((geojson === null || geojson === void 0 ? void 0 : geojson.type) === "FeatureCollection") {
12483
- if (geojson.features.length) {
12484
- return getDefaulLayerTypeByGeometry(geojson.features[0]);
12485
- }
12486
- return "circle";
12487
- }
12488
- return "fill";
12489
- };
12490
-
12491
- /**
12492
- * Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
12493
- *
12494
- * @component
12495
- */
12496
- var MlGeoJsonLayer = function (props) {
12497
- var layerType = props.type || getDefaulLayerTypeByGeometry(props.geojson);
12498
- // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
12499
- useLayer({
12500
- mapId: props.mapId,
12501
- layerId: props.layerId || "MlGeoJsonLayer-" + v4(),
12502
- geojson: props.geojson,
12503
- options: __assign(__assign({ paint: props.paint ||
12504
- getDefaultPaintPropsByType(layerType, props.defaultPaintOverrides), layout: props.layout || {} }, props.options), { type: layerType }),
12505
- insertBeforeLayer: props.insertBeforeLayer,
12506
- onHover: props.onHover,
12507
- onClick: props.onClick,
12508
- onLeave: props.onLeave,
12509
- });
12510
- return (React__default.createElement(React__default.Fragment, null));
12511
- };
12512
-
12513
13196
  var GpsFixed = {};
12514
13197
 
12515
13198
  var _interopRequireDefault$4 = interopRequireDefault.exports;
@@ -12757,8 +13440,8 @@ var MlImageMarkerLayer = function (props) {
12757
13440
  };
12758
13441
 
12759
13442
  //const unitSquareConvert = {
12760
- // kilometers: 1,
12761
- // miles: 1 / 2.58998811,
13443
+ // kilometers: 1,
13444
+ // miles: 1 / 2.58998811,
12762
13445
  //};
12763
13446
  function getUnitSquareMultiplier(measureType) {
12764
13447
  return measureType === "miles" ? 1 / 2.58998811 : 1;
@@ -13179,9 +13862,9 @@ var SvgNeedle = function SvgNeedle(props) {
13179
13862
  }))));
13180
13863
  };
13181
13864
 
13182
- var NeedleButton = styled$3.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 40%;\n display: flex;\n align-items: center;\n\n &:hover {\n cursor: pointer;\n }\n path {\n filter: drop-shadow(0px 0px 15px rgba(0, 0, 0, 0.2));\n }\n &:hover path {\n filter: drop-shadow(0px 0px 13px rgba(255, 255, 255, 0.1));\n }\n path:nth-of-type(2) {\n fill: #343434;\n }\n &:hover path:nth-of-type(2) {\n fill: #434343;\n }\n path:nth-of-type(1) {\n fill: #e90318;\n }\n &:hover path:nth-of-type(1) {\n fill: #fb4052;\n }\n"], ["\n width: 40%;\n display: flex;\n align-items: center;\n\n &:hover {\n cursor: pointer;\n }\n path {\n filter: drop-shadow(0px 0px 15px rgba(0, 0, 0, 0.2));\n }\n &:hover path {\n filter: drop-shadow(0px 0px 13px rgba(255, 255, 255, 0.1));\n }\n path:nth-of-type(2) {\n fill: #343434;\n }\n &:hover path:nth-of-type(2) {\n fill: #434343;\n }\n path:nth-of-type(1) {\n fill: #e90318;\n }\n &:hover path:nth-of-type(1) {\n fill: #fb4052;\n }\n"])));
13183
- var NeedleContainer = styled$3.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n pointer-events: none;\n display: flex;\n z-index: 1002;\n position: absolute;\n align-items: center;\n\n margin-left: -30%;\n path:nth-of-type(2) {\n }\n svg g {\n transform: translate(-76.7053, -29.7727) scale(2, 1);\n }\n svg {\n z-index: 9990;\n height: 150px;\n width: 200px;\n }\n"], ["\n pointer-events: none;\n display: flex;\n z-index: 1002;\n position: absolute;\n align-items: center;\n\n margin-left: -30%;\n path:nth-of-type(2) {\n }\n svg g {\n transform: translate(-76.7053, -29.7727) scale(2, 1);\n }\n svg {\n z-index: 9990;\n height: 150px;\n width: 200px;\n }\n"])));
13184
- var RotateButton = styled$3.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n width: 30%;\n margin-top: 14px;\n z-index: 999;\n display: flex;\n\n svg:hover {\n cursor: pointer;\n }\n svg:hover path {\n fill: #ececec;\n filter: drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.1));\n }\n path {\n fill: #bbb;\n }\n svg {\n transform: scale(0.6);\n z-index: 9990;\n height: 172px;\n }\n"], ["\n width: 30%;\n margin-top: 14px;\n z-index: 999;\n display: flex;\n\n svg:hover {\n cursor: pointer;\n }\n svg:hover path {\n fill: #ececec;\n filter: drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.1));\n }\n path {\n fill: #bbb;\n }\n svg {\n transform: scale(0.6);\n z-index: 9990;\n height: 172px;\n }\n"])));
13865
+ var NeedleButton = styled$3.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\twidth: 40%;\n\tdisplay: flex;\n\talign-items: center;\n\n\t&:hover {\n\t\tcursor: pointer;\n\t}\n\tpath {\n\t\tfilter: drop-shadow(0px 0px 15px rgba(0, 0, 0, 0.2));\n\t}\n\t&:hover path {\n\t\tfilter: drop-shadow(0px 0px 13px rgba(255, 255, 255, 0.1));\n\t}\n\tpath:nth-of-type(2) {\n\t\tfill: #343434;\n\t}\n\t&:hover path:nth-of-type(2) {\n\t\tfill: #434343;\n\t}\n\tpath:nth-of-type(1) {\n\t\tfill: #e90318;\n\t}\n\t&:hover path:nth-of-type(1) {\n\t\tfill: #fb4052;\n\t}\n"], ["\n\twidth: 40%;\n\tdisplay: flex;\n\talign-items: center;\n\n\t&:hover {\n\t\tcursor: pointer;\n\t}\n\tpath {\n\t\tfilter: drop-shadow(0px 0px 15px rgba(0, 0, 0, 0.2));\n\t}\n\t&:hover path {\n\t\tfilter: drop-shadow(0px 0px 13px rgba(255, 255, 255, 0.1));\n\t}\n\tpath:nth-of-type(2) {\n\t\tfill: #343434;\n\t}\n\t&:hover path:nth-of-type(2) {\n\t\tfill: #434343;\n\t}\n\tpath:nth-of-type(1) {\n\t\tfill: #e90318;\n\t}\n\t&:hover path:nth-of-type(1) {\n\t\tfill: #fb4052;\n\t}\n"])));
13866
+ var NeedleContainer = styled$3.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n\tpointer-events: none;\n\tdisplay: flex;\n\tz-index: 1002;\n\tposition: absolute;\n\talign-items: center;\n\n\tmargin-left: -30%;\n\tpath:nth-of-type(2) {\n\t}\n\tsvg g {\n\t\ttransform: translate(-76.7053, -29.7727) scale(2, 1);\n\t}\n\tsvg {\n\t\tz-index: 9990;\n\t\theight: 150px;\n\t\twidth: 200px;\n\t}\n"], ["\n\tpointer-events: none;\n\tdisplay: flex;\n\tz-index: 1002;\n\tposition: absolute;\n\talign-items: center;\n\n\tmargin-left: -30%;\n\tpath:nth-of-type(2) {\n\t}\n\tsvg g {\n\t\ttransform: translate(-76.7053, -29.7727) scale(2, 1);\n\t}\n\tsvg {\n\t\tz-index: 9990;\n\t\theight: 150px;\n\t\twidth: 200px;\n\t}\n"])));
13867
+ var RotateButton = styled$3.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n\twidth: 30%;\n\tmargin-top: 14px;\n\tz-index: 999;\n\tdisplay: flex;\n\n\tsvg:hover {\n\t\tcursor: pointer;\n\t}\n\tsvg:hover path {\n\t\tfill: #ececec;\n\t\tfilter: drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.1));\n\t}\n\tpath {\n\t\tfill: #bbb;\n\t}\n\tsvg {\n\t\ttransform: scale(0.6);\n\t\tz-index: 9990;\n\t\theight: 172px;\n\t}\n"], ["\n\twidth: 30%;\n\tmargin-top: 14px;\n\tz-index: 999;\n\tdisplay: flex;\n\n\tsvg:hover {\n\t\tcursor: pointer;\n\t}\n\tsvg:hover path {\n\t\tfill: #ececec;\n\t\tfilter: drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.1));\n\t}\n\tpath {\n\t\tfill: #bbb;\n\t}\n\tsvg {\n\t\ttransform: scale(0.6);\n\t\tz-index: 9990;\n\t\theight: 172px;\n\t}\n"])));
13185
13868
  /**
13186
13869
  * Navigation component that displays a compass component which indicates the current oriantation of the map it is registered for and offers controls to turn the bearing 90° left/right or reset north to point up.
13187
13870
  *
@@ -13700,13 +14383,13 @@ var defaultProps = {
13700
14383
  * @param {object} props
13701
14384
  * @param {object} props.urlParameters URL query parameters that will be added to the WMS URL. A layers property (string) is mandatory. Any value defined on this attribute will extend the default object
13702
14385
  * @param {string} props.url WMS URL
13703
- * @param {bool} props.visible Sets layer "visibility" property to "visible" if true or "none" if false
14386
+ * @param {bool} props.visible Sets layer "visibility" property to "visible" if true or "none" if false
13704
14387
  * @param {string} props.attribution MapLibre attribution shown in the bottom right of the map, if this layer is visible
13705
14388
  * @param {string} props.mapId Id of the target MapLibre instance in mapContext
13706
14389
  * @param {object} props.sourceOptions Object that is passed to the MapLibre.addSource call as config option parameter
13707
14390
  * @param {object} props.layerOptions Object that is passed to the MapLibre.addLayer call as config option parameter
13708
14391
  * @param {string} props.insertBeforeLayer Id of an existing layer in the mapLibre instance to help specify the layer order
13709
- This layer will be visually beneath the layer with the "insertBeforeLayer" id
14392
+ This layer will be visually beneath the layer with the "insertBeforeLayer" id
13710
14393
  *
13711
14394
  * @component
13712
14395
  */
@@ -14124,27 +14807,27 @@ var MlLayerMagnify = function (props) {
14124
14807
  /*
14125
14808
  automatically adjust radius for small screens
14126
14809
  if (
14127
- mapContext.maps[props.map1Id].getCanvas().clientWidth >
14128
- mapContext.maps[props.map1Id].getCanvas().clientHeight &&
14129
- magnifierRadius * 2 >
14130
- mapContext.maps[props.map1Id].getCanvas().clientHeight
14810
+ mapContext.maps[props.map1Id].getCanvas().clientWidth >
14811
+ mapContext.maps[props.map1Id].getCanvas().clientHeight &&
14812
+ magnifierRadius * 2 >
14813
+ mapContext.maps[props.map1Id].getCanvas().clientHeight
14131
14814
  ) {
14132
- magnifierRadius = Math.floor(
14133
- mapContext.maps[props.map1Id].getCanvas().clientHeight / 2
14134
- );
14135
- setMagnifierRadius(magnifierRadius);
14815
+ magnifierRadius = Math.floor(
14816
+ mapContext.maps[props.map1Id].getCanvas().clientHeight / 2
14817
+ );
14818
+ setMagnifierRadius(magnifierRadius);
14136
14819
  }
14137
-
14820
+
14138
14821
  if (
14139
- mapContext.maps[props.map1Id].getCanvas().clientHeight >
14140
- mapContext.maps[props.map1Id].getCanvas().clientWidth &&
14141
- magnifierRadius * 2 >
14142
- mapContext.maps[props.map1Id].getCanvas().clientWidth
14822
+ mapContext.maps[props.map1Id].getCanvas().clientHeight >
14823
+ mapContext.maps[props.map1Id].getCanvas().clientWidth &&
14824
+ magnifierRadius * 2 >
14825
+ mapContext.maps[props.map1Id].getCanvas().clientWidth
14143
14826
  ) {
14144
- magnifierRadius = Math.floor(
14145
- mapContext.maps[props.map1Id].getCanvas().clientWidth / 2
14146
- );
14147
- setMagnifierRadius(magnifierRadius);
14827
+ magnifierRadius = Math.floor(
14828
+ mapContext.maps[props.map1Id].getCanvas().clientWidth / 2
14829
+ );
14830
+ setMagnifierRadius(magnifierRadius);
14148
14831
  }
14149
14832
  */
14150
14833
  onMove({
@@ -14200,7 +14883,7 @@ MlLayerMagnify.defaultProps = {
14200
14883
  };
14201
14884
 
14202
14885
  /**
14203
- * creates a split view of 2 synchronised maplibre instances
14886
+ * creates a split view of 2 synchronised maplibre instances
14204
14887
  */
14205
14888
  var MlLayerSwipe = function (props) {
14206
14889
  var mapContext = useContext(MapContext);
@@ -18943,6 +19626,63 @@ useWms.defaultProps = {
18943
19626
  }
18944
19627
  };
18945
19628
 
19629
+ function useSource(props) {
19630
+ var _a;
19631
+ var mapHook = useMap({
19632
+ mapId: props.mapId,
19633
+ });
19634
+ var initializedRef = useRef(false);
19635
+ var _b = useState(), source = _b[0], setSource = _b[1];
19636
+ var sourceId = useRef(props.sourceId || (props.idPrefix ? props.idPrefix : "Source-") + mapHook.componentId);
19637
+ var createSource = useCallback(function () {
19638
+ var _a;
19639
+ if (!mapHook.map)
19640
+ return;
19641
+ initializedRef.current = true;
19642
+ if (mapHook.map.map.getSource(sourceId.current)) {
19643
+ mapHook.cleanup();
19644
+ }
19645
+ (_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.addSource(sourceId.current, __assign({}, props.source));
19646
+ setSource(mapHook.map.map.getSource(sourceId.current));
19647
+ }, [props, mapHook.map]);
19648
+ useEffect(function () {
19649
+ if (!mapHook.map || initializedRef.current)
19650
+ return;
19651
+ createSource();
19652
+ }, [mapHook.map, props, createSource]);
19653
+ useEffect(function () {
19654
+ var _a, _b, _c, _d;
19655
+ if (!initializedRef.current || !((_b = (_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.getSource(props.sourceId)))
19656
+ return;
19657
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
19658
+ //@ts-ignore setData only exists on GeoJsonSource
19659
+ (_d = (_c = mapHook.map.map.getSource(props.sourceId)) === null || _c === void 0 ? void 0 : _c.setData) === null || _d === void 0 ? void 0 : _d.call(_c, props.source.data);
19660
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
19661
+ //@ts-ignore data only exists on GeoJsonSource
19662
+ }, [(_a = props.source) === null || _a === void 0 ? void 0 : _a.data]);
19663
+ //cleanup
19664
+ useEffect(function () {
19665
+ return function () {
19666
+ initializedRef.current = false;
19667
+ if (mapHook.map) {
19668
+ for (var _i = 0, _a = Object.entries(mapHook.map.map.style._layers); _i < _a.length; _i++) {
19669
+ var _b = _a[_i], layerId = _b[0], layer = _b[1];
19670
+ if (layer.source === sourceId.current) {
19671
+ mapHook.map.map.removeLayer(layerId);
19672
+ }
19673
+ }
19674
+ mapHook.map.map.removeSource(sourceId.current);
19675
+ }
19676
+ };
19677
+ }, [mapHook.map]);
19678
+ return {
19679
+ map: mapHook.map,
19680
+ source: source,
19681
+ componentId: mapHook.componentId,
19682
+ mapHook: mapHook,
19683
+ };
19684
+ }
19685
+
18946
19686
  var SimpleDataContext = /*#__PURE__*/React__default.createContext({});
18947
19687
  var SimpleDataContextProvider = SimpleDataContext.Provider;
18948
19688
 
@@ -19005,5 +19745,5 @@ SimpleDataProvider.propTypes = {
19005
19745
  children: PropTypes.node.isRequired
19006
19746
  };
19007
19747
 
19008
- export { GeoJsonContext, GeoJsonProvider, MapComponentsProvider, MapContext, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlFollowGps, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlMarker, MlMeasureTool, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlScaleReference, MlSpatialElevationProfile, MlTransitionGeoJsonLayer, MlVectorTileLayer, MlWmsLayer, SimpleDataContext, SimpleDataProvider, useLayer, useMap, useMapState, useWms };
19748
+ export { GeoJsonContext, GeoJsonProvider, MapComponentsProvider, MapContext, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlCreatePdfForm, MlFeatureEditor, MlFillExtrusionLayer, MlFollowGps, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlMarker, MlMeasureTool, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlScaleReference, MlSpatialElevationProfile, MlTransitionGeoJsonLayer, MlVectorTileLayer, MlWmsLayer, SimpleDataContext, SimpleDataProvider, exportMap as useExportMap, useLayer, useMap, useMapState, useSource, useWms };
19009
19749
  //# sourceMappingURL=index.esm.js.map