@mapcomponents/react-maplibre 0.1.37 → 0.1.40

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 (184) hide show
  1. package/.storybook/main.js +1 -0
  2. package/CHANGELOG.md +9 -3
  3. package/coverage/clover.xml +435 -351
  4. package/coverage/coverage-final.json +29 -26
  5. package/coverage/lcov-report/index.html +74 -59
  6. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +75 -27
  7. package/coverage/lcov-report/src/components/MapLibreMap/index.html +13 -13
  8. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +9 -9
  9. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +11 -11
  10. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +3 -6
  11. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
  12. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +3 -3
  13. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  14. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +3 -3
  15. package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
  16. package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.html +3 -3
  17. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +8 -8
  18. package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
  19. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +2 -2
  20. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  21. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +2 -2
  22. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
  23. package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +2 -2
  24. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  25. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +15 -27
  26. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +18 -18
  27. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +13 -28
  28. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +19 -19
  29. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +2 -2
  30. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
  31. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  32. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  33. package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +9 -9
  34. package/coverage/lcov-report/src/components/MlMarker/index.html +11 -11
  35. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +6 -6
  36. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  37. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +7 -7
  38. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +11 -11
  39. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +3 -3
  40. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  41. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
  42. package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
  43. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +2 -2
  44. package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
  45. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +9 -36
  46. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  47. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +2 -2
  48. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
  49. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +3 -3
  50. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
  51. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  52. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  53. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +3 -3
  54. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
  55. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +2 -2
  56. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
  57. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +5 -5
  58. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
  59. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +3 -6
  60. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
  61. package/coverage/lcov-report/src/contexts/MapContext.tsx.html +358 -0
  62. package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +103 -0
  63. package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +277 -0
  64. package/coverage/lcov-report/src/contexts/index.html +146 -0
  65. package/coverage/lcov-report/src/hooks/index.html +11 -11
  66. package/coverage/lcov-report/src/hooks/useLayer.ts.html +15 -126
  67. package/coverage/lcov-report/src/hooks/useMap.ts.html +13 -61
  68. package/coverage/lcov-report/src/hooks/useMapState.ts.html +6 -6
  69. package/coverage/lcov-report/src/hooks/useWms.js.html +7 -7
  70. package/coverage/lcov-report/src/index.html +1 -1
  71. package/coverage/lcov-report/src/index.ts.html +15 -3
  72. package/coverage/lcov.info +790 -615
  73. package/dist/index.esm.js +12093 -37213
  74. package/dist/index.esm.js.map +1 -1
  75. package/docs-build/{0.fd1aa3ea21956d993519.manager.bundle.js → 0.20735a16c2ad9677fe7d.manager.bundle.js} +1 -1
  76. package/docs-build/{0.d0c23b79.iframe.bundle.js → 0.93d0ce3d.iframe.bundle.js} +2 -2
  77. package/docs-build/0.93d0ce3d.iframe.bundle.js.map +1 -0
  78. package/docs-build/{1.34075652.iframe.bundle.js → 1.2b1ae3fa.iframe.bundle.js} +2 -2
  79. package/docs-build/1.2b1ae3fa.iframe.bundle.js.map +1 -0
  80. package/docs-build/{16.ca488dae.iframe.bundle.js → 16.2c8135a1.iframe.bundle.js} +2 -2
  81. package/docs-build/16.2c8135a1.iframe.bundle.js.map +1 -0
  82. package/docs-build/{17.e40eac7f.iframe.bundle.js → 17.9a16865a.iframe.bundle.js} +2 -2
  83. package/docs-build/17.9a16865a.iframe.bundle.js.map +1 -0
  84. package/docs-build/{18.62af0912.iframe.bundle.js → 18.4c47f37e.iframe.bundle.js} +2 -2
  85. package/docs-build/18.4c47f37e.iframe.bundle.js.map +1 -0
  86. package/docs-build/{19.0a217189.iframe.bundle.js → 19.cdf25e28.iframe.bundle.js} +2 -2
  87. package/docs-build/19.cdf25e28.iframe.bundle.js.map +1 -0
  88. package/docs-build/{2.f15ae19a.iframe.bundle.js → 2.4518b817.iframe.bundle.js} +2 -2
  89. package/docs-build/2.4518b817.iframe.bundle.js.map +1 -0
  90. package/docs-build/{4.f741dafe1833630ec8bf.manager.bundle.js → 4.8ac31bba1926f4f011b0.manager.bundle.js} +2 -2
  91. package/docs-build/{4.f741dafe1833630ec8bf.manager.bundle.js.LICENSE.txt → 4.8ac31bba1926f4f011b0.manager.bundle.js.LICENSE.txt} +0 -0
  92. package/docs-build/{5.d4de191e7daeefb036ca.manager.bundle.js → 5.daf044a6c0f55d839078.manager.bundle.js} +1 -1
  93. package/docs-build/{6.2b178c5444648ee5c0fa.manager.bundle.js → 6.99fba2cf6af0473f8209.manager.bundle.js} +2 -2
  94. package/docs-build/{6.2b178c5444648ee5c0fa.manager.bundle.js.LICENSE.txt → 6.99fba2cf6af0473f8209.manager.bundle.js.LICENSE.txt} +0 -0
  95. package/docs-build/{7.7c16aea8ec7ea6e91994.manager.bundle.js → 7.b6a48b90f61cb575c2e4.manager.bundle.js} +1 -1
  96. package/docs-build/{8.52fa838fdf937b29676a.manager.bundle.js → 8.50518a5391398d9d5812.manager.bundle.js} +1 -1
  97. package/docs-build/assets/3D/godzilla_simple.glb +0 -0
  98. package/docs-build/catalogue/mc_meta.json +1 -1
  99. package/docs-build/iframe.html +1 -1
  100. package/docs-build/index.html +1 -1
  101. package/docs-build/{main.8a7ec710ea1c16b5e13f.manager.bundle.js → main.ef9704b1252e8efa56a0.manager.bundle.js} +1 -1
  102. package/docs-build/main~24120820.e0a66582.iframe.bundle.js +2 -0
  103. package/docs-build/main~24120820.e0a66582.iframe.bundle.js.map +1 -0
  104. package/docs-build/{runtime~main.67aa1de2d72f40a81164.manager.bundle.js → runtime~main.6e6ed7dc9ea4785ef286.manager.bundle.js} +1 -1
  105. package/docs-build/stories.json +416 -168
  106. package/docs-build/vendors~main.4b570b3072ba06ee44b5.manager.bundle.js +2 -0
  107. package/docs-build/{vendors~main.351900838c49e9200954.manager.bundle.js.LICENSE.txt → vendors~main.4b570b3072ba06ee44b5.manager.bundle.js.LICENSE.txt} +27 -24
  108. package/docs-build/{vendors~main~0ad7406a.a6abfed7.iframe.bundle.js → vendors~main~0ad7406a.22b96f8e.iframe.bundle.js} +2 -2
  109. package/docs-build/vendors~main~0ad7406a.22b96f8e.iframe.bundle.js.map +1 -0
  110. package/docs-build/{vendors~main~0f485567.1d7a15b7.iframe.bundle.js → vendors~main~0f485567.df27e62a.iframe.bundle.js} +2 -2
  111. package/docs-build/vendors~main~0f485567.df27e62a.iframe.bundle.js.map +1 -0
  112. package/docs-build/{vendors~main~41a6ab2c.525ecc56.iframe.bundle.js → vendors~main~41a6ab2c.7f3a1ced.iframe.bundle.js} +2 -2
  113. package/docs-build/vendors~main~41a6ab2c.7f3a1ced.iframe.bundle.js.map +1 -0
  114. package/docs-build/{vendors~main~73914085.227c6747.iframe.bundle.js → vendors~main~73914085.3d4f5bbf.iframe.bundle.js} +4 -4
  115. package/docs-build/{vendors~main~73914085.227c6747.iframe.bundle.js.map → vendors~main~73914085.3d4f5bbf.iframe.bundle.js.map} +1 -1
  116. package/docs-build/{vendors~main~9c5b28f6.f02cc741.iframe.bundle.js → vendors~main~9c5b28f6.f8614bdc.iframe.bundle.js} +3 -3
  117. package/docs-build/vendors~main~9c5b28f6.f8614bdc.iframe.bundle.js.map +1 -0
  118. package/docs-build/{vendors~main~b5906859.4083ac60.iframe.bundle.js → vendors~main~b5906859.b606e812.iframe.bundle.js} +3 -3
  119. package/docs-build/vendors~main~b5906859.b606e812.iframe.bundle.js.map +1 -0
  120. package/docs-build/vendors~main~b9cf3951.a6200a51.iframe.bundle.js +63 -0
  121. package/docs-build/vendors~main~b9cf3951.a6200a51.iframe.bundle.js.map +1 -0
  122. package/docs-build/{vendors~main~d939e436.92c27fbf.iframe.bundle.js → vendors~main~d939e436.aa5d1533.iframe.bundle.js} +2 -2
  123. package/docs-build/vendors~main~d939e436.aa5d1533.iframe.bundle.js.map +1 -0
  124. package/docs-build/{vendors~main~dab50aa4.b0d58038.iframe.bundle.js → vendors~main~dab50aa4.277284e0.iframe.bundle.js} +4 -4
  125. package/docs-build/{vendors~main~dab50aa4.b0d58038.iframe.bundle.js.map → vendors~main~dab50aa4.277284e0.iframe.bundle.js.map} +1 -1
  126. package/package.json +6 -4
  127. package/rollup.config.js +5 -6
  128. package/src/components/MapLibreMap/MapLibreMap.stories.js +1 -1
  129. package/src/components/MapLibreMap/MapLibreMap.test.js +1 -1
  130. package/src/components/MapLibreMap/MapLibreMap.tsx +32 -16
  131. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.test.js +1 -1
  132. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +2 -2
  133. package/src/components/MlBasicComponent.js +4 -1
  134. package/src/components/MlFeatureEditor/MlFeatureEditor.test.js +1 -1
  135. package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +0 -1
  136. package/src/components/MlFollowGps/MlFollowGps.test.js +1 -1
  137. package/src/components/MlLayer/MlLayer.test.js +1 -1
  138. package/src/components/MlLayerMagnify/MlLayerMagnify.test.js +1 -1
  139. package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +3 -7
  140. package/src/components/MlLayerSwipe/MlLayerSwipe.test.js +1 -1
  141. package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +2 -7
  142. package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +1 -1
  143. package/src/components/MlNavigationCompass/MlNavigationCompass.test.js +1 -1
  144. package/src/components/MlShareMapState/MlShareMapState.js +1 -1
  145. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js +4 -13
  146. package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +1 -1
  147. package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.stories.js +1 -1
  148. package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js +1 -1
  149. package/src/components/MlWmsLoader/MlWmsLoader.tsx +1 -2
  150. package/src/contexts/MapComponentsProvider.test.js +260 -0
  151. package/src/contexts/MapContext.tsx +92 -0
  152. package/src/contexts/SimpleDataContext.js +6 -0
  153. package/src/contexts/SimpleDataProvider.js +64 -0
  154. package/src/contexts/SimpleDataProvider.test.js +68 -0
  155. package/src/custom.d.tsx +1 -1
  156. package/src/decorators/MapContextDecorator.js +1 -1
  157. package/src/decorators/MultiMapContextDecorator.js +1 -1
  158. package/src/hooks/useLayer.ts +12 -49
  159. package/src/hooks/useMap.ts +9 -26
  160. package/src/hooks/useMapState.ts +3 -3
  161. package/src/index.ts +5 -1
  162. package/src/ui_components/LoadingOverlayContext.js +1 -1
  163. package/src/util/layerRemovalTest.js +1 -1
  164. package/src/util/sourceRemovalTest.js +1 -1
  165. package/tsconfig.json +4 -0
  166. package/docs-build/0.d0c23b79.iframe.bundle.js.map +0 -1
  167. package/docs-build/1.34075652.iframe.bundle.js.map +0 -1
  168. package/docs-build/16.ca488dae.iframe.bundle.js.map +0 -1
  169. package/docs-build/17.e40eac7f.iframe.bundle.js.map +0 -1
  170. package/docs-build/18.62af0912.iframe.bundle.js.map +0 -1
  171. package/docs-build/19.0a217189.iframe.bundle.js.map +0 -1
  172. package/docs-build/2.f15ae19a.iframe.bundle.js.map +0 -1
  173. package/docs-build/main~24120820.ba6665a8.iframe.bundle.js +0 -2
  174. package/docs-build/main~24120820.ba6665a8.iframe.bundle.js.map +0 -1
  175. package/docs-build/vendors~main.351900838c49e9200954.manager.bundle.js +0 -2
  176. package/docs-build/vendors~main~0ad7406a.a6abfed7.iframe.bundle.js.map +0 -1
  177. package/docs-build/vendors~main~0f485567.1d7a15b7.iframe.bundle.js.map +0 -1
  178. package/docs-build/vendors~main~41a6ab2c.525ecc56.iframe.bundle.js.map +0 -1
  179. package/docs-build/vendors~main~9c5b28f6.f02cc741.iframe.bundle.js.map +0 -1
  180. package/docs-build/vendors~main~b5906859.4083ac60.iframe.bundle.js.map +0 -1
  181. package/docs-build/vendors~main~b9cf3951.45da142d.iframe.bundle.js +0 -68
  182. package/docs-build/vendors~main~b9cf3951.45da142d.iframe.bundle.js.map +0 -1
  183. package/docs-build/vendors~main~d939e436.92c27fbf.iframe.bundle.js.map +0 -1
  184. package/public/stories.json +0 -331
@@ -1 +1 @@
1
- {"version":3,"file":"vendors~main~dab50aa4.b0d58038.iframe.bundle.js","sources":["webpack:///vendors~main~dab50aa4.b0d58038.iframe.bundle.js"],"mappings":"AAAA;;;;;;;;;;AAuvRA;;;;;;;;AASA;;;;;;;;;;;;AAaA;;;;AAuBA;;;AAGA;AACA;AACA;;;AAGA;AACA;;;AAGA;;;;;;;;;AASA;;AAEA;AACA;AACA;;;AAGA;;;;;AAKA;;AAEA;;;;AAIA;;;;;;;;AAwoBA;;;;;;;;;;;;;;;AAgCA;AAqBA;AACA;AAiCA;AACA;;;;;AAwmBA","sourceRoot":""}
1
+ {"version":3,"file":"vendors~main~dab50aa4.277284e0.iframe.bundle.js","sources":["webpack:///vendors~main~dab50aa4.277284e0.iframe.bundle.js"],"mappings":"AAAA;;;;;;;;;;AAuvRA;;;;;;;;AASA;;;;;;;;;;;;AAaA;;;;AAuBA;;;AAGA;AACA;AACA;;;AAGA;AACA;;;AAGA;;;;;;;;;AASA;;AAEA;AACA;AACA;;;AAGA;;;;;AAKA;;AAEA;;;;AAIA;;;;;;;;AAwoBA;;;;;;;;;;;;;;;AAgCA;AAqBA;AACA;AAiCA;AACA;;;;;AAwmBA","sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapcomponents/react-maplibre",
3
- "version": "0.1.37",
3
+ "version": "0.1.40",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.esm.js",
@@ -23,18 +23,20 @@
23
23
  "@emotion/styled": "^11.8.1",
24
24
  "@mapbox/mapbox-gl-draw": "^1.3.0",
25
25
  "@mapbox/mapbox-gl-sync-move": "^0.3.0",
26
- "@mapcomponents/react-core": "^0.1.7",
27
26
  "@mui/icons-material": "^5.5.1",
28
27
  "@mui/material": "5.5.3",
29
28
  "@mui/styles": "^5.5.3",
30
29
  "@turf/turf": "^6.5.0",
30
+ "d3": "^7.4.4",
31
31
  "jspdf": "^2.5.1",
32
32
  "maplibre-gl": "^2.1.7",
33
+ "react-i18next": "^11.14.3",
33
34
  "three": "^0.139.1",
34
35
  "uuid": "^8.3.2",
35
36
  "wms-capabilities": "^0.5.1",
36
37
  "xmldom": "^0.6.0"
37
38
  },
39
+ "peerDependencies": {},
38
40
  "devDependencies": {
39
41
  "@babel/preset-react": "^7.16.7",
40
42
  "@rollup/plugin-alias": "^3.1.9",
@@ -78,7 +80,6 @@
78
80
  "react-app-polyfill": "^3.0.0",
79
81
  "react-dev-utils": "^12.0.0",
80
82
  "react-dom": "^17.0.2",
81
- "react-i18next": "^11.16.2",
82
83
  "rollup": "^2.70.1",
83
84
  "rollup-plugin-delete": "^2.0.0",
84
85
  "rollup-plugin-import-css": "^3.0.3",
@@ -125,7 +126,8 @@
125
126
  "moduleNameMapper": {
126
127
  "^react-native$": "react-native-web",
127
128
  "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy",
128
- "^!maplibre-gl$": "<rootDir>/node_modules/maplibre-gl"
129
+ "^!maplibre-gl$": "<rootDir>/node_modules/maplibre-gl",
130
+ "d3": "<rootDir>/node_modules/d3/dist/d3.min.js"
129
131
  },
130
132
  "moduleFileExtensions": [
131
133
  "web.js",
package/rollup.config.js CHANGED
@@ -42,15 +42,14 @@ const config = {
42
42
  "d3",
43
43
  "@emotion/react",
44
44
  "@emotion/styled",
45
- ...Object.keys(pkg.peerDependencies || pkg.devDependencies),
45
+ "@babel/helpers",
46
+ "jspdf",
47
+ ...Object.keys(pkg.dependencies),
48
+ ...Object.keys(pkg.peerDependencies),
49
+ ...Object.keys(pkg.devDependencies),
46
50
  ],
47
51
  inlineDynamicImports: true,
48
52
  onwarn: function (warning, warn) {
49
- if (
50
- warning.code === "CIRCULAR_DEPENDENCY" ||
51
- warning.code === "THIS_IS_UNDEFINED"
52
- )
53
- return;
54
53
  warn(warning);
55
54
  },
56
55
  };
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
 
3
3
  import MapLibreMap from "./MapLibreMap";
4
- import { MapComponentsProvider } from "@mapcomponents/react-core";
4
+ import { MapComponentsProvider } from "../../contexts/MapContext";
5
5
 
6
6
  const storyoptions = {
7
7
  title: "Core/MapLibreMap",
@@ -1,7 +1,7 @@
1
1
  import React, { useContext, useEffect, useState } from "react";
2
2
  import { mount, configure } from "enzyme";
3
3
  import { waitFor } from "@testing-library/react";
4
- import { MapContext, MapComponentsProvider } from "@mapcomponents/react-core";
4
+ import MapContext, { MapComponentsProvider } from "../../contexts/MapContext";
5
5
  import MapLibreMap from "./MapLibreMap";
6
6
 
7
7
  const MapLibreMapTestComponent = (props) => {
@@ -1,10 +1,9 @@
1
- import React, { useRef, useEffect, useContext, FC } from "react";
1
+ import React, { useRef, useEffect, useContext, FC, RefObject } from "react";
2
2
 
3
- // @ts-ignore
4
- import { MapContext } from "@mapcomponents/react-core";
5
- // @ts-ignore
3
+ import MapContext from "../../contexts/MapContext";
6
4
  import MapLibreGlWrapper from "./lib/MapLibreGlWrapper";
7
5
 
6
+ import { MapOptions as MapOptionsType } from "maplibre-gl";
8
7
  import "maplibre-gl/dist/maplibre-gl.css";
9
8
 
10
9
  type MapLibreMapProps = {
@@ -17,7 +16,7 @@ type MapLibreMapProps = {
17
16
  * See https://maplibre.org/maplibre-gl-js-docs/api/map/ for a formal documentation of al
18
17
  * available properties.
19
18
  */
20
- options?: object;
19
+ options?: MapOptionsType;
21
20
  /**
22
21
  * css style definition passed to the map container DOM element
23
22
  */
@@ -29,6 +28,23 @@ const defaultProps: MapLibreMapProps = {
29
28
  options: {
30
29
  center: { lng: 8.607, lat: 53.1409349 },
31
30
  zoom: 11,
31
+ container: '',
32
+ style: {
33
+ version: 8,
34
+ name: "blank",
35
+ center: [0, 0],
36
+ zoom: 0,
37
+ sources: {},
38
+ layers: [
39
+ {
40
+ id: "background",
41
+ type: "background",
42
+ paint: {
43
+ "background-color": "rgba(80,0,0,0)",
44
+ },
45
+ },
46
+ ],
47
+ },
32
48
  },
33
49
  };
34
50
 
@@ -43,13 +59,13 @@ const defaultProps: MapLibreMapProps = {
43
59
  * @category Map components
44
60
  */
45
61
  const MapLibreMap: FC<MapLibreMapProps> = (props: MapLibreMapProps) => {
46
- const map: any = useRef(null);
47
- const mapContainer = useRef(null);
62
+ const map: any = useRef<MapLibreGlWrapper>(null);
63
+ const mapContainer = useRef<HTMLDivElement>();
48
64
 
49
- const mapContext: any = useContext(MapContext);
65
+ const mapContext: any = useContext<MapContextType>(MapContext);
50
66
 
51
67
  const mapIdRef = useRef(props.mapId);
52
- const mapOptions = props.options;
68
+ const initializedRef = useRef(false);
53
69
 
54
70
  useEffect(() => {
55
71
  let mapId = mapIdRef.current;
@@ -62,12 +78,15 @@ const MapLibreMap: FC<MapLibreMapProps> = (props: MapLibreMapProps) => {
62
78
  }, []);
63
79
 
64
80
  useEffect(() => {
81
+ if (initializedRef.current) return;
82
+
65
83
  if (mapContainer.current) {
84
+ initializedRef.current = true;
66
85
  map.current = new MapLibreGlWrapper({
67
- // @ts-ignore
68
86
  mapOptions: {
87
+ style: '',
69
88
  container: mapContainer.current,
70
- ...mapOptions,
89
+ ...props.options,
71
90
  },
72
91
  onReady: (map: any, wrapper: any) => {
73
92
  map.once("load", () => {
@@ -80,12 +99,9 @@ const MapLibreMap: FC<MapLibreMapProps> = (props: MapLibreMapProps) => {
80
99
  },
81
100
  });
82
101
  }
83
- // eslint-disable-next-line react-hooks/exhaustive-deps
84
- }, [mapContainer]);
102
+ }, [props.options, props.mapId]);
85
103
 
86
- return (
87
- <div ref={mapContainer} className="mapContainer" style={props.style} />
88
- );
104
+ return <div ref={mapContainer as RefObject<HTMLDivElement>} className="mapContainer" style={props.style} />;
89
105
  };
90
106
 
91
107
  MapLibreMap.defaultProps = defaultProps;
@@ -1,6 +1,6 @@
1
1
  import React, { useRef, useEffect, useContext, useState } from "react";
2
2
  import { mount } from "enzyme";
3
- import { MapContext, MapComponentsProvider } from "@mapcomponents/react-core";
3
+ import MapContext, { MapComponentsProvider } from "../../../contexts/MapContext";
4
4
  import { v4 as uuidv4 } from "uuid";
5
5
  import MapLibreMap from "../MapLibreMap";
6
6
 
@@ -1,4 +1,4 @@
1
- import { Map, IControl, MapOptions } from "maplibre-gl";
1
+ import { Map, IControl, MapOptions as MapOptionsType } from "!maplibre-gl";
2
2
 
3
3
  type EventArgArray = [string, string | Function, Function?];
4
4
  type LayerState = {
@@ -64,7 +64,7 @@ class MapLibreGlWrapper {
64
64
  on: Function;
65
65
  cleanup: Function;
66
66
 
67
- constructor(props: { mapOptions: MapOptions; onReady: Function }) {
67
+ constructor(props: { mapOptions: MapOptionsType; onReady: Function }) {
68
68
  // closure variable to safely point to the object context of the current MapLibreGlWrapper instance
69
69
  let self = this;
70
70
 
@@ -1,7 +1,10 @@
1
1
  import React, { useEffect, useContext } from "react";
2
2
 
3
- import { MapContext } from "@mapcomponents/react-core";
3
+ import MapContext from "../contexts/MapContext";
4
4
 
5
+ /**
6
+ * This component is deprecated and will be removed in the next major release
7
+ */
5
8
  const MlBasicComponent = (props) => {
6
9
  // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
7
10
  // without the requirement of adding it to the dependency list (ignore the false eslint exhaustive deps warning)
@@ -1,7 +1,7 @@
1
1
  import React, { useContext, useState } from "react";
2
2
  import { mount, configure } from "enzyme";
3
3
  import { waitFor } from "@testing-library/react";
4
- import { MapContext, MapComponentsProvider } from "@mapcomponents/react-core";
4
+ import MapContext, { MapComponentsProvider } from "../../contexts/MapContext";
5
5
  import MlFeatureEditor from "./MlFeatureEditor";
6
6
  import MapLibreMap from "./../MapLibreMap/MapLibreMap";
7
7
  import maplibregl from "maplibre-gl/dist/maplibre-gl";
@@ -111,7 +111,6 @@ const MlFeatureEditor = (props:MlFeatureEditorProps) => {
111
111
  draw.current &&
112
112
  props.geojson?.geometry
113
113
  ) {
114
- // @ts-ignore
115
114
  draw.current.set({ type: "FeatureCollection", features: [props.geojson] });
116
115
  }
117
116
  }, [props.geojson, drawToolsReady]);
@@ -1,7 +1,7 @@
1
1
  import React, { useContext, useState } from "react";
2
2
  import { mount, configure } from "enzyme";
3
3
  import { waitFor } from "@testing-library/react";
4
- import { MapContext, MapComponentsProvider } from "@mapcomponents/react-core";
4
+ import MapContext, { MapComponentsProvider } from "../../contexts/MapContext";
5
5
  import MlFollowGps from "./MlFollowGps";
6
6
  import MapLibreMap from "./../MapLibreMap/MapLibreMap";
7
7
 
@@ -1,7 +1,7 @@
1
1
  import React, { useContext, useState } from "react";
2
2
  import { mount, configure } from "enzyme";
3
3
  import { waitFor } from "@testing-library/react";
4
- import { MapContext, MapComponentsProvider } from "@mapcomponents/react-core";
4
+ import MapContext, { MapComponentsProvider } from "../../contexts/MapContext";
5
5
  import MapLibreMap from "./../MapLibreMap/MapLibreMap";
6
6
  import MlLayer from "./MlLayer";
7
7
 
@@ -2,7 +2,7 @@ import MlLayerMagnify from "./MlLayerMagnify";
2
2
 
3
3
  import React, { useContext, useState } from "react";
4
4
  import { mount } from "enzyme";
5
- import { MapContext, MapComponentsProvider } from "@mapcomponents/react-core";
5
+ import MapContext, { MapComponentsProvider } from "../../contexts/MapContext";
6
6
  import MapLibreMap from "./../MapLibreMap/MapLibreMap";
7
7
  import syncMove from "@mapbox/mapbox-gl-sync-move";
8
8
  // Mapbox sync-move mockup
@@ -9,8 +9,7 @@ import React, {
9
9
  // @ts-ignore
10
10
  import syncMove from "@mapbox/mapbox-gl-sync-move";
11
11
  import "./style.css";
12
- // @ts-ignore
13
- import { MapContext } from "@mapcomponents/react-core";
12
+ import MapContext from "../../contexts/MapContext";
14
13
 
15
14
  interface MlLayerMagnifyProps {
16
15
  /**
@@ -35,7 +34,7 @@ interface MlLayerMagnifyProps {
35
34
  const MlLayerMagnify = (props: MlLayerMagnifyProps) => {
36
35
  const mapContext:MapContextType = useContext(MapContext);
37
36
  const syncMoveInitializedRef = useRef(false);
38
- const syncCleanupFunctionRef = useRef(null);
37
+ const syncCleanupFunctionRef = useRef(() => {});
39
38
 
40
39
  const [swipeX, setSwipeX] = useState('50');
41
40
  const swipeXRef = useRef('50');
@@ -72,10 +71,7 @@ const MlLayerMagnify = (props: MlLayerMagnifyProps) => {
72
71
 
73
72
  return () => {
74
73
  window.removeEventListener("resize", _onResize);
75
- if (typeof syncCleanupFunctionRef.current === 'function') {
76
- // @ts-ignore
77
- syncCleanupFunctionRef.current();
78
- }
74
+ syncCleanupFunctionRef.current();
79
75
  };
80
76
  }, []);
81
77
 
@@ -2,7 +2,7 @@ import MlLayerSwipe from "./MlLayerSwipe";
2
2
 
3
3
  import React, { useContext, useState } from "react";
4
4
  import { mount } from "enzyme";
5
- import { MapContext, MapComponentsProvider } from "@mapcomponents/react-core";
5
+ import MapContext, { MapComponentsProvider } from "../../contexts/MapContext";
6
6
  import MapLibreMap from "./../MapLibreMap/MapLibreMap";
7
7
  import syncMove from "@mapbox/mapbox-gl-sync-move";
8
8
  // Mapbox sync-move mockup
@@ -8,8 +8,7 @@ import React, {
8
8
  // @ts-ignore
9
9
  import syncMove from "@mapbox/mapbox-gl-sync-move";
10
10
  import "./style.css";
11
- // @ts-ignore
12
- import { MapContext } from "@mapcomponents/react-core";
11
+ import MapContext from "../../contexts/MapContext";
13
12
 
14
13
  interface MlLayerSwipeProps {
15
14
  /**
@@ -32,7 +31,7 @@ const MlLayerSwipe = (props: MlLayerSwipeProps) => {
32
31
  const [swipeX, setSwipeX] = useState(50);
33
32
  const swipeXRef = useRef(0);
34
33
 
35
- const syncCleanupFunctionRef = useRef(null);
34
+ const syncCleanupFunctionRef = useRef(() => {});
36
35
 
37
36
  const mapExists = useCallback(() => {
38
37
  if (!props.map1Id || !props.map2Id) {
@@ -46,10 +45,7 @@ const MlLayerSwipe = (props: MlLayerSwipeProps) => {
46
45
  }, [mapContext, props.map1Id, props.map2Id]);
47
46
 
48
47
  const cleanup = () => {
49
- if (syncCleanupFunctionRef.current) {
50
- // @ts-ignore
51
48
  syncCleanupFunctionRef.current();
52
- }
53
49
  };
54
50
 
55
51
  const onMove = useCallback(
@@ -68,7 +64,6 @@ const MlLayerSwipe = (props: MlLayerSwipeProps) => {
68
64
  clientX -= bounds.x;
69
65
  let swipeX_tmp = parseFloat(((clientX / bounds.width) * 100).toFixed(2));
70
66
 
71
- console.log(swipeX_tmp);
72
67
  if (swipeXRef.current !== swipeX_tmp) {
73
68
  setSwipeX(swipeX_tmp);
74
69
  swipeXRef.current = swipeX_tmp;
@@ -5,7 +5,7 @@ import PropTypes from "prop-types";
5
5
  import { useTranslation } from "react-i18next";
6
6
  import { Card, CardContent, Typography, Box } from "@mui/material";
7
7
  //Internal
8
- import { MapContext } from "@mapcomponents/react-core";
8
+ import MapContext from "../../contexts/MapContext";
9
9
  import LayerBox from "./components/LayerBox";
10
10
  import Divider from "@mui/material/Divider";
11
11
  import useMapState from "../../hooks/useMapState";
@@ -1,7 +1,7 @@
1
1
  import React, { useContext, useState } from "react";
2
2
  import { mount, configure } from "enzyme";
3
3
  import { waitFor } from "@testing-library/react";
4
- import { MapContext, MapComponentsProvider } from "@mapcomponents/react-core";
4
+ import MapContext, { MapComponentsProvider } from "../../contexts/MapContext";
5
5
  import MlNavigationCompass from "./MlNavigationCompass";
6
6
  import MapLibreMap from "./../MapLibreMap/MapLibreMap";
7
7
  import maplibregl from "maplibre-gl/dist/maplibre-gl";
@@ -1,7 +1,7 @@
1
1
  import React, { useRef, useEffect, useContext, useState, useCallback } from "react";
2
2
  import PropTypes from "prop-types";
3
3
 
4
- import { MapContext } from "@mapcomponents/react-core";
4
+ import MapContext from "../../contexts/MapContext";
5
5
  import { v4 as uuidv4 } from "uuid";
6
6
  import useMapState from "../../hooks/useMapState";
7
7
 
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback, useRef, useContext, useEffect } from "react";
2
- import { MapContext } from "@mapcomponents/react-core";
2
+ import MapContext from "../../contexts/MapContext";
3
3
  import GeoJsonContext from "../MlGPXViewer/util/GeoJsonContext";
4
4
  import { polygon, lineString } from "@turf/helpers";
5
5
  import { distance, lineOffset } from "@turf/turf";
@@ -110,13 +110,7 @@ const MlSpatialElevationProfile = (props) => {
110
110
  props.insertBeforeLayer,
111
111
  componentId.current
112
112
  );
113
- }, [
114
- mapContext.mapIds,
115
- props.insertBeforeLayer,
116
- props.mapId,
117
- dataSource,
118
- mapContext,
119
- ]);
113
+ }, [mapContext.mapIds, props.insertBeforeLayer, props.mapId, dataSource, mapContext]);
120
114
 
121
115
  useEffect(() => {
122
116
  if (!mapRef.current || !mapRef.current.getLayer(layerName.current)) return;
@@ -155,10 +149,7 @@ const MlSpatialElevationProfile = (props) => {
155
149
  if (line.geometry.coordinates[index + 1]) {
156
150
  const wayLength = distance(
157
151
  [coordinate[0], coordinate[1]],
158
- [
159
- line.geometry.coordinates[index + 1][0],
160
- line.geometry.coordinates[index + 1][1],
161
- ],
152
+ [line.geometry.coordinates[index + 1][0], line.geometry.coordinates[index + 1][1]],
162
153
  { units: "kilometers" }
163
154
  );
164
155
  let listLength = ~~((wayLength * 1000) / 10);
@@ -228,6 +219,6 @@ MlSpatialElevationProfile.propTypes = {
228
219
  * https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
229
220
  */
230
221
  insertBeforeLayer: PropTypes.string,
231
- }
222
+ };
232
223
 
233
224
  export default MlSpatialElevationProfile;
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useRef, useEffect, useState } from "react";
2
- import { MapContext } from "@mapcomponents/react-core";
2
+ import MapContext from "../../contexts/MapContext";
3
3
 
4
4
  import Button from "@mui/material/Button";
5
5
  import maplibregl from "maplibre-gl";
@@ -3,7 +3,7 @@ import React, { useState, useContext, useRef, useEffect } from "react";
3
3
  import MlTransitionGeoJsonLayer from "./MlTransitionGeoJsonLayer";
4
4
 
5
5
  import mapContextDecorator from "../../decorators/MapContextDecorator";
6
- import { MapContext } from "@mapcomponents/react-core";
6
+ import MapContext from "../../contexts/MapContext";
7
7
 
8
8
  import sample_geojson_1 from "./assets/sample_1.json";
9
9
  import sample_geojson_2 from "./assets/sample_2.json";
@@ -1,7 +1,7 @@
1
1
  import React, { useRef, useEffect, useContext } from "react";
2
2
  import PropTypes from "prop-types";
3
3
 
4
- import { MapContext } from "@mapcomponents/react-core";
4
+ import MapContext from "../../contexts/MapContext";
5
5
  import { v4 as uuidv4 } from "uuid";
6
6
 
7
7
  /**
@@ -1,7 +1,6 @@
1
1
  import React, { useRef, useEffect, useContext, useCallback, useState } from "react";
2
2
 
3
- // @ts-ignore
4
- import { MapContext } from "@mapcomponents/react-core";
3
+ import MapContext from "../../contexts/MapContext";
5
4
  import { v4 as uuidv4 } from "uuid";
6
5
 
7
6
  import MlWmsLayer from "../MlWmsLayer/MlWmsLayer";