@mapcomponents/react-maplibre 0.1.32 → 0.1.35

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 (319) hide show
  1. package/.babelrc +3 -0
  2. package/.github/workflows/storybook.yml +1 -1
  3. package/.storybook/.babelrc +26 -0
  4. package/.storybook/main.js +15 -1
  5. package/.storybook/mapcomponents_logo.png +0 -0
  6. package/CHANGELOG.md +10 -0
  7. package/config/env.js +106 -0
  8. package/config/getHttpsConfig.js +66 -0
  9. package/config/jest/babelTransform.js +29 -0
  10. package/config/jest/cssTransform.js +14 -0
  11. package/config/jest/fileTransform.js +40 -0
  12. package/config/modules.js +134 -0
  13. package/config/paths.js +75 -0
  14. package/config/pnpTs.js +35 -0
  15. package/config/webpack.config.js +757 -0
  16. package/config/webpackDevServer.config.js +130 -0
  17. package/coverage/clover.xml +822 -900
  18. package/coverage/coverage-final.json +23 -24
  19. package/coverage/lcov-report/index.html +135 -150
  20. package/coverage/lcov-report/src/components/MapLibreMap/{MapLibreMap.js.html → MapLibreMap.tsx.html} +77 -68
  21. package/coverage/lcov-report/src/components/MapLibreMap/index.html +6 -6
  22. package/coverage/lcov-report/src/components/MlCreatePdfButton/{MlCreatePdfButton.js.html → MlCreatePdfButton.tsx.html} +40 -43
  23. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +10 -10
  24. package/coverage/lcov-report/src/components/MlFeatureEditor/{MlFeatureEditor.js.html → MlFeatureEditor.tsx.html} +145 -85
  25. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +21 -21
  26. package/coverage/lcov-report/src/components/{MlImageMarkerLayer/MlImageMarkerLayer.js.html → MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html} +141 -111
  27. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +20 -20
  28. package/coverage/lcov-report/src/components/MlFollowGps/{MlFollowGps.js.html → MlFollowGps.tsx.html} +177 -138
  29. package/coverage/lcov-report/src/components/MlFollowGps/index.html +15 -15
  30. package/coverage/lcov-report/src/components/MlGPXViewer/{MlGPXViewer.js.html → MlGPXViewer.tsx.html} +134 -80
  31. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +1 -1
  32. package/coverage/lcov-report/src/components/MlGPXViewer/index.html +16 -16
  33. package/coverage/lcov-report/src/components/{MlLayer/MlLayer.js.html → MlGeoJsonLayer/MlGeoJsonLayer.tsx.html} +151 -154
  34. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +19 -19
  35. package/coverage/lcov-report/src/components/{MlFillExtrusionLayer/MlFillExtrusionLayer.js.html → MlImageMarkerLayer/MlImageMarkerLayer.tsx.html} +151 -223
  36. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +16 -16
  37. package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +229 -0
  38. package/coverage/lcov-report/src/components/MlLayer/index.html +21 -21
  39. package/coverage/lcov-report/src/components/MlLayerMagnify/{MlLayerMagnify.js.html → MlLayerMagnify.tsx.html} +134 -77
  40. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +20 -20
  41. package/coverage/lcov-report/src/components/MlLayerSwipe/{MlLayerSwipe.js.html → MlLayerSwipe.tsx.html} +83 -41
  42. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +2 -2
  43. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +3 -15
  44. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
  45. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  46. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  47. package/coverage/lcov-report/src/components/MlMarker/{MlMarker.js.html → MlMarker.tsx.html} +89 -137
  48. package/coverage/lcov-report/src/components/MlMarker/index.html +10 -10
  49. package/coverage/lcov-report/src/components/MlNavigationCompass/{MlNavigationCompass.js.html → MlNavigationCompass.tsx.html} +76 -25
  50. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +17 -17
  51. package/coverage/lcov-report/src/components/MlNavigationTools/{MlNavigationTools.js.html → MlNavigationTools.tsx.html} +67 -52
  52. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +10 -10
  53. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
  54. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  55. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
  56. package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
  57. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
  58. package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
  59. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +3 -3
  60. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  61. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +5 -5
  62. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
  63. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/{MlTransitionGeoJsonLayer.js.html → MlTransitionGeoJsonLayer.tsx.html} +127 -118
  64. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +11 -11
  65. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  66. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  67. package/coverage/lcov-report/src/components/MlVectorTileLayer/{MlVectorTileLayer.js.html → MlVectorTileLayer.tsx.html} +59 -11
  68. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +2 -2
  69. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
  70. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
  71. package/coverage/lcov-report/src/components/MlWmsLayer/{MlWmsLayer.js.html → MlWmsLayer.tsx.html} +56 -11
  72. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +2 -2
  73. package/coverage/lcov-report/src/components/MlWmsLoader/{MlWmsLoader.js.html → MlWmsLoader.tsx.html} +102 -78
  74. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +8 -8
  75. package/coverage/lcov-report/src/hooks/index.html +44 -29
  76. package/coverage/lcov-report/src/{components/MlGeoJsonLayer/MlGeoJsonLayer.js.html → hooks/useLayer.ts.html} +328 -184
  77. package/coverage/lcov-report/src/hooks/{useMap.js.html → useMap.ts.html} +140 -50
  78. package/coverage/lcov-report/src/hooks/{useMapState.js.html → useMapState.ts.html} +166 -61
  79. package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
  80. package/coverage/lcov-report/src/index.html +15 -15
  81. package/coverage/lcov-report/src/{i18n.js.html → index.ts.html} +50 -32
  82. package/coverage/lcov.info +1540 -1669
  83. package/dist/index.esm.css +195 -0
  84. package/dist/index.esm.js +17304 -4936
  85. package/dist/index.esm.js.map +1 -1
  86. package/docs-build/0.d0c23b79.iframe.bundle.js +2 -0
  87. package/docs-build/0.d0c23b79.iframe.bundle.js.map +1 -0
  88. package/docs-build/0.fd1aa3ea21956d993519.manager.bundle.js +1 -0
  89. package/docs-build/1.34075652.iframe.bundle.js +10 -0
  90. package/docs-build/1.34075652.iframe.bundle.js.map +1 -0
  91. package/docs-build/16.ca488dae.iframe.bundle.js +2 -0
  92. package/docs-build/16.ca488dae.iframe.bundle.js.map +1 -0
  93. package/docs-build/17.e40eac7f.iframe.bundle.js +17 -0
  94. package/docs-build/17.e40eac7f.iframe.bundle.js.map +1 -0
  95. package/docs-build/18.62af0912.iframe.bundle.js +14 -0
  96. package/docs-build/18.62af0912.iframe.bundle.js.map +1 -0
  97. package/docs-build/19.0a217189.iframe.bundle.js +2 -0
  98. package/docs-build/19.0a217189.iframe.bundle.js.map +1 -0
  99. package/docs-build/2.f15ae19a.iframe.bundle.js +2 -0
  100. package/docs-build/2.f15ae19a.iframe.bundle.js.map +1 -0
  101. package/docs-build/20.4c43e27c.iframe.bundle.js +4 -0
  102. package/docs-build/20.4c43e27c.iframe.bundle.js.map +1 -0
  103. package/docs-build/21.19c21085.iframe.bundle.js +22 -0
  104. package/docs-build/21.19c21085.iframe.bundle.js.map +1 -0
  105. package/docs-build/3.5dd9e88b.iframe.bundle.js +2 -0
  106. package/docs-build/3.5dd9e88b.iframe.bundle.js.map +1 -0
  107. package/docs-build/4.f741dafe1833630ec8bf.manager.bundle.js +2 -0
  108. package/docs-build/4.f741dafe1833630ec8bf.manager.bundle.js.LICENSE.txt +8 -0
  109. package/docs-build/5.d4de191e7daeefb036ca.manager.bundle.js +1 -0
  110. package/docs-build/6.2b178c5444648ee5c0fa.manager.bundle.js +2 -0
  111. package/docs-build/6.2b178c5444648ee5c0fa.manager.bundle.js.LICENSE.txt +12 -0
  112. package/docs-build/7.7c16aea8ec7ea6e91994.manager.bundle.js +1 -0
  113. package/docs-build/8.52fa838fdf937b29676a.manager.bundle.js +1 -0
  114. package/docs-build/assets/dop.png +0 -0
  115. package/docs-build/assets/historic.png +0 -0
  116. package/docs-build/assets/marker.png +0 -0
  117. package/docs-build/assets/osm.png +0 -0
  118. package/docs-build/assets/sample.gpx +716 -0
  119. package/docs-build/{.gitkeep → catalogue/.gitkeep} +0 -0
  120. package/docs-build/catalogue/mc_meta.json +1 -0
  121. package/docs-build/favicon.ico +0 -0
  122. package/docs-build/iframe.html +348 -0
  123. package/docs-build/index.html +59 -0
  124. package/docs-build/logo.png +0 -0
  125. package/docs-build/main.8a7ec710ea1c16b5e13f.manager.bundle.js +1 -0
  126. package/docs-build/main~24120820.ba6665a8.iframe.bundle.js +2 -0
  127. package/docs-build/main~24120820.ba6665a8.iframe.bundle.js.map +1 -0
  128. package/docs-build/manifest.json +25 -0
  129. package/docs-build/robots.txt +3 -0
  130. package/docs-build/runtime~main.67aa1de2d72f40a81164.manager.bundle.js +1 -0
  131. package/docs-build/static/media/mapcomponents_logo.98b01a05.png +0 -0
  132. package/docs-build/static/media/wg-marker.bf3eeb2d.png +0 -0
  133. package/docs-build/stories.json +331 -0
  134. package/docs-build/thumbnails/MapLibreMap.png +0 -0
  135. package/docs-build/thumbnails/MlCameraFollowPath.png +0 -0
  136. package/docs-build/thumbnails/MlCreatePdfButton.png +0 -0
  137. package/docs-build/thumbnails/MlDeckGlLayer.png +0 -0
  138. package/docs-build/thumbnails/MlDeckGlTerrainLayer.png +0 -0
  139. package/docs-build/thumbnails/MlDemoDashboard.png +0 -0
  140. package/docs-build/thumbnails/MlFeatureEditor.png +0 -0
  141. package/docs-build/thumbnails/MlFillExtrusionLayer.png +0 -0
  142. package/docs-build/thumbnails/MlFollowGps.png +0 -0
  143. package/docs-build/thumbnails/MlGPXViewer.png +0 -0
  144. package/docs-build/thumbnails/MlGeoJsonLayer.png +0 -0
  145. package/docs-build/thumbnails/MlHillshadeLayer.png +0 -0
  146. package/docs-build/thumbnails/MlIconLayer.png +0 -0
  147. package/docs-build/thumbnails/MlLaermkarte.png +0 -0
  148. package/docs-build/thumbnails/MlLayerMagnify.png +0 -0
  149. package/docs-build/thumbnails/MlLayerSwipe.png +0 -0
  150. package/docs-build/thumbnails/MlMapDrawTools.png +0 -0
  151. package/docs-build/thumbnails/MlMobilerImker.png +0 -0
  152. package/docs-build/thumbnails/MlNavigationCompass.png +0 -0
  153. package/docs-build/thumbnails/MlNavigationTools.png +0 -0
  154. package/docs-build/thumbnails/MlOsmLayer.png +0 -0
  155. package/docs-build/thumbnails/MlScaleReference.png +0 -0
  156. package/docs-build/thumbnails/MlSpatialElevationProfile.png +0 -0
  157. package/docs-build/thumbnails/MlThreeJsLayer.png +0 -0
  158. package/docs-build/thumbnails/MlTransitionGeoJsonLayer.png +0 -0
  159. package/docs-build/thumbnails/MlVectorTileLayer.png +0 -0
  160. package/docs-build/thumbnails/MlWanderApp.png +0 -0
  161. package/docs-build/thumbnails/MlWmsLayer.png +0 -0
  162. package/docs-build/thumbnails/MlWmsLoader.png +0 -0
  163. package/docs-build/vendors~main.351900838c49e9200954.manager.bundle.js +2 -0
  164. package/docs-build/vendors~main.351900838c49e9200954.manager.bundle.js.LICENSE.txt +101 -0
  165. package/docs-build/vendors~main~0ad7406a.a6abfed7.iframe.bundle.js +8 -0
  166. package/docs-build/vendors~main~0ad7406a.a6abfed7.iframe.bundle.js.map +1 -0
  167. package/docs-build/vendors~main~0f485567.1d7a15b7.iframe.bundle.js +2 -0
  168. package/docs-build/vendors~main~0f485567.1d7a15b7.iframe.bundle.js.map +1 -0
  169. package/docs-build/vendors~main~41a6ab2c.525ecc56.iframe.bundle.js +2 -0
  170. package/docs-build/vendors~main~41a6ab2c.525ecc56.iframe.bundle.js.map +1 -0
  171. package/docs-build/vendors~main~52589227.1d1558cd.iframe.bundle.js +8 -0
  172. package/docs-build/vendors~main~52589227.1d1558cd.iframe.bundle.js.map +1 -0
  173. package/docs-build/vendors~main~73914085.227c6747.iframe.bundle.js +293 -0
  174. package/docs-build/vendors~main~73914085.227c6747.iframe.bundle.js.map +1 -0
  175. package/docs-build/vendors~main~9c5b28f6.f02cc741.iframe.bundle.js +7 -0
  176. package/docs-build/vendors~main~9c5b28f6.f02cc741.iframe.bundle.js.map +1 -0
  177. package/docs-build/vendors~main~b5906859.4083ac60.iframe.bundle.js +21 -0
  178. package/docs-build/vendors~main~b5906859.4083ac60.iframe.bundle.js.map +1 -0
  179. package/docs-build/vendors~main~b8f44717.7a612c34.iframe.bundle.js +89 -0
  180. package/docs-build/vendors~main~b8f44717.7a612c34.iframe.bundle.js.map +1 -0
  181. package/docs-build/vendors~main~b9cf3951.45da142d.iframe.bundle.js +68 -0
  182. package/docs-build/vendors~main~b9cf3951.45da142d.iframe.bundle.js.map +1 -0
  183. package/docs-build/vendors~main~d939e436.92c27fbf.iframe.bundle.js +2 -0
  184. package/docs-build/vendors~main~d939e436.92c27fbf.iframe.bundle.js.map +1 -0
  185. package/docs-build/vendors~main~dab50aa4.b0d58038.iframe.bundle.js +107 -0
  186. package/docs-build/vendors~main~dab50aa4.b0d58038.iframe.bundle.js.map +1 -0
  187. package/package.json +133 -117
  188. package/public/favicon.ico +0 -0
  189. package/public/logo.png +0 -0
  190. package/rollup.config.js +26 -3
  191. package/scripts/start.js +166 -0
  192. package/scripts/test.js +53 -0
  193. package/src/components/MapLibreMap/MapLibreMap.stories.js +14 -5
  194. package/src/components/MapLibreMap/MapLibreMap.test.js +1 -1
  195. package/src/components/MapLibreMap/{MapLibreMap.js → MapLibreMap.tsx} +40 -37
  196. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.test.js +3 -3
  197. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +636 -0
  198. package/src/components/MlComponentTemplate/MlComponentTemplate.stories.js +0 -2
  199. package/src/components/MlComponentTemplate/MlComponentTemplate.tsx +42 -0
  200. package/src/components/MlCreatePdfButton/MlCreatePdfButton.stories.js +0 -5
  201. package/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx +51 -0
  202. package/src/components/MlCreatePdfButton/lib/{createPdf.js → createPdf.ts} +26 -23
  203. package/src/components/MlCreatePdfButton/lib/{nominatimMap.js → nominatimMap.ts} +3 -3
  204. package/src/components/MlFeatureEditor/MlFeatureEditor.doc.en.md +1 -0
  205. package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +139 -0
  206. package/src/components/MlFeatureEditor/custom-direct-select-mode.js +12 -8
  207. package/src/components/MlFeatureEditor/custom-polygon-mode.js +9 -5
  208. package/src/components/MlFeatureEditor/custom-select-mode.js +11 -7
  209. package/src/components/MlFeatureEditor/lib/LICENSE.md +18 -0
  210. package/src/components/MlFeatureEditor/lib/common_selectors.js +4 -0
  211. package/src/components/MlFeatureEditor/lib/constants.js +4 -0
  212. package/src/components/MlFeatureEditor/lib/constrain_feature_movement.js +4 -0
  213. package/src/components/MlFeatureEditor/lib/create_midpoint.js +4 -0
  214. package/src/components/MlFeatureEditor/lib/create_supplementary_points.js +4 -0
  215. package/src/components/MlFeatureEditor/lib/create_vertex.js +4 -0
  216. package/src/components/MlFeatureEditor/lib/double_click_zoom.js +4 -0
  217. package/src/components/MlFeatureEditor/lib/euclidean_distance.js +4 -0
  218. package/src/components/MlFeatureEditor/lib/features_at.js +4 -0
  219. package/src/components/MlFeatureEditor/lib/get_features_and_set_cursor.js +4 -0
  220. package/src/components/MlFeatureEditor/lib/is_click.js +4 -0
  221. package/src/components/MlFeatureEditor/lib/is_event_at_coordinates.js +4 -0
  222. package/src/components/MlFeatureEditor/lib/is_tap.js +4 -0
  223. package/src/components/MlFeatureEditor/lib/map_event_to_bounding_box.js +4 -0
  224. package/src/components/MlFeatureEditor/lib/mode_handler.js +4 -0
  225. package/src/components/MlFeatureEditor/lib/mouse_event_point.js +4 -0
  226. package/src/components/MlFeatureEditor/lib/move_features.js +4 -0
  227. package/src/components/MlFeatureEditor/lib/sort_features.js +4 -0
  228. package/src/components/MlFeatureEditor/lib/string_set.js +4 -0
  229. package/src/components/MlFeatureEditor/lib/string_sets_are_equal.js +4 -0
  230. package/src/components/MlFeatureEditor/lib/theme.js +4 -0
  231. package/src/components/MlFeatureEditor/lib/to_dense_array.js +4 -0
  232. package/src/components/MlFeatureEditor/lib/utils.js +4 -0
  233. package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.doc.en.md +1 -0
  234. package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.stories.js +6 -11
  235. package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx +85 -0
  236. package/src/components/MlFollowGps/MlFollowGps.doc.en.md +1 -0
  237. package/src/components/MlFollowGps/MlFollowGps.stories.js +0 -2
  238. package/src/components/MlFollowGps/{MlFollowGps.js → MlFollowGps.tsx} +99 -86
  239. package/src/components/MlGPXViewer/MlGPXViewer.doc.en.md +1 -0
  240. package/src/components/MlGPXViewer/{MlGPXViewer.js → MlGPXViewer.tsx} +68 -50
  241. package/src/components/MlGPXViewer/util/GeoJsonContext.ts +13 -0
  242. package/src/components/MlGPXViewer/util/{GeoJsonProvider.js → GeoJsonProvider.tsx} +3 -7
  243. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.doc.en.md +1 -0
  244. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +8 -3
  245. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +106 -0
  246. package/src/components/MlGeoJsonLayer/util/{getDefaultLayerTypeByGeometry.js → getDefaultLayerTypeByGeometry.ts} +6 -1
  247. package/src/components/MlGeoJsonLayer/util/{getDefaultPaintPropsByType.js → getDefaultPaintPropsByType.ts} +1 -1
  248. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.js +1 -4
  249. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx +129 -0
  250. package/src/components/MlLayer/MlLayer.stories.js +0 -2
  251. package/src/components/MlLayer/MlLayer.tsx +48 -0
  252. package/src/components/MlLayerMagnify/MlLayerMagnify.doc.en.md +1 -0
  253. package/src/components/MlLayerMagnify/MlLayerMagnify.stories.js +3 -3
  254. package/src/components/MlLayerMagnify/{MlLayerMagnify.js → MlLayerMagnify.tsx} +62 -43
  255. package/src/components/MlLayerSwipe/MlLayerSwipe.doc.en.md +1 -0
  256. package/src/components/MlLayerSwipe/MlLayerSwipe.stories.js +0 -2
  257. package/src/components/MlLayerSwipe/{MlLayerSwipe.js → MlLayerSwipe.tsx} +38 -24
  258. package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +0 -4
  259. package/src/components/MlMarker/MlMarker.tsx +140 -0
  260. package/src/components/MlNavigationCompass/MlNavigationCompass.doc.en.md +1 -0
  261. package/src/components/MlNavigationCompass/{MlNavigationCompass.js → MlNavigationCompass.tsx} +27 -10
  262. package/src/components/MlNavigationTools/MlNavigationTools.doc.en.md +1 -0
  263. package/src/components/MlNavigationTools/{MlNavigationTools.js → MlNavigationTools.tsx} +37 -32
  264. package/src/components/MlScaleReference/MlScaleReference.doc.en.md +1 -0
  265. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.doc.en.md +1 -0
  266. package/src/components/MlThreeJsLayer/MlThreeJsLayer.doc.en.md +1 -0
  267. package/src/components/MlTransitionGeoJsonLayer/{MlTransitionGeoJsonLayer.js → MlTransitionGeoJsonLayer.tsx} +76 -73
  268. package/src/components/MlVectorTileLayer/MlVectorTileLayer.doc.en.md +1 -0
  269. package/src/components/MlVectorTileLayer/{MlVectorTileLayer.js → MlVectorTileLayer.tsx} +23 -7
  270. package/src/components/MlWmsLayer/{MlWmsLayer.js → MlWmsLayer.tsx} +22 -7
  271. package/src/components/MlWmsLoader/MlWmsLoader.doc.en.md +1 -0
  272. package/src/components/MlWmsLoader/{MlWmsLoader.js → MlWmsLoader.tsx} +55 -47
  273. package/src/custom.d.tsx +26 -0
  274. package/src/hooks/useLayer.ts +221 -0
  275. package/src/hooks/{useMap.js → useMap.ts} +48 -17
  276. package/src/hooks/{useMapState.js → useMapState.ts} +42 -7
  277. package/src/{index.js → index.ts} +15 -8
  278. package/tsconfig.json +18 -24
  279. package/.env +0 -1
  280. package/.storybook/main.bck.js +0 -56
  281. package/babel.config.json +0 -4
  282. package/coverage/lcov-report/src/translations/english.js.html +0 -94
  283. package/coverage/lcov-report/src/translations/german.js.html +0 -94
  284. package/coverage/lcov-report/src/translations/index.html +0 -131
  285. package/jest.config.json +0 -16
  286. package/jsdoc.json +0 -21
  287. package/public/assets/3D/posttower.gltf +0 -103
  288. package/public/assets/3D/posttower_simple.gltf +0 -103
  289. package/public/assets/3D/posttower_wh.gltf.glb +0 -0
  290. package/public/bee.png +0 -0
  291. package/public/logo192.png +0 -0
  292. package/public/logo512.png +0 -0
  293. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +0 -528
  294. package/src/components/MlComponentTemplate/MlComponentTemplate.js +0 -39
  295. package/src/components/MlCreatePdfButton/MlCreatePdfButton.js +0 -52
  296. package/src/components/MlFeatureEditor/MlFeatureEditor.js +0 -119
  297. package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.js +0 -153
  298. package/src/components/MlGPXViewer/util/GeoJsonContext.js +0 -6
  299. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +0 -173
  300. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +0 -75
  301. package/src/components/MlLayer/MlLayer.js +0 -107
  302. package/src/components/MlLayerMagnify/utils/compareMagnify.js +0 -173
  303. package/src/components/MlLayerSwipe/utils/swipeCompare.js +0 -220
  304. package/src/components/MlMarker/MlMarker.js +0 -156
  305. package/src/components/index.js +0 -6
  306. package/src/i18n.js +0 -28
  307. package/src/react-app-env.d.ts +0 -1
  308. package/src/stories/IntroductionCore.stories.mdx +0 -3
  309. package/src/stories/assets/code-brackets.svg +0 -1
  310. package/src/stories/assets/colors.svg +0 -1
  311. package/src/stories/assets/comments.svg +0 -1
  312. package/src/stories/assets/direction.svg +0 -1
  313. package/src/stories/assets/flow.svg +0 -1
  314. package/src/stories/assets/plugin.svg +0 -1
  315. package/src/stories/assets/repo.svg +0 -1
  316. package/src/stories/assets/stackalt.svg +0 -1
  317. package/src/stories/components/ComponentTeaser.js +0 -64
  318. package/src/translations/english.js +0 -4
  319. package/src/translations/german.js +0 -4
@@ -0,0 +1,85 @@
1
+ import React from "react";
2
+
3
+ import { v4 as uuidv4 } from "uuid";
4
+ import useLayer from "../../hooks/useLayer";
5
+
6
+ interface MlFillExtrusionLayerProps {
7
+ /**
8
+ * Id of the target MapLibre instance in mapContext
9
+ */
10
+ mapId?: string;
11
+ /**
12
+ * The layerId of an existing layer this layer should be rendered visually beneath
13
+ * https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
14
+ */
15
+ insertBeforeLayer?: string;
16
+ /**
17
+ * Id of the layer that will be added by this component
18
+ */
19
+ layerId?: string;
20
+ /**
21
+ * Paint properties of the config object that is passed to the MapLibreGl.addLayer call. All
22
+ * available properties are documented in the MapLibreGl documentation
23
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill-extrusion
24
+ */
25
+ paint?: object;
26
+ /**
27
+ * Source id of a vector tile source containing the geometries to use for this fill-extrusion
28
+ * layer.
29
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#source-layer
30
+ */
31
+ sourceId?: string;
32
+ /**
33
+ * Layer id from a vector tile source containing the geometries to use for this fill-extrusion
34
+ * layer.
35
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#source-layer
36
+ */
37
+ sourceLayer?: string;
38
+ /**
39
+ * This layer will be hidden for zoom levels lower than defined on this property
40
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#minzoom
41
+ */
42
+ minZoom?: number;
43
+ }
44
+
45
+ /**
46
+ * Adds a fill extrusion layer to the MapLibre instance reference by props.mapId
47
+ *
48
+ */
49
+ const MlFillExtrusionLayer = (props: MlFillExtrusionLayerProps) => {
50
+ useLayer({
51
+ mapId: props.mapId,
52
+ layerId: props.layerId || "MlFillExtrusionLayer-" + uuidv4(),
53
+ options: {
54
+ id: "",
55
+ type: "fill-extrusion",
56
+ source: props.sourceId || "openmaptiles",
57
+ "source-layer": props.sourceLayer || "building",
58
+ minzoom: props.minZoom || 14,
59
+ paint: {
60
+ ...props.paint,
61
+ },
62
+ },
63
+ insertBeforeFirstSymbolLayer: true,
64
+ });
65
+
66
+ return <></>;
67
+ };
68
+
69
+ MlFillExtrusionLayer.defaultProps = {
70
+ mapId: undefined,
71
+ paint: {
72
+ "fill-extrusion-color": "hsl(196, 61%, 83%)",
73
+ "fill-extrusion-height": {
74
+ property: "render_height",
75
+ type: "identity",
76
+ },
77
+ "fill-extrusion-base": {
78
+ property: "render_min_height",
79
+ type: "identity",
80
+ },
81
+ "fill-extrusion-opacity": 1,
82
+ },
83
+ };
84
+
85
+ export default MlFillExtrusionLayer;
@@ -0,0 +1 @@
1
+ Display of the current position and the line of sight.
@@ -8,8 +8,6 @@ const storyoptions = {
8
8
  title: "MapComponents/MlFollowGps",
9
9
  component: MlFollowGps,
10
10
  argTypes: {
11
- url: {},
12
- layer: {},
13
11
  },
14
12
  decorators: mapContextDecorator,
15
13
  };
@@ -1,35 +1,85 @@
1
1
  import React, { useEffect, useState, useCallback, useMemo } from "react";
2
- import PropTypes from "prop-types";
3
2
  import useMap from "../../hooks/useMap";
4
-
5
- import Button from "@mui/material/Button";
6
- import GpsFixedIcon from "@mui/icons-material/GpsFixed";
7
- import { point, circle, lineArc } from "@turf/turf";
8
3
  import MlGeoJsonLayer from "../MlGeoJsonLayer/MlGeoJsonLayer";
9
4
 
5
+ import { Button } from "@mui/material";
6
+ import GpsFixedIcon from "@mui/icons-material/GpsFixed";
7
+
8
+ import { point, circle, lineArc, Feature, Point } from "@turf/turf";
9
+
10
+ interface MlFollowGpsProps {
11
+ /**
12
+ * Id of the target MapLibre instance in mapContext
13
+ */
14
+ mapId?: string;
15
+ /**
16
+ * The layerId of an existing layer this layer should be rendered visually beneath
17
+ * https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
18
+ */
19
+ insertBeforeLayer?: string;
20
+ /**
21
+ * By default a dot will be shown on the map at the user's location. Set to false to disable.
22
+ */
23
+ showUserLocation?: boolean;
24
+ /**
25
+ * By default a cone will be shown on the map at the user's location to indicate the device's orientation.
26
+ * Set to false to disable.
27
+ */
28
+ showOrientation?: boolean;
29
+ /**
30
+ * By default, if showUserLocation is true, a transparent circle will be drawn around the user location
31
+ * indicating the accuracy (95% confidence level) of the user's location. Set to false to disable.
32
+ */
33
+ showAccuracyCircle?: boolean,
34
+ /**
35
+ * position circle paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy circle.
36
+ * Use any available paint prop from layer type "fill".
37
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
38
+ */
39
+ circlePaint?: any;
40
+ /**
41
+ * Active button font color
42
+ */
43
+ onColor?: string;
44
+ /**
45
+ * Inactive button font color
46
+ */
47
+ offColor?: string;
48
+ /**
49
+ * Accuracy paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy circle.
50
+ * Use any available paint prop from layer type "fill".
51
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
52
+ */
53
+ accuracyPaint?: any;
54
+ /**
55
+ * CSS style object that is applied to the button component
56
+ */
57
+ style?: any;
58
+ }
59
+
10
60
  /**
11
61
  * Adds a button that makes the map follow the users GPS position using
12
62
  * navigator.geolocation.watchPosition if activated
13
63
  *
14
- * @param {object} props
15
- * @param {string} props.mapId Id of the target MapLibre instance in mapContext
16
- *
17
- * @component
18
64
  */
19
- const MlFollowGps = (props) => {
20
- const mapHook = useMap({ mapId: props.mapId, waitForLayer: props.insertBeforeLayer });
65
+ const MlFollowGps = (props: MlFollowGpsProps) => {
66
+ const mapHook = useMap({
67
+ mapId: props.mapId,
68
+ waitForLayer: props.insertBeforeLayer,
69
+ });
21
70
 
22
71
  const [isFollowed, setIsFollowed] = useState(false);
23
- const [userLocationGeoJson, setUserLocationGeoJson] = useState(undefined);
72
+ const [userLocationGeoJson, setUserLocationGeoJson] =
73
+ useState<Feature<Point>>();
24
74
  const [locationAccessDenied, setLocationAccessDenied] = useState(false);
25
- const [accuracyGeoJson, setAccuracyGeoJson] = useState();
75
+ const [accuracyGeoJson, setAccuracyGeoJson] = useState<Feature>();
26
76
  const [deviceOrientation, setDeviceOrientation] = useState(0);
27
77
 
28
78
  const getLocationSuccess = useCallback(
29
79
  (pos) => {
30
80
  if (!mapHook.map) return;
31
81
 
32
- mapHook.map.flyTo({
82
+ mapHook.map.map.flyTo({
33
83
  center: [pos.coords.longitude, pos.coords.latitude],
34
84
  zoom: 18,
35
85
  speed: 1,
@@ -43,52 +93,55 @@ const MlFollowGps = (props) => {
43
93
  [mapHook.map, props]
44
94
  );
45
95
 
46
- const getLocationError = (err) => {
96
+ const getLocationError = () => {
47
97
  console.log("Access of user location denied");
48
98
  setLocationAccessDenied(true);
49
99
  };
50
100
 
51
- const orientationCone = useMemo(
52
- () => {
53
- if (!userLocationGeoJson) {
54
- return undefined;
55
- }
56
- let radius = 0.02;
57
- let bearing1 = deviceOrientation - 15;
58
- let bearing2 = deviceOrientation + 15;
59
- const options = {steps: 65};
60
- let arc = lineArc(userLocationGeoJson, radius, bearing1, bearing2, options);
61
- let copy = arc;
62
- copy.geometry.coordinates.push(userLocationGeoJson.geometry.coordinates);
63
- copy.geometry.coordinates.slice(0, 0, userLocationGeoJson.geometry.coordinates);
64
- return copy;
65
- }, [deviceOrientation, userLocationGeoJson]
66
- )
67
-
68
- const handleOrientation = (event) => {
69
- setDeviceOrientation(-event.alpha)
70
- }
101
+ const orientationCone = useMemo(() => {
102
+ if (!userLocationGeoJson) {
103
+ return undefined;
104
+ }
105
+ let radius = 0.02;
106
+ let bearing1 = deviceOrientation - 15;
107
+ let bearing2 = deviceOrientation + 15;
108
+ const options = { steps: 65 };
109
+ let arc = lineArc(userLocationGeoJson, radius, bearing1, bearing2, options);
110
+ let copy = arc;
111
+ copy.geometry.coordinates.push(userLocationGeoJson.geometry.coordinates);
112
+ copy.geometry.coordinates.slice(0, 0);
113
+ return copy;
114
+ }, [deviceOrientation, userLocationGeoJson]);
115
+
116
+ const handleOrientation = (event: any) => {
117
+ setDeviceOrientation(-event.alpha);
118
+ };
71
119
 
72
120
  useEffect(() => {
73
121
  if (isFollowed) {
74
122
  let _handleOrientation = handleOrientation;
75
- window.addEventListener('deviceorientation', _handleOrientation)
123
+ window.addEventListener("deviceorientation", _handleOrientation);
76
124
  return () => {
77
- window.removeEventListener('deviceorientation', _handleOrientation)
78
- }
125
+ window.removeEventListener("deviceorientation", _handleOrientation);
126
+ };
79
127
  }
128
+ return;
80
129
  }, [isFollowed]);
81
130
 
82
131
  useEffect(() => {
83
132
  if (!mapHook.map) return;
84
133
 
85
134
  if (isFollowed) {
86
- let _watchId = navigator.geolocation.watchPosition(getLocationSuccess, getLocationError);
135
+ let _watchId = navigator.geolocation.watchPosition(
136
+ getLocationSuccess,
137
+ getLocationError
138
+ );
87
139
 
88
140
  return () => {
89
141
  navigator.geolocation.clearWatch(_watchId);
90
142
  };
91
143
  }
144
+ return;
92
145
  }, [mapHook.map, isFollowed, getLocationSuccess]);
93
146
 
94
147
  return (
@@ -135,14 +188,18 @@ const MlFollowGps = (props) => {
135
188
  )}
136
189
 
137
190
  <Button
138
- sx={{ zIndex: 1002, color: isFollowed ? props.onColor : props.offColor, ...props.style }}
191
+ sx={{
192
+ zIndex: 1002,
193
+ color: isFollowed ? props.onColor : props.offColor,
194
+ ...props.style,
195
+ }}
139
196
  disabled={locationAccessDenied}
140
197
  onClick={() => {
141
198
  setIsFollowed(!isFollowed);
142
199
  }}
143
200
  >
144
201
  {" "}
145
- <GpsFixedIcon sx={{ fontSize: props.style.fontSize }} />{" "}
202
+ <GpsFixedIcon sx={{ ...(props.style?.fontSize?{fontSize: props.style?.fontSize}:{}) }} />{" "}
146
203
  </Button>
147
204
  </>
148
205
  );
@@ -168,51 +225,7 @@ MlFollowGps.defaultProps = {
168
225
  offColor: "#666",
169
226
  showAccuracyCircle: true,
170
227
  showUserLocation: true,
171
- showOrientation: true
228
+ showOrientation: true,
172
229
  };
173
230
 
174
- MlFollowGps.propTypes = {
175
- /**
176
- * Id of the target MapLibre instance in mapContext
177
- */
178
- mapId: PropTypes.string,
179
- /**
180
- * CSS style object that is applied to the button component
181
- */
182
- style: PropTypes.object,
183
- /**
184
- * Active button font color
185
- */
186
- onColor: PropTypes.string,
187
- /**
188
- * Inactive button font color
189
- */
190
- offColor: PropTypes.string,
191
- /**
192
- * Accuracy paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy circle.
193
- * Use any available paint prop from layer type "fill".
194
- * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
195
- */
196
- accuracyPaint: PropTypes.object,
197
- /**
198
- * position circle paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy circle.
199
- * Use any available paint prop from layer type "fill".
200
- * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
201
- */
202
- circlePaint: PropTypes.object,
203
- /**
204
- * By default, if showUserLocation is true, a transparent circle will be drawn around the user location
205
- * indicating the accuracy (95% confidence level) of the user's location. Set to false to disable.
206
- */
207
- showAccuracyCircle: PropTypes.bool,
208
- /**
209
- * By default a dot will be shown on the map at the user's location. Set to false to disable.
210
- */
211
- showUserLocation: PropTypes.bool,
212
- /**
213
- * By default a cone will be shown on the map at the user's location to indicate the device's orientation.
214
- * Set to false to disable.
215
- */
216
- showOrientation: PropTypes.bool,
217
- };
218
231
  export default MlFollowGps;
@@ -0,0 +1 @@
1
+ Upload and presentation of GPX tracks.
@@ -1,13 +1,12 @@
1
1
  import React, { useContext, useRef, useEffect, useState } from "react";
2
- import PropTypes from "prop-types";
3
- import { bbox } from "@turf/turf";
2
+ import { bbox } from '@turf/turf';
4
3
  import Divider from "@mui/material/Divider";
5
4
  import Typography from "@mui/material/Typography";
6
5
  import Drawer from "@mui/material/Drawer";
7
6
  import IconButton from "@mui/material/IconButton";
8
7
  import InfoIcon from "@mui/icons-material/Info";
9
8
  import FileCopy from "@mui/icons-material/FileCopy";
10
- import { Popup } from "maplibre-gl";
9
+ import { Popup, LngLatBoundsLike, GeoJSONSource } from "maplibre-gl";
11
10
  import List from "@mui/material/List";
12
11
  import ListItem from "@mui/material/ListItem";
13
12
  import ListItemText from "@mui/material/ListItemText";
@@ -16,12 +15,31 @@ import toGeoJSON from "./gpxConverter";
16
15
  import useMediaQuery from "@mui/material/useMediaQuery";
17
16
  import useMap from "../../hooks/useMap";
18
17
 
18
+ interface MlGPXViewerProps {
19
+
20
+ /**
21
+ * Id of the target MapLibre instance in mapHook
22
+ */
23
+ mapId?: string,
24
+ /**
25
+ * The layerId of an existing layer this layer should be rendered visually beneath
26
+ * https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
27
+ */
28
+ insertBeforeLayer?: string,
29
+ /**
30
+ * Prefix of the component id this component uses when adding elements to the MapLibreGl-instance
31
+ */
32
+ idPrefix?: string,
33
+ /**
34
+ * Sets the layers layout-property "visibility" to "none" if false or "visible" if true
35
+ */
36
+ visible?: boolean,
37
+ }
38
+
19
39
  /**
20
40
  * MlGPXViewer returns a dropzone and a button to load a GPX Track into the map.
21
- *
22
- * @component
23
41
  */
24
- const MlGPXViewer = (props) => {
42
+ const MlGPXViewer = (props:MlGPXViewerProps) => {
25
43
  const dataSource = useContext(GeoJsonContext);
26
44
  const initializedRef = useRef(false);
27
45
  const mapHook = useMap({ mapId: props.mapId, waitForLayer: props.insertBeforeLayer });
@@ -30,10 +48,10 @@ const MlGPXViewer = (props) => {
30
48
  const layerNamePoints = "importer-layer-points";
31
49
 
32
50
  const [open, setIsOpen] = useState(false);
33
- const dropZone = useRef(null);
51
+ const dropZone = useRef<HTMLDivElement>(null);
34
52
  const [zIndex, setZIndex] = useState(0);
35
- const [metaData, setMetaData] = useState([]);
36
- const fileupload = useRef(null);
53
+ const [metaData, setMetaData] = useState<{ title: string; value: string; id: number; }[]>([]);
54
+ const fileupload = useRef<HTMLInputElement>(null);
37
55
  const mediaIsMobile = useMediaQuery("(max-width:900px)");
38
56
 
39
57
  const popup = useRef(
@@ -85,12 +103,15 @@ const MlGPXViewer = (props) => {
85
103
  );
86
104
 
87
105
  [layerNameLines, layerNamePoints].forEach((layerName) => {
88
- mapHook.map.setLayoutProperty(layerName, "visibility", "visible");
106
+ if(!mapHook.map)return;
107
+
108
+ mapHook.map.map.setLayoutProperty(layerName, "visibility", "visible");
89
109
  });
90
110
  mapHook.map.on(
91
111
  "mouseenter",
92
112
  layerNamePoints,
93
- (e) => {
113
+ (e:any) => {
114
+ if(!mapHook.map)return;
94
115
  // Change the cursor style as a UI indicator.
95
116
 
96
117
  const coordinates = e.features[0].geometry.coordinates.slice();
@@ -107,7 +128,7 @@ const MlGPXViewer = (props) => {
107
128
  // Populate the popup and set its coordinates
108
129
 
109
130
  // based on the feature found.
110
- popup.current.setLngLat(coordinates).setHTML(name).addTo(mapHook.map);
131
+ popup.current.setLngLat(coordinates).setHTML(name).addTo(mapHook.map.map);
111
132
  },
112
133
  mapHook.componentId
113
134
  );
@@ -116,25 +137,27 @@ const MlGPXViewer = (props) => {
116
137
  "mouseleave",
117
138
  "places",
118
139
  function () {
119
- mapHook.map.getCanvas().style.cursor = "";
140
+ if(!mapHook.map)return;
141
+
142
+ mapHook.map.map.getCanvas().style.cursor = "";
120
143
  popup.current.remove();
121
144
  },
122
145
  mapHook.componentId
123
146
  );
124
147
 
125
- mapHook.map.setZoom(10);
148
+ mapHook.map.map.setZoom(10);
126
149
  }, [mapHook.map]);
127
150
 
128
151
  useEffect(() => {
129
- const dropZoneCurrent = dropZone.current;
130
- const raiseDropZoneAndStopDefault = (event) => {
152
+ const _dropZone = dropZone.current;
153
+ const raiseDropZoneAndStopDefault = (event:any) => {
131
154
  setZIndex(1000);
132
155
  stopDefault(event);
133
156
  };
134
157
  const lowerDropZone = () => {
135
158
  setZIndex(0);
136
159
  };
137
- const lowerDropZoneAndStopDefault = (event) => {
160
+ const lowerDropZoneAndStopDefault = (event:any) => {
138
161
  setZIndex(0);
139
162
  stopDefault(event);
140
163
  };
@@ -142,19 +165,19 @@ const MlGPXViewer = (props) => {
142
165
  window.addEventListener("dragenter", raiseDropZoneAndStopDefault);
143
166
  window.addEventListener("dragover", stopDefault);
144
167
 
145
- dropZoneCurrent.addEventListener("dragleave", lowerDropZone);
168
+ _dropZone?.addEventListener("dragleave", lowerDropZone);
146
169
 
147
170
  window.addEventListener("drop", lowerDropZoneAndStopDefault);
148
171
 
149
172
  return () => {
150
173
  window.removeEventListener("dragenter", raiseDropZoneAndStopDefault);
151
174
  window.removeEventListener("dragover", stopDefault);
152
- dropZoneCurrent.removeEventListener("dragleave", lowerDropZone);
175
+ _dropZone?.removeEventListener("dragleave", lowerDropZone);
153
176
  window.removeEventListener("drop", lowerDropZoneAndStopDefault);
154
177
  };
155
178
  });
156
179
 
157
- const stopDefault = (event) => {
180
+ const stopDefault = (event:any) => {
158
181
  event.preventDefault();
159
182
  event.stopPropagation();
160
183
  };
@@ -165,11 +188,13 @@ const MlGPXViewer = (props) => {
165
188
  const visibility = props.visible ? "visible" : "none";
166
189
 
167
190
  [layerNameLines, layerNamePoints].forEach((layerName) => {
168
- mapHook.map.setLayoutProperty(layerName, "visibility", visibility);
191
+ if(!mapHook.map)return;
192
+
193
+ mapHook.map.map.setLayoutProperty(layerName, "visibility", visibility);
169
194
  });
170
195
  }, [props.visible]);
171
196
 
172
- const dropHandler = (event) => {
197
+ const dropHandler = (event:any) => {
173
198
  event.preventDefault();
174
199
 
175
200
  if (event.dataTransfer.items) {
@@ -179,7 +204,9 @@ const MlGPXViewer = (props) => {
179
204
  // If dropped items aren't files, reject them
180
205
  if (event.dataTransfer.items[0].kind === "file") {
181
206
  const reader = new FileReader();
182
- reader.onload = (payload) => {
207
+ reader.onload = (payload:any) => {
208
+ if(!payload?.currentTarget?.result)return;
209
+
183
210
  addGPXToMap(payload.currentTarget.result);
184
211
  };
185
212
  const file = event.dataTransfer.items[0].getAsFile();
@@ -188,23 +215,25 @@ const MlGPXViewer = (props) => {
188
215
  } else {
189
216
  // Use DataTransfer interface to access the file(s)
190
217
  }
218
+ return;
191
219
  };
192
220
 
193
- const addGPXToMap = (gpxAsString) => {
194
- if (!mapHook.map) return;
221
+ const addGPXToMap = (gpxAsString:string) => {
222
+ if (!mapHook.map || !dataSource.setData) return;
223
+
195
224
  try {
196
225
  setMetaData([]);
197
226
  const domParser = new DOMParser();
198
227
  const gpxDoc = domParser.parseFromString(gpxAsString, "application/xml");
199
228
  const metadata = gpxDoc.querySelector("metadata");
200
- metadata.childNodes.forEach((node) => {
229
+ metadata?.childNodes.forEach((node:Element) => {
201
230
  let value = node.textContent;
202
231
  const title = node.nodeName;
203
232
 
204
233
  if (node.nodeName === "link") {
205
234
  value = node.getAttribute("href");
206
235
  }
207
- if (!!value.trim().length) {
236
+ if (!!value?.trim().length) {
208
237
  const metaDatEntry = {
209
238
  title: title,
210
239
  value: value,
@@ -215,9 +244,9 @@ const MlGPXViewer = (props) => {
215
244
  });
216
245
  const data = toGeoJSON.gpx(gpxDoc);
217
246
  dataSource.setData(data);
218
- mapHook.map.getSource(sourceName).setData(data);
247
+ (mapHook.map.map.getSource(sourceName) as GeoJSONSource).setData(data as GeoJSON);
219
248
  const bounds = bbox(data);
220
- mapHook.map.fitBounds(bounds);
249
+ mapHook.map.map.fitBounds(bounds as LngLatBoundsLike);
221
250
  } catch (e) {
222
251
  console.log(e);
223
252
  }
@@ -228,17 +257,25 @@ const MlGPXViewer = (props) => {
228
257
  };
229
258
 
230
259
  const fileUploadOnChange = () => {
231
- const file = fileupload.current.files[0];
260
+ if(!fileupload.current)return false;
261
+
262
+ const file = fileupload.current?.files?.[0];
232
263
  if (!file) return false;
233
264
  const reader = new FileReader();
234
- reader.onload = (payload) => {
265
+ reader.onload = (payload:any) => {
266
+ if(!payload)return;
267
+
235
268
  addGPXToMap(payload.currentTarget.result);
236
269
  };
237
270
 
238
271
  reader.readAsText(file);
272
+
273
+ return;
239
274
  };
240
275
 
241
276
  const manualUpload = () => {
277
+ if(!fileupload.current)return;
278
+
242
279
  fileupload.current.click();
243
280
  };
244
281
  return (
@@ -336,24 +373,5 @@ MlGPXViewer.defaultProps = {
336
373
  visible: true,
337
374
  };
338
375
 
339
- MlGPXViewer.propTypes = {
340
- /**
341
- * Id of the target MapLibre instance in mapHook
342
- */
343
- mapId: PropTypes.string,
344
- /**
345
- * Prefix of the component id this component uses when adding elements to the MapLibreGl-instance
346
- */
347
- idPrefix: PropTypes.string,
348
- /**
349
- * Sets the layers layout-property "visibility" to "none" if false or "visible" if true
350
- */
351
- visible: PropTypes.bool,
352
- /**
353
- * The layerId of an existing layer this layer should be rendered visually beneath
354
- * https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
355
- */
356
- insertBeforeLayer: PropTypes.string,
357
- };
358
376
 
359
377
  export default MlGPXViewer;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { FeatureCollection } from '@turf/turf';
3
+
4
+ type ContextProps = {
5
+ data: FeatureCollection,
6
+ setData: Function,
7
+ getEmptyFeatureCollection: Function
8
+ };
9
+
10
+ const GeoJsonContext = React.createContext<Partial<ContextProps>>({});
11
+
12
+ export const GeoJsonContextProvider = GeoJsonContext.Provider;
13
+ export default GeoJsonContext;
@@ -1,9 +1,9 @@
1
1
  import React, { useState } from "react";
2
- import PropTypes from "prop-types";
3
2
  import { GeoJsonContextProvider } from "./GeoJsonContext";
3
+ import { FeatureCollection } from '@turf/turf';
4
4
 
5
- const GeoJsonProvider = ({ children }) => {
6
- const [data, setData] = useState({
5
+ const GeoJsonProvider = ({ children }:{children:JSX.Element}) => {
6
+ const [data, setData] = useState<FeatureCollection>({
7
7
  type: "FeatureCollection",
8
8
  features: [],
9
9
  });
@@ -22,8 +22,4 @@ const GeoJsonProvider = ({ children }) => {
22
22
  return <GeoJsonContextProvider value={value}>{children}</GeoJsonContextProvider>;
23
23
  };
24
24
 
25
- GeoJsonProvider.propTypes = {
26
- children: PropTypes.node.isRequired,
27
- };
28
-
29
25
  export default GeoJsonProvider;
@@ -0,0 +1 @@
1
+ Presents GeoJSON objects.