@mapcomponents/react-maplibre 0.1.12 → 0.1.13

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 (120) hide show
  1. package/coverage/clover.xml +727 -608
  2. package/coverage/coverage-final.json +19 -14
  3. package/coverage/lcov-report/index.html +156 -96
  4. package/coverage/lcov-report/{components → src/components}/MapLibreMap/MapLibreMap.js.html +10 -10
  5. package/coverage/lcov-report/{components → src/components}/MapLibreMap/index.html +10 -10
  6. package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/MlCreatePdfButton.js.html +10 -10
  7. package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/index.html +10 -10
  8. package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/MlFeatureEditor.js.html +10 -10
  9. package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/index.html +10 -10
  10. package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +10 -10
  11. package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/index.html +10 -10
  12. package/coverage/lcov-report/{components → src/components}/MlFollowGps/MlFollowGps.js.html +61 -55
  13. package/coverage/lcov-report/{components → src/components}/MlFollowGps/index.html +10 -10
  14. package/coverage/lcov-report/{components → src/components}/MlGPXViewer/MlGPXViewer.js.html +66 -60
  15. package/coverage/lcov-report/{components → src/components}/MlGPXViewer/gpxConverter.js.html +49 -70
  16. package/coverage/lcov-report/{components → src/components}/MlGPXViewer/index.html +25 -25
  17. package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/MlGeoJsonLayer.js.html +70 -28
  18. package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/index.html +27 -27
  19. package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/MlImageMarkerLayer.js.html +19 -22
  20. package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/index.html +19 -19
  21. package/coverage/lcov-report/{components → src/components}/MlLayer/MlLayer.js.html +30 -30
  22. package/coverage/lcov-report/{components → src/components}/MlLayer/index.html +26 -26
  23. package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/MlLayerMagnify.js.html +41 -41
  24. package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/index.html +24 -24
  25. package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/MlLayerSwipe.js.html +38 -41
  26. package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/index.html +24 -24
  27. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +755 -0
  28. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +380 -0
  29. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +117 -0
  30. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +117 -0
  31. package/coverage/lcov-report/{components → src/components}/MlMarker/MlMarker.js.html +11 -11
  32. package/coverage/lcov-report/{components → src/components}/MlMarker/index.html +10 -10
  33. package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/MlNavigationCompass.js.html +10 -10
  34. package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/index.html +10 -10
  35. package/coverage/lcov-report/{components → src/components}/MlNavigationTools/MlNavigationTools.js.html +48 -36
  36. package/coverage/lcov-report/{components → src/components}/MlNavigationTools/index.html +16 -16
  37. package/coverage/lcov-report/{components → src/components}/MlOsmLayer/MlOsmLayer.js.html +10 -10
  38. package/coverage/lcov-report/{components → src/components}/MlOsmLayer/index.html +10 -10
  39. package/coverage/lcov-report/{components → src/components}/MlScaleReference/MlScaleReference.js.html +10 -10
  40. package/coverage/lcov-report/{components → src/components}/MlScaleReference/index.html +10 -10
  41. package/coverage/lcov-report/{components → src/components}/MlShareMapState/MlShareMapState.js.html +10 -10
  42. package/coverage/lcov-report/{components → src/components}/MlShareMapState/index.html +10 -10
  43. package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +10 -10
  44. package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/index.html +10 -10
  45. package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/MlThreeJsLayer.js.html +30 -54
  46. package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/index.html +24 -24
  47. package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/MlUseMapDebugger.js.html +10 -10
  48. package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/index.html +10 -10
  49. package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/MlVectorTileLayer.js.html +10 -10
  50. package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/index.html +10 -10
  51. package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +10 -10
  52. package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/index.html +10 -10
  53. package/coverage/lcov-report/{components → src/components}/MlWmsLayer/MlWmsLayer.js.html +13 -13
  54. package/coverage/lcov-report/{components → src/components}/MlWmsLayer/index.html +14 -14
  55. package/coverage/lcov-report/{components → src/components}/MlWmsLoader/MlWmsLoader.js.html +31 -19
  56. package/coverage/lcov-report/{components → src/components}/MlWmsLoader/index.html +16 -16
  57. package/coverage/lcov-report/{hooks → src/hooks}/index.html +10 -10
  58. package/coverage/lcov-report/{hooks → src/hooks}/useMap.js.html +10 -10
  59. package/coverage/lcov-report/{hooks → src/hooks}/useMapState.js.html +10 -10
  60. package/coverage/lcov-report/{hooks → src/hooks}/useWms.js.html +18 -18
  61. package/coverage/lcov-report/src/i18n.js.html +167 -0
  62. package/coverage/lcov-report/src/index.html +117 -0
  63. package/coverage/lcov-report/src/translations/english.js.html +95 -0
  64. package/coverage/lcov-report/src/translations/german.js.html +95 -0
  65. package/coverage/lcov-report/src/translations/index.html +132 -0
  66. package/coverage/lcov.info +1240 -976
  67. package/dist/b556faa3bc6829d2.png +0 -0
  68. package/dist/index.esm.js +102 -71
  69. package/dist/index.esm.js.map +1 -1
  70. package/package.json +3 -1
  71. package/public/assets/dop.png +0 -0
  72. package/public/assets/historic.png +0 -0
  73. package/public/assets/osm.png +0 -0
  74. package/public/thumbnails/MlFollowGps.png +0 -0
  75. package/public/thumbnails/MlThreeJsLayer.png +0 -0
  76. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +58 -73
  77. package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -2
  78. package/src/components/MlFollowGps/MlFollowGps.js +45 -43
  79. package/src/components/MlFollowGps/MlFollowGps.meta.json +2 -2
  80. package/src/components/MlFollowGps/assets/marker.png +0 -0
  81. package/src/components/MlGPXViewer/MlGPXViewer.js +45 -43
  82. package/src/components/MlGPXViewer/gpxConverter.js +22 -29
  83. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +22 -8
  84. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +3 -4
  85. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +6 -7
  86. package/src/components/MlLayer/MlLayer.js +2 -2
  87. package/src/components/MlLayer/MlLayer.test.js +12 -10
  88. package/src/components/MlLayerMagnify/MlLayerMagnify.js +3 -3
  89. package/src/components/MlLayerSwipe/MlLayerSwipe.js +4 -5
  90. package/src/components/MlLayerSwitcher/MlLayerSwitcher.css +17 -0
  91. package/src/components/MlLayerSwitcher/MlLayerSwitcher.doc.de.md +3 -0
  92. package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +223 -0
  93. package/src/components/MlLayerSwitcher/MlLayerSwitcher.meta_.json +15 -0
  94. package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +106 -0
  95. package/src/components/MlLayerSwitcher/assets/sample_1.json +26 -0
  96. package/src/components/MlLayerSwitcher/assets/sample_2.json +22 -0
  97. package/src/components/MlLayerSwitcher/components/LayerBox.js +98 -0
  98. package/src/components/MlMarker/MlMarker.js +1 -1
  99. package/src/components/MlNavigationTools/MlNavigationTools.js +26 -22
  100. package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -1
  101. package/src/components/MlScaleReference/MlScaleReference.stories.js +25 -21
  102. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +12 -6
  103. package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +8 -15
  104. package/src/components/MlWmsLayer/MlWmsLayer.js +1 -1
  105. package/src/components/MlWmsLoader/MlWmsLoader.js +8 -4
  106. package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -1
  107. package/src/components/MlWmsLoader/MlWmsLoader.stories.js +5 -4
  108. package/src/decorators/EmptyMapContextDecorator.js +11 -6
  109. package/src/decorators/MapContext3DDecorator.js +25 -20
  110. package/src/decorators/MapContextDashboardDecorator.js +7 -2
  111. package/src/decorators/MapContextDecorator.js +7 -3
  112. package/src/decorators/MapContextKlokantechBasicDecorator.js +8 -4
  113. package/src/decorators/MultiMapContextDecorator.js +2 -1
  114. package/src/hooks/useWms.js +7 -6
  115. package/src/i18n.js +28 -0
  116. package/src/translations/english.js +4 -0
  117. package/src/translations/german.js +4 -0
  118. package/src/ui_components/ImageLoader.js +73 -0
  119. package/src/ui_components/Sidebar.js +75 -20
  120. package/src/ui_components/TopToolbar.js +18 -18
@@ -4,12 +4,13 @@ import { MapComponentsProvider } from "@mapcomponents/react-core";
4
4
 
5
5
  import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
6
6
 
7
- import { createTheme, ThemeProvider } from "@mui/material/styles";
8
7
 
9
8
  import "./style.css";
9
+ import { createTheme, ThemeProvider } from "@mui/material/styles";
10
10
 
11
11
  const theme = createTheme({});
12
12
 
13
+
13
14
  const decorators = [
14
15
  (Story) => (
15
16
  <div className="fullscreen_map">
@@ -25,12 +25,13 @@ function useWms(props) {
25
25
  // extract URL parameters from the given URL
26
26
  clearState();
27
27
  setError(undefined);
28
- if (!props.url) return;
28
+
29
+ if (!url) return;
29
30
 
30
31
  let _propsUrlParams;
31
- let _wmsUrl = props.url;
32
- if (props.url.indexOf("?") !== -1) {
33
- _propsUrlParams = props.url.split("?");
32
+ let _wmsUrl = url;
33
+ if (url.indexOf("?") !== -1) {
34
+ _propsUrlParams = url.split("?");
34
35
  _wmsUrl = _propsUrlParams[0];
35
36
  }
36
37
  let _urlParamsFromUrl = new URLSearchParams(_propsUrlParams?.[1]);
@@ -62,7 +63,7 @@ function useWms(props) {
62
63
  console.log(error);
63
64
  setError(error.message);
64
65
  });
65
- }, [props.url, props.urlParameters]);
66
+ }, [url, props.urlParameters]);
66
67
 
67
68
  useEffect(() => {
68
69
  if (!capabilities?.Service) return;
@@ -92,4 +93,4 @@ useWms.defaultProps = {
92
93
  },
93
94
  };
94
95
 
95
- export default useWms;
96
+ export default useWms;
package/src/i18n.js ADDED
@@ -0,0 +1,28 @@
1
+ import i18n from "i18next";
2
+ import { initReactI18next } from "react-i18next";
3
+ import english from "./translations/english.js"
4
+ import german from "./translations/german.js"
5
+
6
+
7
+ // the translations
8
+ // (tip move them in a JSON file and import them,
9
+ // or even better, manage them separated from your code: https://react.i18next.com/guides/multiple-translation-files)
10
+ const resources = { ...english, ...german };
11
+
12
+
13
+ i18n
14
+ .use(initReactI18next) // passes i18n down to react-i18next
15
+ .init({
16
+ resources,
17
+ lng: "de", // language to use, more information here: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources
18
+ // you can use the i18n.changeLanguage function to change the language manually: https://www.i18next.com/overview/api#changelanguage
19
+ // if you're using a language detector, do not define the lng option
20
+
21
+ interpolation: {
22
+ escapeValue: false // react already safes from xss
23
+ }
24
+ });
25
+
26
+
27
+
28
+ export default i18n;
@@ -0,0 +1,4 @@
1
+ const english = {
2
+ "en": { "Layer": "Layer" }
3
+ }
4
+ export default english;
@@ -0,0 +1,4 @@
1
+ const german = {
2
+ "de": { "Layer": "Ebene" }
3
+ }
4
+ export default german;
@@ -0,0 +1,73 @@
1
+
2
+ import { useEffect, useState } from "react"
3
+ import CircularProgress from '@mui/material/CircularProgress';
4
+
5
+ import ErrorIcon from '@mui/icons-material/Error';
6
+ import { Box } from "@mui/system";
7
+ const ImageLoader = (props) => {
8
+ const [state, setState] = useState("loading");
9
+
10
+ useEffect(() => {
11
+ if (!props.src) {
12
+ setState("error");
13
+ return;
14
+ }
15
+ fetch(props.src)
16
+ .then(({ ok }) => {
17
+ if (ok) {
18
+ setState("ready");
19
+ } else {
20
+ setState("error");
21
+ }
22
+ })
23
+ .catch((e) => {
24
+ console.error(e);
25
+ setState("error");
26
+ });
27
+ }, [props.src]);
28
+
29
+ const boxStyle = {
30
+ width: "100%",
31
+ height: "100%",
32
+ border: 2,
33
+ borderRadius: "8px",
34
+ textAlign: "center",
35
+ display: "flex",
36
+ };
37
+
38
+ const LoadingImage = () => {
39
+ return (
40
+ <Box className={props.className} sx={{ ...boxStyle, ...props.style }}>
41
+ <CircularProgress />
42
+ </Box>
43
+ );
44
+ };
45
+
46
+ const ReadyImage = () => {
47
+ return (
48
+ <img className={props.className} style={{ ...boxStyle, ...props.style }} src={props.src} />
49
+ );
50
+ };
51
+ const ErrorImage = () => {
52
+ return (
53
+ <Box className={props.className} sx={{ boxStyle, ...props.style }}>
54
+ <ErrorIcon sx={{ display: "block", margin: "auto" }} />
55
+ </Box>
56
+ );
57
+ };
58
+
59
+ const renderImage = (state) => {
60
+ switch (state) {
61
+ case "ready":
62
+ return <ReadyImage />;
63
+ case "error":
64
+ return <ErrorImage />;
65
+ }
66
+
67
+ return <LoadingImage />;
68
+ };
69
+
70
+ return <>{renderImage(state)}</>;
71
+ };
72
+
73
+ export default ImageLoader
@@ -1,12 +1,16 @@
1
- import React from "react";
1
+ import React, {useState} from "react";
2
+ import { useTheme, styled } from "@mui/material/styles";
2
3
  import makeStyles from "@mui/styles/makeStyles";
3
4
  import Drawer from "@mui/material/Drawer";
4
- import { InsertInvitationOutlined } from "@mui/icons-material";
5
+ import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
6
+ import MenuIcon from '@mui/icons-material/Menu';
7
+ import { IconButton } from "@mui/material";
8
+ import useMediaQuery from "@mui/material/useMediaQuery";
5
9
 
6
10
  const useStyles = makeStyles((theme) => ({
7
11
  drawer: {
8
12
  flexGrow: 1,
9
- zIndex: 101,
13
+ zIndex: 105,
10
14
  position: "absolute",
11
15
  top: 0,
12
16
  left: 0,
@@ -14,32 +18,83 @@ const useStyles = makeStyles((theme) => ({
14
18
  backgroundColor: "#fafafa",
15
19
  display: "flex",
16
20
  flexDirection: "column",
17
- alignContent: "stretch",
18
21
  alignItems: "stretch",
22
+ alignContent: "stretch",
19
23
  },
20
24
  drawerPaper: {
21
- position: "initial",
22
- padding: "20px",
25
+ position: "initial !important",
26
+ boxSizing: "border-box",
27
+ padding: "40px",
28
+ visibility: "visible !important",
29
+ zIndex: "initial !important",
30
+ },
31
+ drawerHeader: {
32
+ alignContent: "flex-start",
33
+ display: "flex",
23
34
  },
35
+ drawerContent: {},
36
+ }));
37
+
38
+ const DrawerHeader = styled("div")(({ theme }) => ({
39
+ display: "flex",
40
+ alignItems: "center",
24
41
  }));
25
42
 
26
43
  export default function Sidebar(props) {
27
44
  const classes = useStyles();
45
+ const mediaIsMobile = useMediaQuery("(max-width:900px)");
46
+
47
+ const [drawerOpen, setDrawerOpen] = useState(true);
48
+
49
+ const handleDrawerOpen = () => {
50
+ setDrawerOpen(true);
51
+ };
52
+ const handleDrawerClose = () => {
53
+ setDrawerOpen(false);
54
+ };
28
55
 
29
56
  return (
30
- <Drawer
31
- className={classes.drawer}
32
- variant="persistent"
33
- anchor="left"
34
- open={true}
35
- classes={{
36
- paper: classes.drawerPaper,
37
- }}
38
- sx={{
39
- ...props.sx,
40
- }}
41
- >
42
- {props.children}
43
- </Drawer>
57
+ <>
58
+ <IconButton
59
+ onClick={handleDrawerOpen}
60
+ style={{
61
+ zIndex: 101,
62
+ position: "relative",
63
+ padding: "20px",
64
+ }}
65
+ >
66
+ <MenuIcon />
67
+ </IconButton>
68
+ <Drawer
69
+ transitionDuration={0}
70
+ className={classes.drawer}
71
+ variant="persistent"
72
+ anchor="left"
73
+ open={drawerOpen}
74
+ classes={{
75
+ paper: classes.drawerPaper,
76
+ }}
77
+ sx={{
78
+ ...props.sx,
79
+ ...{
80
+ maxWidth: mediaIsMobile ? "90vw" : "20vw",
81
+ },
82
+ ...(drawerOpen ? {} : { left: mediaIsMobile ? "-90vw" : "-20vw" }),
83
+ }}
84
+ >
85
+ <DrawerHeader className={classes.drawerHeader}>
86
+ <IconButton onClick={handleDrawerClose}>
87
+ <ChevronLeftIcon
88
+ style={
89
+ {
90
+ //paddingBottom: "40px",
91
+ }
92
+ }
93
+ />
94
+ </IconButton>
95
+ </DrawerHeader>
96
+ <div style={{ maxWidth: "100%" }}>{props.children}</div>
97
+ </Drawer>
98
+ </>
44
99
  );
45
100
  }
@@ -3,27 +3,27 @@ import makeStyles from "@mui/styles/makeStyles";
3
3
  import AppBar from "@mui/material/AppBar";
4
4
  import Toolbar from "@mui/material/Toolbar";
5
5
 
6
- const useStyles = makeStyles((theme) => ({
7
- root: {
8
- flexGrow: 1,
9
- zIndex: 120,
10
- position: "absolute",
11
- top: 0,
12
- left: 0,
13
- right: 0,
14
- },
15
- AppBar: {
16
- backgroundColor: "#fafafa",
17
- minHeight: "62px",
18
- },
19
- }));
20
6
 
21
7
  export default function TopToolbar(props) {
22
- const classes = useStyles();
23
-
24
8
  return (
25
- <div className={classes.root}>
26
- <AppBar className={classes.AppBar} position="static">
9
+ <div
10
+ style={{
11
+ flexGrow: 1,
12
+ zIndex: 120,
13
+ position: "absolute",
14
+ top: 0,
15
+ left: 0,
16
+ right: 0,
17
+ }}
18
+ >
19
+ <AppBar
20
+ sx={{
21
+ minHeight: "62px",
22
+ backgroundColor: "#f1f1f1",
23
+ }}
24
+ color="primary"
25
+ position="static"
26
+ >
27
27
  <Toolbar>{props.children}</Toolbar>
28
28
  </AppBar>
29
29
  </div>