@mapcomponents/react-maplibre 0.1.66 → 0.1.67

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 (179) hide show
  1. package/.github/workflows/node_version_test.yml +1 -1
  2. package/.storybook/main.js +37 -31
  3. package/.storybook/preview.js +21 -0
  4. package/CHANGELOG.md +13 -0
  5. package/coverage/clover.xml +419 -344
  6. package/coverage/coverage-final.json +15 -14
  7. package/coverage/lcov-report/index.html +61 -61
  8. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +24 -18
  9. package/coverage/lcov-report/src/components/MapLibreMap/index.html +14 -14
  10. package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +2 -2
  11. package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
  12. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +1 -1
  13. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
  14. package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.cy.tsx.html +1 -1
  15. package/coverage/lcov-report/src/components/MlCreatePdfForm/MlCreatePdfForm.tsx.html +1 -1
  16. package/coverage/lcov-report/src/components/MlCreatePdfForm/index.html +1 -1
  17. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +1 -1
  18. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
  19. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
  20. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  21. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +9 -9
  22. package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
  23. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +1 -1
  24. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  25. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.lineStyler.js.html +1 -1
  26. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeoJsonLayer.polygonStyler.js.html +1 -1
  27. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerCircleStyler.tsx.html +1 -1
  28. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/MlGeojsonLayerHeatMapStyler.tsx.html +1 -1
  29. package/coverage/lcov-report/src/components/MlGeoJsonLayer/story_utils/index.html +1 -1
  30. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.tsx.html +1 -1
  31. package/coverage/lcov-report/src/components/MlGeojsonLayerWithSource/index.html +1 -1
  32. package/coverage/lcov-report/src/components/MlGpxViewer/MlGpxViewer.tsx.html +1 -1
  33. package/coverage/lcov-report/src/components/MlGpxViewer/index.html +1 -1
  34. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +1 -1
  35. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
  36. package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +1 -1
  37. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  38. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +52 -40
  39. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +10 -10
  40. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +4 -4
  41. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
  42. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
  43. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
  44. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  45. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  46. package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +1 -1
  47. package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
  48. package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +1 -1
  49. package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
  50. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
  51. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  52. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +1 -1
  53. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +1 -1
  54. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
  55. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +1 -1
  56. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  57. package/coverage/lcov-report/src/components/MlScaleReference/{MlScaleReference.js.html → MlScaleReference.tsx.html} +57 -36
  58. package/coverage/lcov-report/src/components/MlScaleReference/index.html +2 -2
  59. package/coverage/lcov-report/src/components/MlShareMapState/{MlShareMapState.js.html → MlShareMapState.tsx.html} +192 -84
  60. package/coverage/lcov-report/src/components/MlShareMapState/index.html +20 -20
  61. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/ColorPicker.tsx.html +1 -1
  62. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerList.tsx.html +1 -1
  63. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerListItem.tsx.html +1 -1
  64. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/LayerPropertyForm.tsx.html +1 -1
  65. package/coverage/lcov-report/src/components/MlSketchTool/LayerList/index.html +1 -1
  66. package/coverage/lcov-report/src/components/MlSketchTool/MlSketchTool.tsx.html +1 -1
  67. package/coverage/lcov-report/src/components/MlSketchTool/index.html +1 -1
  68. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.tsx.html +1 -1
  69. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  70. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
  71. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreejsLayer.tsx.html +769 -0
  72. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +25 -10
  73. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +1 -1
  74. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
  75. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  76. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  77. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +1 -1
  78. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
  79. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +11 -11
  80. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +11 -11
  81. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +1 -1
  82. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
  83. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +27 -18
  84. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +11 -11
  85. package/coverage/lcov-report/src/contexts/MapContext.tsx.html +50 -26
  86. package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
  87. package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
  88. package/coverage/lcov-report/src/contexts/index.html +1 -1
  89. package/coverage/lcov-report/src/hooks/index.html +21 -21
  90. package/coverage/lcov-report/src/hooks/useCameraFollowPath/index.html +1 -1
  91. package/coverage/lcov-report/src/hooks/useCameraFollowPath/useCameraFollowPath.tsx.html +1 -1
  92. package/coverage/lcov-report/src/hooks/useExportMap/index.html +1 -1
  93. package/coverage/lcov-report/src/hooks/useExportMap/index.ts.html +1 -1
  94. package/coverage/lcov-report/src/hooks/useExportMap/lib.ts.html +1 -1
  95. package/coverage/lcov-report/src/hooks/useGpx/index.html +1 -1
  96. package/coverage/lcov-report/src/hooks/useGpx/useGpx.tsx.html +1 -1
  97. package/coverage/lcov-report/src/hooks/useLayer.ts.html +1 -1
  98. package/coverage/lcov-report/src/hooks/useLayerEvent.js.html +9 -9
  99. package/coverage/lcov-report/src/hooks/useLayerFilter/index.html +1 -1
  100. package/coverage/lcov-report/src/hooks/useLayerFilter/useLayerFilter.ts.html +1 -1
  101. package/coverage/lcov-report/src/hooks/useLayerHoverPopup/index.html +1 -1
  102. package/coverage/lcov-report/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx.html +9 -6
  103. package/coverage/lcov-report/src/hooks/useMap.ts.html +2 -2
  104. package/coverage/lcov-report/src/hooks/useMapState.ts.html +8 -29
  105. package/coverage/lcov-report/src/hooks/useSource.ts.html +10 -10
  106. package/coverage/lcov-report/src/hooks/useWms.ts.html +1 -1
  107. package/coverage/lcov-report/src/index.html +1 -1
  108. package/coverage/lcov-report/src/index.ts.html +80 -11
  109. package/coverage/lcov.info +741 -604
  110. package/dist/components/MapLibreMap/MapLibreMap.stories.d.ts +3 -0
  111. package/dist/components/MapLibreMap/lib/MapLibreGlWrapper.d.ts +17 -15
  112. package/dist/components/MlCenterPosition/MlCenterPosition.stories.d.ts +1 -1
  113. package/dist/components/MlComponentTemplate/MlComponentTemplate.stories.d.ts +1 -1
  114. package/dist/components/MlCreatePdfButton/MlCreatePdfButton.stories.d.ts +1 -1
  115. package/dist/components/MlCreatePdfForm/MlCreatePdfForm.stories.d.ts +1 -1
  116. package/dist/components/MlFeatureEditor/lib/create_supplementary_points.d.ts +1 -1
  117. package/dist/components/MlFeatureEditor/lib/create_vertex.d.ts +1 -1
  118. package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.d.ts +1 -1
  119. package/dist/components/MlGeojsonLayerWithSource/MlGeojsonLayerWithSource.stories.d.ts +1 -1
  120. package/dist/components/MlGpxViewer/MlGpxViewer.stories.d.ts +1 -1
  121. package/dist/components/MlImageMarkerLayer/MlImageMarkerLayer.stories.d.ts +1 -1
  122. package/dist/components/MlLayerMagnify/MlLayerMagnify.stories.d.ts +1 -1
  123. package/dist/components/MlLayerSwipe/MlLayerSwipe.stories.d.ts +1 -1
  124. package/dist/components/MlScaleReference/MlScaleReference.d.ts +7 -1
  125. package/dist/components/MlShareMapState/MlShareMapState.d.ts +32 -13
  126. package/dist/components/MlShareMapState/MlShareMapState.stories.d.ts +15 -9
  127. package/dist/components/MlSketchTool/MlSketchTool.stories.d.ts +1 -1
  128. package/dist/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.d.ts +1 -1
  129. package/dist/components/MlSpatialElevationProfile/util/getElevationData.d.ts +1 -1
  130. package/dist/components/MlThreeJsLayer/MlThreeJsLayer.stories.d.ts +1 -1
  131. package/dist/components/MlThreeJsLayer/MlThreejsLayer.d.ts +29 -0
  132. package/dist/components/MlThreeJsLayer/lib/GLTFLoader.d.ts +2 -1
  133. package/dist/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.stories.d.ts +1 -1
  134. package/dist/components/MlWmsLoader/MlWmsLoader.stories.d.ts +1 -1
  135. package/dist/contexts/MapContext.d.ts +13 -2
  136. package/dist/custom.d.d.ts +1 -1
  137. package/dist/decorators/MapContextDecorator.d.ts +1 -1
  138. package/dist/decorators/MapContextDecoratorHooks.d.ts +1 -1
  139. package/dist/decorators/MultiMapContextDecorator.d.ts +1 -1
  140. package/dist/decorators/NoNavToolsDecorator.d.ts +1 -1
  141. package/dist/decorators/ThemeWrapper.d.ts +1 -3
  142. package/dist/hooks/useCameraFollowPath/useCameraFollowPath.stories.d.ts +1 -1
  143. package/dist/hooks/useLayerFilter/useLayerFilter.stories.d.ts +1 -1
  144. package/dist/index.d.ts +18 -8
  145. package/dist/index.esm.js +5590 -3701
  146. package/dist/index.esm.js.map +1 -1
  147. package/dist/setupTests.d.ts +6 -6
  148. package/package.json +56 -49
  149. package/public/thumbnails/{MlGPXViewer.png → MlGpxViewer.png} +0 -0
  150. package/rollup.config.js +49 -48
  151. package/src/@types/assets/index.d.ts +20 -0
  152. package/src/components/MapLibreMap/MapLibreMap.stories.js +8 -1
  153. package/src/components/MapLibreMap/MapLibreMap.tsx +11 -9
  154. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +49 -39
  155. package/src/components/MlCenterPosition/MlCenterPosition.tsx +1 -1
  156. package/src/components/MlFollowGps/MlFollowGps.tsx +8 -8
  157. package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +21 -17
  158. package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +3 -3
  159. package/src/components/MlScaleReference/{MlScaleReference.js → MlScaleReference.tsx} +38 -31
  160. package/src/components/MlShareMapState/MlShareMapState.stories.tsx +100 -0
  161. package/src/components/MlShareMapState/{MlShareMapState.js → MlShareMapState.tsx} +94 -58
  162. package/src/components/MlThreeJsLayer/MlThreejsLayer.tsx +228 -0
  163. package/src/components/MlWmsLoader/MlWmsLoader.tsx +7 -4
  164. package/src/contexts/MapContext.tsx +26 -19
  165. package/src/custom.d.ts +5 -0
  166. package/src/decorators/MapContextDecorator.js +39 -28
  167. package/src/decorators/MapContextDecoratorHooks.js +18 -8
  168. package/src/decorators/MultiMapContextDecorator.js +79 -69
  169. package/src/decorators/NoNavToolsDecorator.js +34 -25
  170. package/src/hooks/useLayerHoverPopup/useLayerHoverPopup.tsx +5 -4
  171. package/src/hooks/useMap.ts +1 -1
  172. package/src/hooks/useMapState.ts +6 -13
  173. package/src/hooks/useSource.ts +1 -1
  174. package/src/index.ts +31 -8
  175. package/src/ui_components/TopToolbar.tsx +1 -1
  176. package/tsconfig.json +1 -0
  177. package/src/components/MlShareMapState/MlShareMapState.stories.js +0 -100
  178. package/src/custom.d.tsx +0 -26
  179. package/src/decorators/ThemeWrapper.tsx +0 -9
@@ -1,11 +1,11 @@
1
1
  export var uuid_regex: string;
2
2
  export namespace mockMapLibreMethods {
3
- const on: jest.Mock<any, any>;
4
- const off: jest.Mock<any, any>;
5
- const addControl: jest.Mock<any, any>;
6
- const removeControl: jest.Mock<any, any>;
7
- const fitBounds: jest.Mock<any, any>;
8
- const hasControl: jest.Mock<boolean, []>;
3
+ const on: jest.Mock<any, any, any>;
4
+ const off: jest.Mock<any, any, any>;
5
+ const addControl: jest.Mock<any, any, any>;
6
+ const removeControl: jest.Mock<any, any, any>;
7
+ const fitBounds: jest.Mock<any, any, any>;
8
+ const hasControl: jest.Mock<boolean, [], any>;
9
9
  function getCanvas(): HTMLCanvasElement;
10
10
  function getContainer(): {
11
11
  style: {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapcomponents/react-maplibre",
3
- "version": "0.1.66",
3
+ "version": "0.1.67",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.esm.js",
@@ -23,69 +23,76 @@
23
23
  "@emotion/css": "11.10.5",
24
24
  "@emotion/react": "11.10.5",
25
25
  "@emotion/styled": "11.10.5",
26
+ "@fontsource/material-icons": "^4.5.4",
27
+ "@fontsource/roboto": "^4.5.8",
26
28
  "@mapbox/mapbox-gl-draw": "^1.3.0",
27
29
  "@mapbox/mapbox-gl-sync-move": "0.3.0",
28
30
  "@mui/icons-material": "5.11.0",
29
- "@mui/material": "5.11.0",
30
- "@mui/styles": "5.11.0",
31
+ "@mui/material": "5.11.6",
32
+ "@mui/styles": "5.11.2",
31
33
  "@turf/turf": "^6.5.0",
32
- "d3": "^7.7.0",
34
+ "d3": "^7.8.2",
33
35
  "jspdf": "^2.5.1",
34
36
  "maplibre-gl": "^2.4.0",
35
37
  "mui-color": "^2.0.0-beta.2",
36
38
  "react-draggable": "^4.4.5",
37
- "react-i18next": "^11.14.3",
39
+ "react-i18next": "^12.1.4",
38
40
  "react-moveable": "^0.45.1",
39
- "three": "^0.147.0",
41
+ "storybook-source-link": "^2.0.4",
42
+ "three": "^0.149.0",
40
43
  "uuid": "^9.0.0",
41
44
  "wms-capabilities": "^0.6.0",
42
45
  "xmldom": "^0.6.0"
43
46
  },
44
47
  "peerDependencies": {},
45
48
  "devDependencies": {
46
- "@babel/preset-react": "^7.16.7",
49
+ "@babel/preset-react": "^7.18.6",
47
50
  "@bahmutov/cy-rollup": "^2.0.0",
48
- "@cypress/react": "^6.2.0",
49
- "@cypress/webpack-preprocessor": "^5.14.0",
50
- "@rollup/plugin-alias": "^3.1.9",
51
- "@rollup/plugin-babel": "^5.3.1",
52
- "@rollup/plugin-commonjs": "^21.0.3",
53
- "@rollup/plugin-node-resolve": "^13.1.3",
54
- "@rollup/plugin-url": "^6.1.0",
55
- "@storybook/addon-actions": "^6.4.19",
56
- "@storybook/addon-docs": "^6.4.20",
57
- "@storybook/addon-essentials": "^6.4.19",
58
- "@storybook/addon-links": "^6.4.19",
59
- "@storybook/addons": "^6.4.19",
60
- "@storybook/node-logger": "^6.4.19",
61
- "@storybook/react": "^6.4.19",
51
+ "@cypress/react": "^7.0.2",
52
+ "@cypress/webpack-preprocessor": "^5.16.1",
53
+ "@rollup/plugin-alias": "^4.0.3",
54
+ "@rollup/plugin-babel": "^6.0.3",
55
+ "@rollup/plugin-commonjs": "^24.0.1",
56
+ "@rollup/plugin-node-resolve": "^15.0.1",
57
+ "@rollup/plugin-url": "^8.0.1",
58
+ "@storybook/addon-actions": "^6.5.16",
59
+ "@storybook/addon-docs": "^6.5.16",
60
+ "@storybook/addon-essentials": "^6.5.16",
61
+ "@storybook/addon-links": "^6.5.16",
62
+ "@storybook/addon-storysource": "^6.5.16",
63
+ "@storybook/addons": "^6.5.16",
64
+ "@storybook/builder-webpack5": "^6.5.16",
65
+ "@storybook/manager-webpack5": "^6.5.16",
66
+ "@storybook/node-logger": "^6.5.16",
67
+ "@storybook/react": "^6.5.16",
62
68
  "@storybook/testing-react": "^1.3.0",
63
- "@storybook/theming": "^6.4.19",
64
- "@svgr/rollup": "^6.2.1",
65
- "@testing-library/react": "^12.1.2",
66
- "@types/enzyme": "^3.10.11",
69
+ "@storybook/theming": "^6.5.16",
70
+ "@svgr/rollup": "^6.5.1",
71
+ "@testing-library/react": "^13.4.0",
72
+ "@types/enzyme": "^3.10.12",
67
73
  "@types/expect": "^24.3.0",
68
- "@types/jest": "^29.2.5",
69
- "@types/mapbox__mapbox-gl-draw": "^1.2.3",
74
+ "@types/jest": "^29.4.0",
75
+ "@types/mapbox__mapbox-gl-draw": "^1.3.3",
70
76
  "@types/mapbox__point-geometry": "^0.1.2",
71
77
  "@types/mapbox__vector-tile": "^1.3.0",
72
- "@types/react": "^17.0.43",
73
- "@types/react-dom": "^17.0.14",
74
- "@types/uuid": "^8.3.4",
75
- "@typescript-eslint/eslint-plugin": "^5.36.1",
76
- "@typescript-eslint/parser": "^5.36.1",
77
- "@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
78
+ "@types/react": "^18.0.27",
79
+ "@types/react-dom": "^18.0.10",
80
+ "@types/three": "^0.148.1",
81
+ "@types/uuid": "^9.0.0",
82
+ "@typescript-eslint/eslint-plugin": "^5.49.0",
83
+ "@typescript-eslint/parser": "^5.49.0",
84
+ "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
78
85
  "avj": "^0.0.0",
79
86
  "babel-jest": "^26.6.0",
80
87
  "babel-plugin-inline-react-svg": "^2.0.1",
81
- "babel-plugin-styled-components": "^2.0.6",
88
+ "babel-plugin-styled-components": "^2.0.7",
82
89
  "babel-preset-react-app": "^10.0.1",
83
- "cypress": "^10.9.0",
90
+ "cypress": "^12.4.1",
84
91
  "enzyme": "^3.11.0",
85
- "eslint": "^8.23.0",
86
- "eslint-config-prettier": "^8.5.0",
87
- "eslint-plugin-react": "^7.31.1",
88
- "glob": "^7.2.0",
92
+ "eslint": "^8.32.0",
93
+ "eslint-config-prettier": "^8.6.0",
94
+ "eslint-plugin-react": "^7.32.1",
95
+ "glob": "^8.1.0",
89
96
  "jest": "26.6.0",
90
97
  "jest-circus": "26.6.0",
91
98
  "jest-environment-jsdom-sixteen": "^2.0.0",
@@ -93,24 +100,24 @@
93
100
  "jest-resolve": "26.6.0",
94
101
  "jest-watch-typeahead": "0.6.1",
95
102
  "node-fetch": "^3.3.0",
96
- "postcss": "^8.4.12",
97
- "prettier": "2.7.1",
98
- "react": "^17.0.2",
103
+ "postcss": "^8.4.21",
104
+ "prettier": "2.8.3",
105
+ "react": "^18.2.0",
99
106
  "react-app-polyfill": "^3.0.0",
100
- "react-dev-utils": "^12.0.0",
101
- "react-dom": "^17.0.2",
107
+ "react-dev-utils": "^12.0.1",
108
+ "react-dom": "^18.2.0",
102
109
  "rollup": "^2.70.1",
103
110
  "rollup-plugin-delete": "^2.0.0",
104
111
  "rollup-plugin-import-css": "^3.0.3",
105
112
  "rollup-plugin-peer-deps-external": "^2.2.4",
106
113
  "rollup-plugin-postcss": "^4.0.2",
107
114
  "rollup-plugin-typescript2": "^0.31.2",
108
- "showdown": "^2.0.3",
109
- "ts-jest": "^27.1.4",
110
- "typedoc": "^0.22.13",
111
- "typedoc-plugin-missing-exports": "^0.22.6",
115
+ "showdown": "^2.1.0",
116
+ "ts-jest": "^29.0.5",
117
+ "typedoc": "^0.23.24",
118
+ "typedoc-plugin-missing-exports": "^1.0.0",
112
119
  "typedoc-twilio-theme": "^1.0.1",
113
- "typescript": "^4.6.3"
120
+ "typescript": "^4.9.4"
114
121
  },
115
122
  "jest": {
116
123
  "roots": [
package/rollup.config.js CHANGED
@@ -1,56 +1,57 @@
1
- import peerDepsExternal from "rollup-plugin-peer-deps-external";
2
- import resolve from "@rollup/plugin-node-resolve";
3
- import commonjs from "@rollup/plugin-commonjs";
4
- import typescript from "rollup-plugin-typescript2";
1
+ import peerDepsExternal from 'rollup-plugin-peer-deps-external';
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import commonjs from '@rollup/plugin-commonjs';
4
+ import typescript from 'rollup-plugin-typescript2';
5
5
 
6
- import babel from "@rollup/plugin-babel";
7
- import url from "@rollup/plugin-url";
8
- import external from "rollup-plugin-peer-deps-external";
6
+ import babel from '@rollup/plugin-babel';
7
+ import url from '@rollup/plugin-url';
8
+ import external from 'rollup-plugin-peer-deps-external';
9
9
 
10
- import css from "rollup-plugin-import-css";
11
- import del from "rollup-plugin-delete";
12
- import svgr from "@svgr/rollup";
10
+ import css from 'rollup-plugin-import-css';
11
+ import del from 'rollup-plugin-delete';
12
+ import svgr from '@svgr/rollup';
13
13
 
14
14
  import pkg from "./package.json";
15
15
 
16
16
  const config = {
17
- input: pkg.source,
18
- output: [{ file: pkg.module, format: "esm", sourcemap: true }],
19
- plugins: [
20
- svgr({
21
- svgo: false,
22
- }),
23
- url(),
24
- babel({
25
- exclude: "node_modules/**",
26
- babelHelpers: "bundled",
27
- presets: ["@babel/preset-react"],
28
- }),
29
- external(),
30
- peerDepsExternal(),
31
- resolve(),
32
- commonjs(),
33
- typescript({
34
- useTsconfigDeclarationDir: true,
35
- tsconfig: "tsconfig.json",
36
- }),
37
- css(),
38
- del({ targets: ["build/*"] }),
39
- ],
40
- external: [
41
- "prop-types",
42
- "d3",
43
- "@emotion/react",
44
- "@emotion/styled",
45
- "@babel/helpers",
46
- "jspdf",
47
- ...Object.keys(pkg.dependencies),
48
- ...Object.keys(pkg.peerDependencies),
49
- ...Object.keys(pkg.devDependencies),
50
- ],
51
- inlineDynamicImports: true,
52
- onwarn: function (warning, warn) {
53
- warn(warning);
54
- },
17
+ input: pkg.source,
18
+ output: [{ file: pkg.module, format: 'esm', sourcemap: true }],
19
+ plugins: [
20
+ svgr({
21
+ svgo: false,
22
+ }),
23
+ url(),
24
+ babel({
25
+ exclude: 'node_modules/**',
26
+ babelHelpers: 'bundled',
27
+ presets: ['@babel/preset-react'],
28
+ }),
29
+ external(),
30
+ peerDepsExternal(),
31
+ resolve(),
32
+ commonjs(),
33
+ typescript({
34
+ useTsconfigDeclarationDir: true,
35
+ tsconfig: 'tsconfig.json',
36
+ }),
37
+ css(),
38
+ del({ targets: ['build/*'] }),
39
+ ],
40
+ external: [
41
+ '!maplibre-gl',
42
+ 'prop-types',
43
+ 'd3',
44
+ '@emotion/react',
45
+ '@emotion/styled',
46
+ '@babel/helpers',
47
+ 'jspdf',
48
+ ...Object.keys(pkg.dependencies),
49
+ ...Object.keys(pkg.peerDependencies),
50
+ ...Object.keys(pkg.devDependencies),
51
+ ],
52
+ inlineDynamicImports: true,
53
+ onwarn: function (warning, warn) {
54
+ warn(warning);
55
+ },
55
56
  };
56
57
  export default config;
@@ -0,0 +1,20 @@
1
+ declare module "*.svg" {
2
+ import React = require('react');
3
+ export const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>;
4
+ const src: string;
5
+ export default src;
6
+ }
7
+ declare module "*.jpg" {
8
+ const content: string;
9
+ export default content;
10
+ }
11
+
12
+ declare module "*.png" {
13
+ const content: string;
14
+ export default content;
15
+ }
16
+
17
+ declare module "*.json" {
18
+ const content: string;
19
+ export default content;
20
+ }
@@ -17,6 +17,10 @@ const storyoptions = {
17
17
  },
18
18
  },
19
19
  },
20
+
21
+ parameters: {
22
+ sourceLink: 'components/MapLibreMap/MapLibreMap.tsx'
23
+ }
20
24
  };
21
25
  export default storyoptions;
22
26
 
@@ -24,7 +28,7 @@ const Template = (args) => {
24
28
  return (
25
29
  <MapComponentsProvider>
26
30
  <MapLibreMap
27
- options={args.options}
31
+ options={{ ...args.options }}
28
32
  style={{
29
33
  position: "absolute",
30
34
  height: "100vh",
@@ -61,6 +65,8 @@ const StyleChangeTemplate = (args) => {
61
65
  onClick={() =>
62
66
  setActiveStyle("https://wms.wheregroup.com/tileserver/style/osm-bright.json")
63
67
  }
68
+ variant="contained"
69
+ sx={{marginRight:'5px'}}
64
70
  >
65
71
  OSM-Bright
66
72
  </Button>
@@ -68,6 +74,7 @@ const StyleChangeTemplate = (args) => {
68
74
  onClick={() =>
69
75
  setActiveStyle("https://wms.wheregroup.com/tileserver/style/osm-fiord-color.json")
70
76
  }
77
+ variant="contained"
71
78
  >
72
79
  OSM-Fiord-Color
73
80
  </Button>
@@ -1,6 +1,6 @@
1
1
  import React, { useRef, useEffect, useContext, FC, RefObject } from "react";
2
2
 
3
- import MapContext from "../../contexts/MapContext";
3
+ import MapContext, { MapContextType } from "../../contexts/MapContext";
4
4
  import MapLibreGlWrapper from "./lib/MapLibreGlWrapper";
5
5
 
6
6
  import { MapOptions as MapOptionsType } from "maplibre-gl";
@@ -59,35 +59,38 @@ const defaultProps: MapLibreMapProps = {
59
59
  * @category Map components
60
60
  */
61
61
  const MapLibreMap: FC<MapLibreMapProps> = (props: MapLibreMapProps) => {
62
- const map: any = useRef<MapLibreGlWrapper>(null);
62
+ const map = useRef<MapLibreGlWrapper>();
63
63
  const mapContainer = useRef<HTMLDivElement>();
64
64
 
65
- const mapContext: any = useContext<MapContextType>(MapContext);
65
+ const mapContext = useContext<MapContextType>(MapContext);
66
66
 
67
67
  const mapIdRef = useRef(props.mapId);
68
68
  const initializedRef = useRef(false);
69
69
  const currentStyle = useRef(props.options?.style);
70
70
 
71
71
  useEffect(() => {
72
- let mapId = mapIdRef.current;
72
+ const mapId = mapIdRef.current;
73
73
 
74
74
  return () => {
75
75
  mapContext.removeMap(mapId);
76
- map.current?.remove?.();
77
- map.current = null;
76
+ map.current?.map?.remove?.();
77
+ map.current = undefined;
78
78
  };
79
79
  }, []);
80
80
 
81
81
  useEffect(() => {
82
82
  if (initializedRef.current) return;
83
83
 
84
+ console.log(mapContainer.current);
85
+
84
86
  if (mapContainer.current) {
85
87
  initializedRef.current = true;
86
88
  map.current = new MapLibreGlWrapper({
87
89
  mapOptions: {
88
90
  style: '',
89
- container: mapContainer.current,
90
91
  ...props.options,
92
+ ...(props?.options?.style?{}:{style:defaultProps?.options?.style}),
93
+ container: mapContainer.current,
91
94
  },
92
95
  onReady: (map: any, wrapper: any) => {
93
96
  map.once("load", () => {
@@ -108,8 +111,7 @@ const MapLibreMap: FC<MapLibreMapProps> = (props: MapLibreMapProps) => {
108
111
  currentStyle.current = props.options.style;
109
112
  map.current.map.setStyle(props.options.style);
110
113
  }
111
- // @ts-ignore: props.options is either passed or populated with default values
112
- }, [props.options.style])
114
+ }, [props?.options?.style])
113
115
 
114
116
  return <div ref={mapContainer as RefObject<HTMLDivElement>} className="mapContainer" style={props.style} />;
115
117
  };
@@ -9,6 +9,7 @@ import {
9
9
  CustomLayerInterface,
10
10
  SourceSpecification,
11
11
  ControlPosition,
12
+ StyleImageMetadata,
12
13
  } from '!maplibre-gl';
13
14
  import { Map as MapType, Style } from 'maplibre-gl';
14
15
 
@@ -39,6 +40,34 @@ type ViewportState = {
39
40
  * @class
40
41
  */
41
42
 
43
+ interface MapLibreGlWrapper extends MapType {
44
+ addImage: (
45
+ id: string,
46
+ image:
47
+ | HTMLImageElement
48
+ | ImageBitmap
49
+ | ImageData
50
+ | {
51
+ width: number;
52
+ height: number;
53
+ data: Uint8Array | Uint8ClampedArray;
54
+ }
55
+ | StyleImageInterface,
56
+ key?: Partial<StyleImageMetadata> | string | undefined,
57
+ componentId?: string | undefined
58
+ ) => this;
59
+ addLayer: (
60
+ layer:
61
+ | (LayerSpecification & {
62
+ source?: string | SourceSpecification | undefined;
63
+ })
64
+ | (CustomLayerInterface & {
65
+ source?: string | SourceSpecification | undefined;
66
+ }),
67
+ beforeId?: string | undefined,
68
+ componentId?: string | undefined
69
+ ) => this;
70
+ }
42
71
  class MapLibreGlWrapper {
43
72
  registeredElements: {
44
73
  [key: string]: {
@@ -90,42 +119,21 @@ class MapLibreGlWrapper {
90
119
  initRegisteredElements: (componentId: string, force?: boolean | undefined) => void;
91
120
  addNativeMaplibreFunctionsAndProps: () => void;
92
121
  map: MapType;
93
- style: object;
122
+ style: Style;
94
123
 
95
124
  styleJson: object;
96
- addLayer: (
97
- layer:
98
- | (LayerSpecification & {
99
- source?: string | SourceSpecification | undefined;
100
- })
101
- | (CustomLayerInterface & {
102
- source?: string | SourceSpecification | undefined;
103
- }),
104
- beforeId?: string | undefined,
105
- componentId?: string | undefined
106
- ) => Map | undefined;
107
- addSource: (id: string, source: SourceSpecification,componentId?: string | undefined) => Map | undefined;
108
- addControl: (control: IControl | unknown, position?: ControlPosition | undefined,componentId?: string | undefined) => Map | undefined;
109
- addImage: (
110
- id: string,
111
- image:
112
- | HTMLImageElement
113
- | ImageBitmap
114
- | ImageData
115
- | {
116
- width: number;
117
- height: number;
118
- data: Uint8Array | Uint8ClampedArray;
119
- }
120
- | StyleImageInterface,
125
+ addSource: (id: string, source: SourceSpecification, componentId?: string | undefined) => this;
126
+ addControl: (
127
+ control: IControl | unknown,
128
+ position?: ControlPosition | undefined,
121
129
  componentId?: string | undefined
122
- ) => void;
130
+ ) => this;
123
131
  on: (
124
132
  type: keyof MapLayerEventType | keyof MapEventType | string,
125
133
  layerId: string | ((ev: unknown) => void),
126
134
  handler?: ((ev: MapEventType & unknown) => Map | void) | string,
127
135
  componentId?: string | undefined
128
- ) => Map | undefined;
136
+ ) => this;
129
137
  cleanup: (componentId: string) => void;
130
138
 
131
139
  constructor(props: {
@@ -367,7 +375,7 @@ class MapLibreGlWrapper {
367
375
  */
368
376
  this.addLayer = (layer, beforeId, componentId) => {
369
377
  if (!self.map.style) {
370
- return;
378
+ return this;
371
379
  }
372
380
  if (componentId && typeof componentId === 'string' && typeof layer.id !== 'undefined') {
373
381
  self.initRegisteredElements(componentId);
@@ -379,7 +387,7 @@ class MapLibreGlWrapper {
379
387
  }
380
388
 
381
389
  self.map.addLayer(layer, beforeId);
382
- return self.map;
390
+ return this;
383
391
  };
384
392
 
385
393
  /**
@@ -393,7 +401,7 @@ class MapLibreGlWrapper {
393
401
  */
394
402
  this.addSource = (sourceId, source, componentId) => {
395
403
  if (!self.map.style) {
396
- return;
404
+ return this;
397
405
  }
398
406
  if (componentId && typeof componentId === 'string' && typeof sourceId !== 'undefined') {
399
407
  self.initRegisteredElements(componentId);
@@ -401,7 +409,7 @@ class MapLibreGlWrapper {
401
409
  }
402
410
 
403
411
  self.map.addSource(sourceId, source);
404
- return self.map;
412
+ return this;
405
413
  };
406
414
 
407
415
  /**
@@ -411,18 +419,21 @@ class MapLibreGlWrapper {
411
419
  * @param {*} image
412
420
  * @param {*} ref
413
421
  * @param {string} componentId
414
- * @returns {undefined}
415
422
  */
416
- this.addImage = (id, image, componentId) => {
423
+ this.addImage = (id, image, meta, componentId) => {
417
424
  if (!self.map.style) {
418
- return;
425
+ return this;
426
+ }
427
+ if (typeof meta === 'string' && typeof componentId === 'undefined') {
428
+ return self.addImage(id, image, undefined, meta);
419
429
  }
420
430
  if (componentId && typeof componentId === 'string' && typeof id !== 'undefined') {
421
431
  self.initRegisteredElements(componentId);
422
432
  self.registeredElements[componentId].images.push(id);
423
433
  }
424
434
 
425
- self.map.addImage(id, image);
435
+ self.map.addImage(id, image, meta as Partial<StyleImageMetadata> | undefined);
436
+ return this;
426
437
  };
427
438
 
428
439
  /**
@@ -456,7 +467,7 @@ class MapLibreGlWrapper {
456
467
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
457
468
  // @ts-ignore
458
469
  self.map.on(..._arguments);
459
- return self.map;
470
+ return this;
460
471
  };
461
472
 
462
473
  /**
@@ -473,7 +484,7 @@ class MapLibreGlWrapper {
473
484
  }
474
485
 
475
486
  self.map.addControl(control as IControl, position);
476
- return self.map;
487
+ return this;
477
488
  };
478
489
 
479
490
  /**
@@ -675,7 +686,6 @@ class MapLibreGlWrapper {
675
686
  initializeMapLibre();
676
687
  }
677
688
  }
678
-
679
689
  export default MapLibreGlWrapper;
680
690
 
681
691
  export type { LayerState, ViewportState };
@@ -42,7 +42,7 @@ const MlCenterPosition = (props: MlCenterPositionProps) => {
42
42
  navigator.geolocation.getCurrentPosition(getLocationSuccess, getLocationError);
43
43
  };
44
44
 
45
- const getLocationSuccess = useCallback((location) => {
45
+ const getLocationSuccess = useCallback((location:GeolocationPosition) => {
46
46
  mapHook.map?.map.setCenter?.([location.coords.longitude, location.coords.latitude]);
47
47
  }, [mapHook.map]);
48
48
 
@@ -93,7 +93,7 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
93
93
  const initiallyCentered = useRef(false);
94
94
 
95
95
  const getLocationSuccess = useCallback(
96
- (pos) => {
96
+ (pos:GeolocationPosition) => {
97
97
  if (!mapHook.map) return;
98
98
 
99
99
  if ((!props.centerUserPosition && !initiallyCentered.current) || props.centerUserPosition) {
@@ -127,12 +127,12 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
127
127
  if (!userLocationGeoJson) {
128
128
  return undefined;
129
129
  }
130
- let radius = 0.02;
131
- let bearing1 = deviceOrientation - 15;
132
- let bearing2 = deviceOrientation + 15;
130
+ const radius = 0.02;
131
+ const bearing1 = deviceOrientation - 15;
132
+ const bearing2 = deviceOrientation + 15;
133
133
  const options = { steps: 65 };
134
- let arc = lineArc(userLocationGeoJson, radius, bearing1, bearing2, options);
135
- let copy = arc;
134
+ const arc = lineArc(userLocationGeoJson, radius, bearing1, bearing2, options);
135
+ const copy = arc;
136
136
  copy.geometry.coordinates.push(userLocationGeoJson.geometry.coordinates);
137
137
  copy.geometry.coordinates.slice(0, 0);
138
138
  return copy;
@@ -144,7 +144,7 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
144
144
 
145
145
  useEffect(() => {
146
146
  if (isFollowed) {
147
- let _handleOrientation = handleOrientation;
147
+ const _handleOrientation = handleOrientation;
148
148
  window.addEventListener("deviceorientation", _handleOrientation);
149
149
  return () => {
150
150
  window.removeEventListener("deviceorientation", _handleOrientation);
@@ -159,7 +159,7 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
159
159
  if (!mapHook.map) return;
160
160
 
161
161
  if (isFollowed) {
162
- let _watchId = navigator.geolocation.watchPosition(getLocationSuccess, getLocationError);
162
+ const _watchId = navigator.geolocation.watchPosition(getLocationSuccess, getLocationError);
163
163
 
164
164
  return () => {
165
165
  navigator.geolocation.clearWatch(_watchId);