@mapcomponents/react-maplibre 0.1.8 → 0.1.12

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 (82) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +2 -2
  2. package/.github/ISSUE_TEMPLATE/feature_request.md +3 -3
  3. package/.github/workflows/node_version_test.yml +25 -0
  4. package/.github/workflows/storybook.yml +6 -3
  5. package/CODE_OF_CONDUCT.md +70 -0
  6. package/CONTRIBUTING.md +149 -0
  7. package/README.md +16 -9
  8. package/coverage/clover.xml +76 -72
  9. package/coverage/coverage-final.json +2 -2
  10. package/coverage/lcov-report/block-navigation.js +8 -0
  11. package/coverage/lcov-report/components/MapLibreMap/MapLibreMap.js.html +8 -2
  12. package/coverage/lcov-report/components/MapLibreMap/index.html +8 -2
  13. package/coverage/lcov-report/components/MlCreatePdfButton/MlCreatePdfButton.js.html +8 -2
  14. package/coverage/lcov-report/components/MlCreatePdfButton/index.html +8 -2
  15. package/coverage/lcov-report/components/MlFeatureEditor/MlFeatureEditor.js.html +8 -2
  16. package/coverage/lcov-report/components/MlFeatureEditor/index.html +8 -2
  17. package/coverage/lcov-report/components/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +8 -2
  18. package/coverage/lcov-report/components/MlFillExtrusionLayer/index.html +8 -2
  19. package/coverage/lcov-report/components/MlFollowGps/MlFollowGps.js.html +53 -8
  20. package/coverage/lcov-report/components/MlFollowGps/index.html +18 -12
  21. package/coverage/lcov-report/components/MlGPXViewer/MlGPXViewer.js.html +8 -2
  22. package/coverage/lcov-report/components/MlGPXViewer/gpxConverter.js.html +8 -2
  23. package/coverage/lcov-report/components/MlGPXViewer/index.html +8 -2
  24. package/coverage/lcov-report/components/MlGeoJsonLayer/MlGeoJsonLayer.js.html +35 -17
  25. package/coverage/lcov-report/components/MlGeoJsonLayer/index.html +26 -20
  26. package/coverage/lcov-report/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +8 -2
  27. package/coverage/lcov-report/components/MlImageMarkerLayer/index.html +8 -2
  28. package/coverage/lcov-report/components/MlLayer/MlLayer.js.html +8 -2
  29. package/coverage/lcov-report/components/MlLayer/index.html +8 -2
  30. package/coverage/lcov-report/components/MlLayerMagnify/MlLayerMagnify.js.html +8 -2
  31. package/coverage/lcov-report/components/MlLayerMagnify/index.html +8 -2
  32. package/coverage/lcov-report/components/MlLayerSwipe/MlLayerSwipe.js.html +8 -2
  33. package/coverage/lcov-report/components/MlLayerSwipe/index.html +8 -2
  34. package/coverage/lcov-report/components/MlMarker/MlMarker.js.html +8 -2
  35. package/coverage/lcov-report/components/MlMarker/index.html +8 -2
  36. package/coverage/lcov-report/components/MlNavigationCompass/MlNavigationCompass.js.html +8 -2
  37. package/coverage/lcov-report/components/MlNavigationCompass/index.html +8 -2
  38. package/coverage/lcov-report/components/MlNavigationTools/MlNavigationTools.js.html +8 -2
  39. package/coverage/lcov-report/components/MlNavigationTools/index.html +8 -2
  40. package/coverage/lcov-report/components/MlOsmLayer/MlOsmLayer.js.html +8 -2
  41. package/coverage/lcov-report/components/MlOsmLayer/index.html +8 -2
  42. package/coverage/lcov-report/components/MlScaleReference/MlScaleReference.js.html +8 -2
  43. package/coverage/lcov-report/components/MlScaleReference/index.html +8 -2
  44. package/coverage/lcov-report/components/MlShareMapState/MlShareMapState.js.html +8 -2
  45. package/coverage/lcov-report/components/MlShareMapState/index.html +8 -2
  46. package/coverage/lcov-report/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +8 -2
  47. package/coverage/lcov-report/components/MlSpatialElevationProfile/index.html +8 -2
  48. package/coverage/lcov-report/components/MlThreeJsLayer/MlThreeJsLayer.js.html +8 -2
  49. package/coverage/lcov-report/components/MlThreeJsLayer/index.html +8 -2
  50. package/coverage/lcov-report/components/MlUseMapDebugger/MlUseMapDebugger.js.html +8 -2
  51. package/coverage/lcov-report/components/MlUseMapDebugger/index.html +8 -2
  52. package/coverage/lcov-report/components/MlVectorTileLayer/MlVectorTileLayer.js.html +8 -2
  53. package/coverage/lcov-report/components/MlVectorTileLayer/index.html +8 -2
  54. package/coverage/lcov-report/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +8 -2
  55. package/coverage/lcov-report/components/MlWmsFeatureInfoPopup/index.html +8 -2
  56. package/coverage/lcov-report/components/MlWmsLayer/MlWmsLayer.js.html +8 -2
  57. package/coverage/lcov-report/components/MlWmsLayer/index.html +8 -2
  58. package/coverage/lcov-report/components/MlWmsLoader/MlWmsLoader.js.html +8 -2
  59. package/coverage/lcov-report/components/MlWmsLoader/index.html +8 -2
  60. package/coverage/lcov-report/hooks/index.html +8 -2
  61. package/coverage/lcov-report/hooks/useMap.js.html +8 -2
  62. package/coverage/lcov-report/hooks/useMapState.js.html +8 -2
  63. package/coverage/lcov-report/hooks/useWms.js.html +8 -2
  64. package/coverage/lcov-report/index.html +32 -26
  65. package/coverage/lcov-report/sorter.js +26 -0
  66. package/coverage/lcov.info +153 -149
  67. package/dist/index.esm.js +68 -38
  68. package/dist/index.esm.js.map +1 -1
  69. package/package.json +1 -1
  70. package/rollup.config.js +10 -2
  71. package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta.json +1 -1
  72. package/src/components/MlFollowGps/MlFollowGps.js +14 -1
  73. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +8 -4
  74. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -1
  75. package/src/components/MlGeoJsonLayer/util/transitionFunctions.js +19 -12
  76. package/src/components/MlVectorTileLayer/MlVectorTileLayer.meta.json +3 -3
  77. package/src/decorators/MapContextDashboardDecorator.js +0 -5
  78. package/src/decorators/MapContextDecorator.js +0 -5
  79. package/src/decorators/MapContextKlokantechBasicDecorator.js +0 -5
  80. package/src/decorators/MultiMapContextDecorator.js +0 -5
  81. package/src/hooks/useMapState.stories.js +7 -2
  82. package/src/ui_components/Sidebar.js +7 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapcomponents/react-maplibre",
3
- "version": "0.1.8",
3
+ "version": "0.1.12",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "module": "dist/index.esm.js",
package/rollup.config.js CHANGED
@@ -11,7 +11,9 @@ const config = {
11
11
  input: pkg.source,
12
12
  output: [{ file: pkg.module, format: "esm", sourcemap: true }],
13
13
  plugins: [
14
- svgr(),
14
+ svgr({
15
+ svgo: false,
16
+ }),
15
17
  url(),
16
18
  external(),
17
19
  babel({
@@ -21,6 +23,12 @@ const config = {
21
23
  css(),
22
24
  del({ targets: ["dist/*"] }),
23
25
  ],
24
- external: ["prop-types", "d3", ...Object.keys(pkg.peerDependencies || {})],
26
+ external: [
27
+ "prop-types",
28
+ "d3",
29
+ "@emotion/react",
30
+ "@emotion/styled",
31
+ ...Object.keys(pkg.peerDependencies || {}),
32
+ ],
25
33
  };
26
34
  export default config;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "MlCreatePdfButton",
3
- "title": "Sinmple Map print",
3
+ "title": "Export PDF",
4
4
  "description": "Creates a PDF file with the current map view.",
5
5
  "i18n": {
6
6
  "de": {
@@ -29,6 +29,7 @@ const MlFollowGps = (props) => {
29
29
  const initializedRef = useRef(false);
30
30
  const mapRef = useRef(undefined);
31
31
  const componentId = useRef((props.idPrefix ? props.idPrefix : "MlFollowGps-") + uuidv4());
32
+ const [accuracyRadius, setAccuracyRadius] = useState(30);
32
33
 
33
34
  useEffect(() => {
34
35
  let _componentId = componentId.current;
@@ -66,6 +67,7 @@ const MlFollowGps = (props) => {
66
67
  const getLocationSuccess = (pos) => {
67
68
  if (!mapRef.current) return;
68
69
  mapRef.current.setCenter([pos.coords.longitude, pos.coords.latitude]);
70
+ setAccuracyRadius(pos.coords.accuracy)
69
71
  setGeoJson(point([pos.coords.longitude, pos.coords.latitude]));
70
72
  };
71
73
 
@@ -79,7 +81,18 @@ const MlFollowGps = (props) => {
79
81
  {isFollowed && geoJson &&
80
82
  <MlGeoJsonLayer geojson={geoJson} type={"circle"}
81
83
  paint={{
82
- "circle-radius": 30,
84
+ "circle-radius": {
85
+ stops: [
86
+ [0, 0],
87
+ [
88
+ 20,
89
+ (accuracyRadius) /
90
+ 0.075 /
91
+ Math.cos((geoJson.geometry.coordinates[1] * Math.PI) / 180),
92
+ ],
93
+ ],
94
+ base: 2,
95
+ },
83
96
  "circle-color": "#ee7700",
84
97
  "circle-opacity": 0.5,
85
98
  }}
@@ -21,6 +21,7 @@ const MlGeoJsonLayer = (props) => {
21
21
  const mapRef = useRef(null);
22
22
  const initializedRef = useRef(false);
23
23
  const transitionInProgressRef = useRef(false);
24
+ const transitionTimeoutRef = useRef(undefined);
24
25
  const currentTransitionStepRef = useRef(false);
25
26
  const transitionGeojsonDataRef = useRef([]);
26
27
  const transitionGeojsonCommonDataRef = useRef([]);
@@ -33,7 +34,11 @@ const MlGeoJsonLayer = (props) => {
33
34
  let _componentId = componentId.current;
34
35
  return () => {
35
36
  // This is the cleanup function, it is called when this react component is removed from react-dom
37
+ if(transitionTimeoutRef.current){
38
+ clearTimeout(transitionTimeoutRef.current)
39
+ }
36
40
  if (mapRef.current) {
41
+
37
42
  mapRef.current.cleanup(_componentId);
38
43
 
39
44
  mapRef.current = null;
@@ -63,7 +68,8 @@ const MlGeoJsonLayer = (props) => {
63
68
  msPerStep,
64
69
  currentTransitionStepRef,
65
70
  mapRef.current,
66
- componentId.current
71
+ componentId.current,
72
+ transitionTimeoutRef
67
73
  );
68
74
  },
69
75
  [props]
@@ -153,9 +159,7 @@ const MlGeoJsonLayer = (props) => {
153
159
  typeof props.geojson.geometry !== "undefined"
154
160
  ) {
155
161
  transitionToGeojson(props.geojson);
156
- setTimeout(() => {
157
- oldGeojsonRef.current = props.geojson;
158
- }, props.transitionTime / 2);
162
+ oldGeojsonRef.current = props.geojson;
159
163
  }
160
164
  }
161
165
  }, [mapContext.mapIds, mapContext, props, transitionToGeojson]);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "MlGeoJsonLayer",
3
- "title": "GeoJSON level",
3
+ "title": "GeoJSON layer",
4
4
  "description": "",
5
5
  "i18n": {
6
6
  "de": {
@@ -8,13 +8,14 @@ const _showNextTransitionSegment = function (
8
8
  transitionGeojsonDataRef,
9
9
  transitionGeojsonCommonDataRef,
10
10
  currentTransitionStepRef,
11
- msPerStep
11
+ msPerStep,
12
+ transitionTimeoutRef
12
13
  ) {
13
14
  if (
14
15
  typeof map.getSource(layerId) === "undefined" ||
15
16
  !transitionInProgressRef.current
16
17
  ) {
17
- setTimeout(() => _showNextTransitionSegment(...arguments), msPerStep);
18
+ transitionTimeoutRef.current = setTimeout(() => _showNextTransitionSegment(...arguments), msPerStep);
18
19
  return;
19
20
  }
20
21
  if (
@@ -31,6 +32,10 @@ const _showNextTransitionSegment = function (
31
32
  .geometry.coordinates,
32
33
  ]);
33
34
 
35
+ if (!map?.getSource?.(layerId)) {
36
+ return;
37
+ }
38
+
34
39
  map.getSource(layerId).setData(newData);
35
40
 
36
41
  if (typeof props.onTransitionFrame === "function") {
@@ -42,7 +47,7 @@ const _showNextTransitionSegment = function (
42
47
  transitionInProgressRef.current &&
43
48
  currentTransitionStepRef.current < transitionGeojsonDataRef.current.length
44
49
  ) {
45
- setTimeout(() => _showNextTransitionSegment(...arguments), msPerStep);
50
+ transitionTimeoutRef.current = setTimeout(() => _showNextTransitionSegment(...arguments), msPerStep);
46
51
  } else {
47
52
  if (typeof props.onTransitionEnd === "function") {
48
53
  props.onTransitionEnd(props.geojson);
@@ -62,7 +67,8 @@ const _transitionToGeojson = (
62
67
  msPerStep,
63
68
  currentTransitionStepRef,
64
69
  map,
65
- layerId
70
+ layerId,
71
+ transitionTimeoutRef
66
72
  ) => {
67
73
  // create the transition geojson between oldGeojsonRef.current and props.geojson
68
74
 
@@ -189,12 +195,12 @@ const _transitionToGeojson = (
189
195
  );
190
196
  // for some reason turf.lineChunk returns the full lineString as element 0, chunks start at 1
191
197
  tmpLinestring = tmpChunks.features[1];
192
- for (i = 1; i < srcTransitionSteps; i++) {
198
+ for (i = 0; i < srcTransitionSteps; i++) {
193
199
  transitionGeojsonDataRef.current.push(tmpLinestring);
194
- if (typeof tmpChunks.features[i + 1] !== "undefined") {
200
+ if (typeof tmpChunks.features[i] !== "undefined") {
195
201
  tmpLinestring = turf.lineString([
196
202
  ...tmpLinestring.geometry.coordinates,
197
- ...tmpChunks.features[i + 1].geometry.coordinates,
203
+ ...tmpChunks.features[i].geometry.coordinates,
198
204
  ]);
199
205
  } else {
200
206
  transitionGeojsonDataRef.current.push(tmpLinestring);
@@ -212,12 +218,12 @@ const _transitionToGeojson = (
212
218
  );
213
219
  // for some reason turf.lineChunk returns the full lineString as element 0, chunks start at 1
214
220
  tmpLinestring = tmpChunks.features[1];
215
- for (i = 1; i < targetTransitionSteps; i++) {
221
+ for (i = 0; i < targetTransitionSteps; i++) {
216
222
  transitionGeojsonDataRef.current.push(tmpLinestring);
217
- if (typeof tmpChunks.features[i + 1] !== "undefined") {
223
+ if (typeof tmpChunks.features[i] !== "undefined") {
218
224
  tmpLinestring = turf.lineString([
219
225
  ...tmpLinestring.geometry.coordinates,
220
- ...tmpChunks.features[i + 1].geometry.coordinates,
226
+ ...tmpChunks.features[i].geometry.coordinates,
221
227
  ]);
222
228
  } else {
223
229
  transitionGeojsonDataRef.current.push(tmpLinestring);
@@ -229,7 +235,7 @@ const _transitionToGeojson = (
229
235
 
230
236
  currentTransitionStepRef.current = 1;
231
237
  transitionInProgressRef.current = true;
232
- setTimeout(
238
+ transitionTimeoutRef.current = setTimeout(
233
239
  () =>
234
240
  _showNextTransitionSegment(
235
241
  props,
@@ -239,7 +245,8 @@ const _transitionToGeojson = (
239
245
  transitionGeojsonDataRef,
240
246
  transitionGeojsonCommonDataRef,
241
247
  currentTransitionStepRef,
242
- msPerStep
248
+ msPerStep,
249
+ transitionTimeoutRef
243
250
  ),
244
251
  msPerStep
245
252
  );
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "MlVectorTileLayer",
3
- "title": "Vektor tiles",
4
- "description": "Component: Vector Tiles (add to the Application/map)",
3
+ "title": "Vector tile layer",
4
+ "description": "Adds a vector tile layer to the map",
5
5
  "i18n": {
6
6
  "de": {
7
7
  "title": "Vektorenkacheln",
8
8
  "description": "Baustein: Vektorenkacheln/Vector Tiles (der Anwendung/Karte hinzufügen)"
9
9
  }
10
10
  },
11
- "tags": [ "Map layer" ],
11
+ "tags": ["Map layer"],
12
12
  "category": "layer",
13
13
  "type": "component",
14
14
  "price": 5000
@@ -1,17 +1,12 @@
1
1
  import React from "react";
2
2
 
3
3
  import { MapComponentsProvider } from "@mapcomponents/react-core";
4
- import { LoadingOverlayProvider } from "../ui_components/LoadingOverlayContext";
5
- import LoadingOverlay from "../ui_components/LoadingOverlay";
6
4
  import "./style.css";
7
5
 
8
6
  const decorators = [
9
7
  (Story) => (
10
8
  <MapComponentsProvider>
11
- <LoadingOverlayProvider>
12
- <LoadingOverlay></LoadingOverlay>
13
9
  <Story />
14
- </LoadingOverlayProvider>
15
10
  </MapComponentsProvider>
16
11
  ),
17
12
  ];
@@ -2,16 +2,12 @@ import React from "react";
2
2
 
3
3
  import { MapComponentsProvider } from "@mapcomponents/react-core";
4
4
  import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
5
- import { LoadingOverlayProvider } from "../ui_components/LoadingOverlayContext";
6
- import LoadingOverlay from "../ui_components/LoadingOverlay";
7
5
  import "./style.css";
8
6
 
9
7
  const decorators = [
10
8
  (Story) => (
11
9
  <div className="fullscreen_map">
12
10
  <MapComponentsProvider>
13
- <LoadingOverlayProvider>
14
- <LoadingOverlay></LoadingOverlay>
15
11
 
16
12
  <Story />
17
13
  <MapLibreMap
@@ -22,7 +18,6 @@ const decorators = [
22
18
  }}
23
19
  mapId="map_1"
24
20
  />
25
- </LoadingOverlayProvider>
26
21
  </MapComponentsProvider>
27
22
  </div>
28
23
  ),
@@ -2,16 +2,12 @@ import React from "react";
2
2
 
3
3
  import { MapComponentsProvider } from "@mapcomponents/react-core";
4
4
  import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
5
- import { LoadingOverlayProvider } from "../ui_components/LoadingOverlayContext";
6
- import LoadingOverlay from "../ui_components/LoadingOverlay";
7
5
  import "./style.css";
8
6
 
9
7
  const decorators = [
10
8
  (Story) => (
11
9
  <div className="fullscreen_map">
12
10
  <MapComponentsProvider>
13
- <LoadingOverlayProvider>
14
- <LoadingOverlay></LoadingOverlay>
15
11
  <Story />
16
12
  <MapLibreMap
17
13
  options={{
@@ -31,7 +27,6 @@ const decorators = [
31
27
  // ],
32
28
  }}
33
29
  />
34
- </LoadingOverlayProvider>
35
30
  </MapComponentsProvider>
36
31
  </div>
37
32
  ),
@@ -1,8 +1,6 @@
1
1
  import React from "react";
2
2
 
3
3
  import { MapComponentsProvider } from "@mapcomponents/react-core";
4
- import { LoadingOverlayProvider } from "../ui_components/LoadingOverlayContext";
5
- import LoadingOverlay from "../ui_components/LoadingOverlay";
6
4
 
7
5
  import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
8
6
 
@@ -17,8 +15,6 @@ const decorators = [
17
15
  <div className="fullscreen_map">
18
16
  <ThemeProvider theme={theme}>
19
17
  <MapComponentsProvider>
20
- <LoadingOverlayProvider>
21
- <LoadingOverlay></LoadingOverlay>
22
18
  <div
23
19
  style={{
24
20
  overflow: "hidden",
@@ -69,7 +65,6 @@ const decorators = [
69
65
  />
70
66
  </div>
71
67
  </div>
72
- </LoadingOverlayProvider>
73
68
  </MapComponentsProvider>
74
69
  </ThemeProvider>
75
70
  </div>
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { useEffect } from "react";
2
2
 
3
3
  import useMapState from "./useMapState";
4
4
 
@@ -15,6 +15,11 @@ export default storyoptions;
15
15
  const Template = (props) => {
16
16
  const mapState = useMapState({ ...props });
17
17
 
18
+ useEffect(() => {
19
+
20
+
21
+ }, [mapState.layers])
22
+
18
23
  return (
19
24
  <>
20
25
  <div
@@ -110,6 +115,6 @@ NonBaseLayersOnly.args = {
110
115
  sources: false,
111
116
  },
112
117
  filter: {
113
- includeBaseLayers: true,
118
+ includeBaseLayers: false,
114
119
  },
115
120
  };
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import makeStyles from "@mui/styles/makeStyles";
3
3
  import Drawer from "@mui/material/Drawer";
4
+ import { InsertInvitationOutlined } from "@mui/icons-material";
4
5
 
5
6
  const useStyles = makeStyles((theme) => ({
6
7
  drawer: {
@@ -11,16 +12,14 @@ const useStyles = makeStyles((theme) => ({
11
12
  left: 0,
12
13
  bottom: 0,
13
14
  backgroundColor: "#fafafa",
14
- },
15
- drawerPaper: {
16
- position: "static",
17
15
  display: "flex",
18
- alignItems: "stretch",
19
- alignContent: "stretch",
20
16
  flexDirection: "column",
21
- padding: "90px 10px 10px 23px",
22
- boxSizing: "border-box",
23
- minWidth: "150px",
17
+ alignContent: "stretch",
18
+ alignItems: "stretch",
19
+ },
20
+ drawerPaper: {
21
+ position: "initial",
22
+ padding: "20px",
24
23
  },
25
24
  }));
26
25