@mapcomponents/react-maplibre 0.1.16 → 0.1.20

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 (92) hide show
  1. package/CHANGELOG.md +16 -7
  2. package/coverage/clover.xml +259 -285
  3. package/coverage/coverage-final.json +10 -10
  4. package/coverage/lcov-report/index.html +42 -43
  5. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.js.html +2 -3
  6. package/coverage/lcov-report/src/components/MapLibreMap/index.html +2 -3
  7. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.js.html +2 -3
  8. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +2 -3
  9. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.js.html +2 -3
  10. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +2 -3
  11. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +2 -3
  12. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +2 -3
  13. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.js.html +2 -3
  14. package/coverage/lcov-report/src/components/MlFollowGps/index.html +2 -3
  15. package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.js.html +2 -3
  16. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +2 -3
  17. package/coverage/lcov-report/src/components/MlGPXViewer/index.html +2 -3
  18. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js.html +145 -161
  19. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +16 -17
  20. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +2 -3
  21. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +2 -3
  22. package/coverage/lcov-report/src/components/MlLayer/MlLayer.js.html +9 -13
  23. package/coverage/lcov-report/src/components/MlLayer/index.html +16 -17
  24. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.js.html +2 -3
  25. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +2 -3
  26. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.js.html +2 -3
  27. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +2 -3
  28. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +3 -10
  29. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +9 -82
  30. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +10 -11
  31. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +2 -3
  32. package/coverage/lcov-report/src/components/MlMarker/MlMarker.js.html +6 -7
  33. package/coverage/lcov-report/src/components/MlMarker/index.html +6 -7
  34. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.js.html +2 -3
  35. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +2 -3
  36. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.js.html +2 -3
  37. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +2 -3
  38. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +2 -3
  39. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +2 -3
  40. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +2 -3
  41. package/coverage/lcov-report/src/components/MlScaleReference/index.html +2 -3
  42. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +2 -3
  43. package/coverage/lcov-report/src/components/MlShareMapState/index.html +2 -3
  44. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +2 -3
  45. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +2 -3
  46. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +2 -3
  47. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +2 -3
  48. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +6 -25
  49. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +6 -7
  50. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.js.html +3 -4
  51. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +2 -3
  52. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +2 -3
  53. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +2 -3
  54. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.js.html +2 -3
  55. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +2 -3
  56. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.js.html +6 -19
  57. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +8 -9
  58. package/coverage/lcov-report/src/hooks/index.html +14 -15
  59. package/coverage/lcov-report/src/hooks/useMap.js.html +23 -24
  60. package/coverage/lcov-report/src/hooks/useMapState.js.html +7 -50
  61. package/coverage/lcov-report/src/hooks/useWms.js.html +9 -22
  62. package/coverage/lcov-report/src/i18n.js.html +2 -3
  63. package/coverage/lcov-report/src/index.html +2 -3
  64. package/coverage/lcov-report/src/translations/english.js.html +2 -3
  65. package/coverage/lcov-report/src/translations/german.js.html +2 -3
  66. package/coverage/lcov-report/src/translations/index.html +2 -3
  67. package/coverage/lcov.info +490 -524
  68. package/dist/index.esm.js +165 -153
  69. package/dist/index.esm.js.map +1 -1
  70. package/package.json +2 -2
  71. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +3 -2
  72. package/src/components/MlComponentTemplate/MlComponentTemplate.js +3 -3
  73. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +104 -109
  74. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +35 -6
  75. package/src/components/MlGeoJsonLayer/assets/sample_polygon_1.json +33 -0
  76. package/src/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.js +25 -0
  77. package/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.js +31 -0
  78. package/src/components/MlLayer/MlLayer.js +0 -1
  79. package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +0 -2
  80. package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +3 -6
  81. package/src/components/MlLayerSwitcher/components/LayerBox.js +2 -26
  82. package/src/components/MlMarker/MlMarker.js +1 -1
  83. package/src/components/MlShareMapState/MlShareMapState.stories.js +14 -17
  84. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +1 -3
  85. package/src/components/MlUseMapDebugger/MlUseMapDebugger.js +1 -7
  86. package/src/components/MlVectorTileLayer/MlVectorTileLayer.js +1 -1
  87. package/src/components/MlWmsLoader/MlWmsLoader.js +0 -4
  88. package/src/hooks/useMapState.js +0 -14
  89. package/src/hooks/useWms.js +2 -7
  90. package/src/ui_components/ImageLoader.js +8 -3
  91. package/src/ui_components/Sidebar.js +1 -1
  92. package/src/ui_components/TopToolbar.js +0 -2
@@ -2,7 +2,6 @@ import React, { useState} from "react";
2
2
 
3
3
  import MlShareMapState from "./MlShareMapState";
4
4
  import mapContextDecorator from "../../decorators/MapContextDecorator";
5
- import useMapState from "../../hooks/useMapState";
6
5
  import MlLayer from "../MlLayer/MlLayer";
7
6
 
8
7
  const storyoptions = {
@@ -16,17 +15,6 @@ export default storyoptions;
16
15
  const Template = (args) => {
17
16
  const [watchState, setWatchState] = useState(false);
18
17
  const [testLayerVisible, setTestLayerVisible] = useState(true);
19
- const mapState = useMapState({
20
- watch : {
21
- viewport : false,
22
- layers : true,
23
- sources : false
24
- },
25
- filter : {
26
- includeBaseLayers : false
27
- }
28
- }
29
- )
30
18
 
31
19
  return (
32
20
  <>
@@ -34,18 +22,27 @@ const Template = (args) => {
34
22
  style={{ zIndex: "1000", position: "absolute" }}
35
23
  onClick={() => setWatchState(!watchState)}
36
24
  >
37
- watch map state {watchState?1:0}
25
+ watch map state {watchState ? 1 : 0}
38
26
  </button>
39
27
  <button
40
28
  style={{ zIndex: "1000", position: "absolute" }}
41
29
  onClick={() => setTestLayerVisible(!testLayerVisible)}
42
30
  >
43
- visibility {testLayerVisible?1:0}
31
+ visibility {testLayerVisible ? 1 : 0}
44
32
  </button>
45
33
  <MlShareMapState active={watchState} />
46
- <MlLayer layerId={"MlLayer-testLayer"} options={{layout: {visibility: (testLayerVisible ? "visible":"none")}}} />
47
- <MlLayer layerId={"MlLayer-testLayer2"} options={{layout: {visibility: (testLayerVisible ? "visible":"none")}}} />
48
- <MlLayer layerId={"MlLayer-testLayer3"} options={{layout: {visibility: (testLayerVisible ? "visible":"none")}}} />
34
+ <MlLayer
35
+ layerId={"MlLayer-testLayer"}
36
+ options={{ layout: { visibility: testLayerVisible ? "visible" : "none" } }}
37
+ />
38
+ <MlLayer
39
+ layerId={"MlLayer-testLayer2"}
40
+ options={{ layout: { visibility: testLayerVisible ? "visible" : "none" } }}
41
+ />
42
+ <MlLayer
43
+ layerId={"MlLayer-testLayer3"}
44
+ options={{ layout: { visibility: testLayerVisible ? "visible" : "none" } }}
45
+ />
49
46
  </>
50
47
  );
51
48
  };
@@ -5,9 +5,7 @@ import MlGPXViewer from "../MlGPXViewer/MlGPXViewer";
5
5
 
6
6
  import mapContextDecorator from "../../decorators/MapContextDecorator";
7
7
  import GeoJsonProvider from "../MlGPXViewer/util/GeoJsonProvider";
8
- import Button from "@mui/material/Button";
9
- import FileDownloadIcon from '@mui/icons-material/FileDownload';
10
- import InfoIcon from "@mui/icons-material/Info";
8
+ import FileDownloadIcon from "@mui/icons-material/FileDownload";
11
9
  import IconButton from "@mui/material/IconButton";
12
10
  import useMediaQuery from "@mui/material/useMediaQuery";
13
11
 
@@ -1,11 +1,7 @@
1
- import React, { useRef, useState } from "react";
1
+ import React, { useRef } from "react";
2
2
  import PropTypes from "prop-types";
3
3
 
4
- import { Drawer, IconButton } from "@mui/material";
5
- import CodeIcon from "@mui/icons-material/Code";
6
-
7
4
  import useMapState from "../../hooks/useMapState";
8
- import { render } from "@testing-library/react";
9
5
 
10
6
  /**
11
7
  * Renders a collapsable top-drawer containing live map debug information
@@ -30,8 +26,6 @@ const MlUseMapDebugger = (props) => {
30
26
  });
31
27
  const renderCounter = useRef(0);
32
28
  renderCounter.current = renderCounter.current + 1;
33
- const [debuggerOpen, setDebuggerOpen] = useState(true);
34
- //const [maxHeight /*setMaxHeight*/] = useState("50%");
35
29
 
36
30
  return (
37
31
  <>
@@ -48,7 +48,7 @@ const MlVectorTileLayer = (props) => {
48
48
  tiles: [props.url],
49
49
  tileSize: 512,
50
50
  attribution: "",
51
- //...props.sourceOptions,
51
+ ...props.sourceOptions,
52
52
  });
53
53
 
54
54
  for (let key in props.layers) {
@@ -155,10 +155,6 @@ const MlWmsLoader = (props) => {
155
155
  };
156
156
  }, [getFeatureInfoUrl]);
157
157
 
158
- const clearState = () => {
159
- setLayers([]);
160
- };
161
-
162
158
  useEffect(() => {
163
159
  if (!capabilities?.Service) return;
164
160
 
@@ -15,8 +15,6 @@ function useMapState(props) {
15
15
  const initializedRef = useRef(false);
16
16
  const mapRef = useRef(undefined);
17
17
 
18
- const [center, setCenter] = useState(undefined);
19
-
20
18
  const [viewport, setViewport] = useState(undefined);
21
19
  const viewportRef = useRef(undefined);
22
20
 
@@ -25,7 +23,6 @@ function useMapState(props) {
25
23
  //const mapRef = useRef(props.map);
26
24
  const componentId = useRef(uuidv4());
27
25
 
28
-
29
26
  /**
30
27
  * returns the element if it matches the defined filter criteria
31
28
  * to be used as filter function on the layers array
@@ -79,16 +76,6 @@ function useMapState(props) {
79
76
  initializedRef.current = true;
80
77
  mapRef.current = mapContext.getMap(props.mapId);
81
78
 
82
- /*
83
- mapRef.current.on(
84
- "move",
85
- () => {
86
- setCenter(mapRef.current.getCenter());
87
- },
88
- componentId.current
89
- );
90
- */
91
-
92
79
  if (props?.watch?.viewport) {
93
80
  setViewport(mapRef.current.wrapper.viewportState);
94
81
 
@@ -97,7 +84,6 @@ function useMapState(props) {
97
84
  () => {
98
85
  if (viewportRef.current !== mapRef.current?.wrapper.viewportStateString) {
99
86
  setViewport(mapRef.current?.wrapper.viewportState);
100
- setCenter(mapRef.current?.wrapper.viewportState?.center);
101
87
  }
102
88
  },
103
89
  componentId.current
@@ -1,13 +1,8 @@
1
- import { useContext, useState, useEffect, useRef } from "react";
2
- import { v4 as uuidv4 } from "uuid";
1
+ import { useState, useEffect } from "react";
3
2
  import WMSCapabilities from "wms-capabilities";
4
- import { MapContext } from "@mapcomponents/react-core";
5
3
 
6
4
  function useWms(props) {
7
5
  // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
8
- const mapContext = useContext(MapContext);
9
- const initializedRef = useRef(false);
10
-
11
6
  const [getFeatureInfoUrl, setGetFeatureInfoUrl] = useState(undefined);
12
7
  const [url, setUrl] = useState(props.url);
13
8
  const [wmsUrl, setWmsUrl] = useState("");
@@ -93,4 +88,4 @@ useWms.defaultProps = {
93
88
  },
94
89
  };
95
90
 
96
- export default useWms;
91
+ export default useWms;
@@ -45,7 +45,12 @@ const ImageLoader = (props) => {
45
45
 
46
46
  const ReadyImage = () => {
47
47
  return (
48
- <img className={props.className} style={{ ...boxStyle, ...props.style }} src={props.src} />
48
+ <img
49
+ className={props.className}
50
+ style={{ ...boxStyle, ...props.style }}
51
+ src={props.src}
52
+ alt={props.alt || ""}
53
+ />
49
54
  );
50
55
  };
51
56
  const ErrorImage = () => {
@@ -62,9 +67,9 @@ const ImageLoader = (props) => {
62
67
  return <ReadyImage />;
63
68
  case "error":
64
69
  return <ErrorImage />;
70
+ default:
71
+ return <LoadingImage />;
65
72
  }
66
-
67
- return <LoadingImage />;
68
73
  };
69
74
 
70
75
  return <>{renderImage(state)}</>;
@@ -1,5 +1,5 @@
1
1
  import React, {useState} from "react";
2
- import { useTheme, styled } from "@mui/material/styles";
2
+ import { styled } from "@mui/material/styles";
3
3
  import makeStyles from "@mui/styles/makeStyles";
4
4
  import Drawer from "@mui/material/Drawer";
5
5
  import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
@@ -1,9 +1,7 @@
1
1
  import React from "react";
2
- import makeStyles from "@mui/styles/makeStyles";
3
2
  import AppBar from "@mui/material/AppBar";
4
3
  import Toolbar from "@mui/material/Toolbar";
5
4
 
6
-
7
5
  export default function TopToolbar(props) {
8
6
  return (
9
7
  <div