@mapcomponents/react-maplibre 0.1.11 → 0.1.15

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 (135) hide show
  1. package/.github/workflows/storybook.yml +10 -5
  2. package/coverage/clover.xml +894 -747
  3. package/coverage/coverage-final.json +22 -17
  4. package/coverage/lcov-report/block-navigation.js +8 -0
  5. package/coverage/lcov-report/index.html +188 -122
  6. package/coverage/lcov-report/sorter.js +26 -0
  7. package/coverage/lcov-report/{components → src/components}/MapLibreMap/MapLibreMap.js.html +17 -11
  8. package/coverage/lcov-report/{components → src/components}/MapLibreMap/index.html +17 -11
  9. package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/MlCreatePdfButton.js.html +17 -11
  10. package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/index.html +17 -11
  11. package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/MlFeatureEditor.js.html +17 -11
  12. package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/index.html +17 -11
  13. package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +17 -11
  14. package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/index.html +17 -11
  15. package/coverage/lcov-report/{components → src/components}/MlFollowGps/MlFollowGps.js.html +84 -69
  16. package/coverage/lcov-report/{components → src/components}/MlFollowGps/index.html +27 -21
  17. package/coverage/lcov-report/{components → src/components}/MlGPXViewer/MlGPXViewer.js.html +73 -61
  18. package/coverage/lcov-report/{components → src/components}/MlGPXViewer/gpxConverter.js.html +56 -71
  19. package/coverage/lcov-report/{components → src/components}/MlGPXViewer/index.html +32 -26
  20. package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/MlGeoJsonLayer.js.html +162 -48
  21. package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/index.html +35 -29
  22. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +311 -0
  23. package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/index.html +35 -29
  24. package/coverage/lcov-report/{components/MlImageMarkerLayer/MlImageMarkerLayer.js.html → src/components/MlLayer/MlLayer.js.html} +123 -126
  25. package/coverage/lcov-report/src/components/MlLayer/index.html +117 -0
  26. package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/MlLayerMagnify.js.html +48 -42
  27. package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/index.html +31 -25
  28. package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/MlLayerSwipe.js.html +45 -42
  29. package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/index.html +31 -25
  30. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +755 -0
  31. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +380 -0
  32. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +117 -0
  33. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +117 -0
  34. package/coverage/lcov-report/{components → src/components}/MlMarker/MlMarker.js.html +18 -12
  35. package/coverage/lcov-report/{components → src/components}/MlMarker/index.html +17 -11
  36. package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/MlNavigationCompass.js.html +17 -11
  37. package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/index.html +17 -11
  38. package/coverage/lcov-report/{components → src/components}/MlNavigationTools/MlNavigationTools.js.html +57 -42
  39. package/coverage/lcov-report/{components → src/components}/MlNavigationTools/index.html +25 -19
  40. package/coverage/lcov-report/{components → src/components}/MlOsmLayer/MlOsmLayer.js.html +17 -11
  41. package/coverage/lcov-report/{components → src/components}/MlOsmLayer/index.html +17 -11
  42. package/coverage/lcov-report/{components → src/components}/MlScaleReference/MlScaleReference.js.html +17 -11
  43. package/coverage/lcov-report/{components → src/components}/MlScaleReference/index.html +17 -11
  44. package/coverage/lcov-report/{components → src/components}/MlShareMapState/MlShareMapState.js.html +224 -26
  45. package/coverage/lcov-report/{components → src/components}/MlShareMapState/index.html +25 -19
  46. package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +17 -11
  47. package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/index.html +17 -11
  48. package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/MlThreeJsLayer.js.html +37 -55
  49. package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/index.html +31 -25
  50. package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/MlUseMapDebugger.js.html +17 -11
  51. package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/index.html +17 -11
  52. package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/MlVectorTileLayer.js.html +17 -11
  53. package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/index.html +17 -11
  54. package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +17 -11
  55. package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/index.html +17 -11
  56. package/coverage/lcov-report/{components → src/components}/MlWmsLayer/MlWmsLayer.js.html +20 -14
  57. package/coverage/lcov-report/{components → src/components}/MlWmsLayer/index.html +21 -15
  58. package/coverage/lcov-report/{components → src/components}/MlWmsLoader/MlWmsLoader.js.html +38 -20
  59. package/coverage/lcov-report/{components → src/components}/MlWmsLoader/index.html +23 -17
  60. package/coverage/lcov-report/src/hooks/index.html +147 -0
  61. package/coverage/lcov-report/{components/MlLayer/MlLayer.js.html → src/hooks/useMap.js.html} +86 -119
  62. package/coverage/lcov-report/{hooks → src/hooks}/useMapState.js.html +98 -92
  63. package/coverage/lcov-report/{hooks → src/hooks}/useWms.js.html +25 -19
  64. package/coverage/lcov-report/src/i18n.js.html +167 -0
  65. package/coverage/lcov-report/src/index.html +117 -0
  66. package/coverage/lcov-report/src/translations/english.js.html +95 -0
  67. package/coverage/lcov-report/src/translations/german.js.html +95 -0
  68. package/coverage/lcov-report/src/translations/index.html +132 -0
  69. package/coverage/lcov.info +1620 -1306
  70. package/dist/b556faa3bc6829d2.png +0 -0
  71. package/dist/index.esm.js +976 -688
  72. package/dist/index.esm.js.map +1 -1
  73. package/package.json +3 -1
  74. package/public/assets/dop.png +0 -0
  75. package/public/assets/historic.png +0 -0
  76. package/public/assets/osm.png +0 -0
  77. package/public/thumbnails/MlFollowGps.png +0 -0
  78. package/public/thumbnails/MlThreeJsLayer.png +0 -0
  79. package/rollup.config.js +7 -1
  80. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +53 -67
  81. package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta.json +1 -1
  82. package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -2
  83. package/src/components/MlFollowGps/MlFollowGps.js +49 -46
  84. package/src/components/MlFollowGps/MlFollowGps.meta.json +2 -2
  85. package/src/components/MlFollowGps/assets/marker.png +0 -0
  86. package/src/components/MlGPXViewer/MlGPXViewer.js +45 -43
  87. package/src/components/MlGPXViewer/gpxConverter.js +22 -29
  88. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +45 -9
  89. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -1
  90. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +21 -57
  91. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +6 -7
  92. package/src/components/MlLayer/MlLayer.js +28 -6
  93. package/src/components/MlLayer/MlLayer.test.js +12 -10
  94. package/src/components/MlLayerMagnify/MlLayerMagnify.js +3 -3
  95. package/src/components/MlLayerSwipe/MlLayerSwipe.js +4 -5
  96. package/src/components/MlLayerSwitcher/MlLayerSwitcher.css +17 -0
  97. package/src/components/MlLayerSwitcher/MlLayerSwitcher.doc.de.md +3 -0
  98. package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +223 -0
  99. package/src/components/MlLayerSwitcher/MlLayerSwitcher.meta_.json +15 -0
  100. package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +106 -0
  101. package/src/components/MlLayerSwitcher/assets/sample_1.json +26 -0
  102. package/src/components/MlLayerSwitcher/assets/sample_2.json +22 -0
  103. package/src/components/MlLayerSwitcher/components/LayerBox.js +98 -0
  104. package/src/components/MlMarker/MlMarker.js +1 -1
  105. package/src/components/MlNavigationTools/MlNavigationTools.js +29 -26
  106. package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -1
  107. package/src/components/MlScaleReference/MlScaleReference.stories.js +25 -21
  108. package/src/components/MlShareMapState/MlShareMapState.js +73 -9
  109. package/src/components/MlShareMapState/MlShareMapState.stories.js +24 -1
  110. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +12 -6
  111. package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +8 -15
  112. package/src/components/MlVectorTileLayer/MlVectorTileLayer.meta.json +3 -3
  113. package/src/components/MlWmsLayer/MlWmsLayer.js +1 -1
  114. package/src/components/MlWmsLoader/MlWmsLoader.js +8 -4
  115. package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -1
  116. package/src/components/MlWmsLoader/MlWmsLoader.stories.js +5 -4
  117. package/src/decorators/EmptyMapContextDecorator.js +11 -6
  118. package/src/decorators/MapContext3DDecorator.js +25 -20
  119. package/src/decorators/MapContextDashboardDecorator.js +7 -2
  120. package/src/decorators/MapContextDecorator.js +7 -3
  121. package/src/decorators/MapContextKlokantechBasicDecorator.js +8 -4
  122. package/src/decorators/MultiMapContextDecorator.js +2 -1
  123. package/src/hooks/useMap.js +36 -62
  124. package/src/hooks/useMapState.js +3 -3
  125. package/src/hooks/useWms.js +7 -6
  126. package/src/i18n.js +28 -0
  127. package/src/index.js +3 -0
  128. package/src/translations/english.js +4 -0
  129. package/src/translations/german.js +4 -0
  130. package/src/ui_components/ImageLoader.js +73 -0
  131. package/src/ui_components/Sidebar.js +76 -22
  132. package/src/ui_components/TopToolbar.js +18 -18
  133. package/coverage/lcov-report/components/MlLayer/index.html +0 -111
  134. package/coverage/lcov-report/hooks/index.html +0 -141
  135. package/coverage/lcov-report/hooks/useMap.js.html +0 -377
@@ -4,6 +4,7 @@ import MlScaleReference from "./MlScaleReference";
4
4
 
5
5
  import TopToolbar from "../../ui_components/TopToolbar";
6
6
  import mapContextDecorator from "../../decorators/MapContextDecorator";
7
+ import useMediaQuery from "@mui/material/useMediaQuery";
7
8
 
8
9
  const storyoptions = {
9
10
  title: "MapComponents/MlScaleReference",
@@ -16,27 +17,30 @@ const storyoptions = {
16
17
  };
17
18
  export default storyoptions;
18
19
 
19
- const Template = (props) => (
20
- <>
21
- {props.show === "toolbar" && (
22
- <TopToolbar>
23
- <MlScaleReference {...props} />
24
- </TopToolbar>
25
- )}
26
- {props.show === "overlay" && (
27
- <div
28
- style={{
29
- position: "absolute",
30
- zIndex: 100000,
31
- bottom: "20px",
32
- right: "20px",
33
- }}
34
- >
35
- <MlScaleReference {...props} />
36
- </div>
37
- )}
38
- </>
39
- );
20
+ const Template = (props) => {
21
+ const mediaIsMobile = useMediaQuery("(max-width:900px)");
22
+ return(
23
+ <>
24
+ {props.show === "toolbar" && (
25
+ <TopToolbar>
26
+ <MlScaleReference {...props} />
27
+ </TopToolbar>
28
+ )}
29
+ {props.show === "overlay" && (
30
+ <div
31
+ style={{
32
+ position: "absolute",
33
+ zIndex: 100000,
34
+ bottom: mediaIsMobile ? "40px" : "20px",
35
+ right: "20px",
36
+ }}
37
+ >
38
+ <MlScaleReference {...props} />
39
+ </div>
40
+ )}
41
+ </>
42
+ );
43
+ }
40
44
 
41
45
  export const Toolbar = Template.bind({});
42
46
  Toolbar.args = {
@@ -1,8 +1,9 @@
1
- import React, { useRef, useEffect, useContext, useState } from "react";
1
+ import React, {useRef, useEffect, useContext, useState} from "react";
2
2
  import PropTypes from "prop-types";
3
3
 
4
- import { MapContext } from "@mapcomponents/react-core";
5
- import { v4 as uuidv4 } from "uuid";
4
+ import {MapContext} from "@mapcomponents/react-core";
5
+ import {v4 as uuidv4} from "uuid";
6
+ import useMapState from "../../hooks/useMapState";
6
7
 
7
8
  /**
8
9
  * TODO: Add short & useful description
@@ -15,11 +16,21 @@ import { v4 as uuidv4 } from "uuid";
15
16
  const MlShareMapState = (props) => {
16
17
  // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
17
18
  const mapContext = useContext(MapContext);
18
-
19
19
  const initializedRef = useRef(false);
20
20
  const mapRef = useRef(undefined);
21
21
  const [map, setMap] = useState(undefined);
22
22
  const componentId = useRef((props.idPrefix ? props.idPrefix : "MlShareMapState-") + uuidv4());
23
+ const [isInitialState, setIsInitialState] = useState(true);
24
+ const mapState = useMapState({
25
+ watch: {
26
+ viewport: false,
27
+ layers: true,
28
+ sources: false
29
+ },
30
+ filter: {
31
+ includeBaseLayers: false
32
+ }
33
+ })
23
34
 
24
35
  const mapStateRef = useRef({});
25
36
 
@@ -49,32 +60,59 @@ const MlShareMapState = (props) => {
49
60
  mapRef.current = mapContext.getMap(props.mapId);
50
61
  setMap(mapRef.current);
51
62
 
52
- let currentUrlParams = getCurrentUrlParameters();
63
+ const currentUrlParams = getCurrentUrlParameters();
53
64
  if (currentUrlParams.lat && currentUrlParams.lng) {
54
65
  mapStateRef.current.lat = currentUrlParams.lat;
55
66
  mapStateRef.current.lng = currentUrlParams.lng;
56
67
  mapStateRef.current.zoom = currentUrlParams.zoom;
57
- mapRef.current.setCenter([mapStateRef.current.lng, mapStateRef.current.lat]);
58
68
  mapRef.current.setZoom(mapStateRef.current.zoom);
59
69
  }
60
70
  }, [mapContext.mapIds, mapContext, props.mapId, props.active]);
61
71
 
62
72
  useEffect(() => {
63
73
  if (!map) return;
74
+ if(!mapState.layers) return;
75
+ if(!isInitialState) return;
76
+
77
+ const currentUrlParams = getCurrentUrlParameters()
78
+
79
+ if(currentUrlParams.layers) {
80
+ for (let x in currentUrlParams.layers) {
81
+ mapRef.current.getLayer(currentUrlParams.layers[x].id).visibility = currentUrlParams.layers[x].visible ? "visible" : "none"
82
+ mapRef.current.getLayer(currentUrlParams.layers[x].id).type = currentUrlParams.layers[x].type
83
+ }
84
+ }
85
+
86
+ }, [mapState.layers, props.mapId, props.active])
87
+
88
+ useEffect(() => {
89
+ if (!map) return;
90
+ if (!mapState.layers) return;
64
91
 
65
92
  if (props.active) {
93
+ setIsInitialState(false)
66
94
  map.on(
67
95
  "moveend",
68
96
  () => {
97
+ let mapLayers = []
98
+ for (let x in mapState.layers) {
99
+ mapLayers.push(new URLSearchParams({
100
+ id: mapState.layers[x].id,
101
+ type: mapState.layers[x].type,
102
+ visible: mapState.layers[x].visible
103
+ }))
104
+ }
69
105
  refreshMapState();
70
106
  let urlParams = new URLSearchParams({
71
107
  ...getCurrentUrlParameters(),
72
108
  ...mapStateRef.current,
109
+ layers : mapLayers
73
110
  });
111
+
74
112
  let currentParams = new URLSearchParams(window.location.search);
75
113
  if (urlParams.toString() !== currentParams.toString()) {
76
114
  window.history.pushState(
77
- { ...mapStateRef.current },
115
+ {...mapStateRef.current},
78
116
  document.title,
79
117
  "?" + urlParams.toString()
80
118
  );
@@ -88,7 +126,33 @@ const MlShareMapState = (props) => {
88
126
  }, [props.active, map]);
89
127
 
90
128
  const getCurrentUrlParameters = () => {
91
- return Object.fromEntries(new URLSearchParams(window.location.search));
129
+ let parameterObject = Object.fromEntries(new URLSearchParams(window.location.search))
130
+
131
+ if(window.location.search.indexOf("layers")!==-1) {
132
+ let layerParamString = window.location.search.substring(window.location.search.indexOf("layers"))
133
+ layerParamString = layerParamString.substring(0, (layerParamString.indexOf("&")!==-1) ? layerParamString.indexOf("&") : layerParamString.length)
134
+ parameterObject = Object.fromEntries(new URLSearchParams(window.location.search.replace(layerParamString, "")))
135
+ let layerParams = layerParamString.substring(7)
136
+ layerParams = layerParams.replaceAll("%3D", "=")
137
+ layerParams = layerParams.replaceAll("%26", "&")
138
+ layerParams = layerParams.replaceAll("%2C", ",")
139
+
140
+ if (layerParams.indexOf(",")) {
141
+ layerParams = layerParams.split(",")
142
+ } else {
143
+ layerParams = [layerParams]
144
+ }
145
+
146
+ for (let x in layerParams) {
147
+ let layerState = layerParams[x].split("&")
148
+ layerParams[x] = {}
149
+ for (let y in layerState) {
150
+ layerParams[x][layerState[y].split("=")[0]] = layerState[y].split("=")[1]
151
+ }
152
+ }
153
+ parameterObject["layers"] = layerParams
154
+ }
155
+ return parameterObject
92
156
  };
93
157
 
94
158
  const refreshMapState = () => {
@@ -99,7 +163,7 @@ const MlShareMapState = (props) => {
99
163
 
100
164
  window.onpopstate = (event) => {
101
165
  if (event.state && event.state.lng && event.state.lat && event.state.zoom) {
102
- mapRef.current.easeTo({ zoom: event.state.zoom, center: [event.state.lng, event.state.lat] });
166
+ mapRef.current.easeTo({zoom: event.state.zoom, center: [event.state.lng, event.state.lat]});
103
167
  }
104
168
  };
105
169
 
@@ -2,6 +2,8 @@ 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
+ import MlLayer from "../MlLayer/MlLayer";
5
7
 
6
8
  const storyoptions = {
7
9
  title: "MapComponents/MlShareMapState",
@@ -12,7 +14,19 @@ const storyoptions = {
12
14
  export default storyoptions;
13
15
 
14
16
  const Template = (args) => {
15
- const [watchState, setWatchState] = useState(true);
17
+ const [watchState, setWatchState] = useState(false);
18
+ 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
+ )
16
30
 
17
31
  return (
18
32
  <>
@@ -22,7 +36,16 @@ const Template = (args) => {
22
36
  >
23
37
  watch map state {watchState?1:0}
24
38
  </button>
39
+ <button
40
+ style={{ zIndex: "1000", position: "absolute" }}
41
+ onClick={() => setTestLayerVisible(!testLayerVisible)}
42
+ >
43
+ visibility {testLayerVisible?1:0}
44
+ </button>
25
45
  <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")}}} />
26
49
  </>
27
50
  );
28
51
  };
@@ -9,6 +9,7 @@ import Button from "@mui/material/Button";
9
9
  import FileDownloadIcon from '@mui/icons-material/FileDownload';
10
10
  import InfoIcon from "@mui/icons-material/Info";
11
11
  import IconButton from "@mui/material/IconButton";
12
+ import useMediaQuery from "@mui/material/useMediaQuery";
12
13
 
13
14
  const storyoptions = {
14
15
  title: "MapComponents/MlSpatialElevationProfile",
@@ -24,30 +25,35 @@ const storyoptions = {
24
25
  };
25
26
  export default storyoptions;
26
27
 
27
- const Template = (args) => (
28
+ const Template = (args) => {
29
+
30
+ const mediaIsMobile = useMediaQuery("(max-width:900px)");
31
+
32
+ return(
28
33
  <>
29
34
  <IconButton
30
35
  style={{
31
36
  position: "absolute",
32
37
  right: "5px",
33
- bottom: "125px",
38
+ bottom: mediaIsMobile ? "145px" : "125px",
34
39
  backgroundColor: "rgba(255,255,255,1)",
35
40
 
36
41
  zIndex: 1000,
37
42
  }}
38
43
  title="Download sample-data"
39
44
  size="large"
40
- href="/assets/sample.gpx"
45
+ href="assets/sample.gpx"
41
46
  target="blank"
42
47
  >
43
- <FileDownloadIcon/>
48
+ <FileDownloadIcon />
44
49
  </IconButton>
45
50
  <GeoJsonProvider>
46
- <MlGPXViewer/>
47
- <MlSpatialElevationProfile/>
51
+ <MlGPXViewer />
52
+ <MlSpatialElevationProfile />
48
53
  </GeoJsonProvider>
49
54
  </>
50
55
  );
56
+ }
51
57
 
52
58
  export const ExampleConfig = Template.bind({});
53
59
  ExampleConfig.parameters = {};
@@ -45,8 +45,13 @@ const MlThreeJsLayer = (props) => {
45
45
  initializedRef.current = true;
46
46
  mapRef.current = mapContext.getMap(props.mapId);
47
47
 
48
+ mapRef.current.setCenter([7.099771581806502, 50.73395746209983]);
49
+ mapRef.current.setZoom(15);
50
+ mapRef.current.setPitch(45);
51
+
48
52
  // parameters to ensure the model is georeferenced correctly on the map
49
- var modelOrigin = [7.1300753566457304, 50.71596191210998];
53
+ var modelOrigin = [7.099771581806502, 50.73395746209983];
54
+ // 50.73395746209983, 7.099771581806502
50
55
  var modelAltitude = 0;
51
56
  var modelRotate = [Math.PI / 2, 90, 0];
52
57
 
@@ -92,8 +97,7 @@ const MlThreeJsLayer = (props) => {
92
97
  // use the three.js GLTF loader to add the 3D model to the three.js scene
93
98
  var loader = new GLTFLoader();
94
99
  loader.load(
95
- //"/assets/3D/posttower_simple.gltf",
96
- "/assets/3D/godzilla_simple.glb",
100
+ "assets/3D/godzilla_simple.glb",
97
101
  //"https://docs.mapbox.com/mapbox-gl-js/assets/34M_17/34M_17.gltf",
98
102
  function (gltf) {
99
103
  this.scene.add(gltf.scene);
@@ -102,14 +106,6 @@ const MlThreeJsLayer = (props) => {
102
106
  }
103
107
  }.bind(this)
104
108
  );
105
- loader.load(
106
- "/assets/3D/posttower.gltf",
107
- //"/assets/3D/posttower_wh.gltf.glb",
108
- //"https://docs.mapbox.com/mapbox-gl-js/assets/34M_17/34M_17.gltf",
109
- function (gltf) {
110
- this.scene.add(gltf.scene);
111
- }.bind(this)
112
- );
113
109
  this.map = map;
114
110
 
115
111
  // use the Mapbox GL JS map canvas for three.js
@@ -161,9 +157,6 @@ const MlThreeJsLayer = (props) => {
161
157
  if (mapRef.current.getLayer(layerName)) {
162
158
  mapRef.current.setLayoutProperty(layerName, "visibility", "visible");
163
159
  }
164
- mapRef.current.setCenter([7.130255969902919, 50.7143656091998]);
165
- mapRef.current.setZoom(15);
166
- mapRef.current.setPitch(45);
167
160
  }, [mapContext.mapIds, mapContext, props]);
168
161
 
169
162
  useEffect(() => {
@@ -211,4 +204,4 @@ MlThreeJsLayer.propTypes = {
211
204
  onDone: PropTypes.func,
212
205
  };
213
206
 
214
- export default MlThreeJsLayer;
207
+ export default MlThreeJsLayer;
@@ -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
@@ -47,7 +47,7 @@ const defaultProps = {
47
47
  const MlWmsLayer = (props) => {
48
48
  const mapContext = useContext(MapContext);
49
49
 
50
- const componentId = useRef((props.idPrefix ? props.idPrefix : "MlWmsLayer-") + uuidv4());
50
+ const componentId = useRef(props.layerId || ("MlWmsLayer-" + uuidv4()));
51
51
  const mapRef = useRef(null);
52
52
  const initializedRef = useRef(false);
53
53
  const layerId = useRef(props.layerId || componentId.current);
@@ -41,7 +41,7 @@ const MlWmsLoader = (props) => {
41
41
  // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
42
42
  const mapContext = useContext(MapContext);
43
43
  const { capabilities, error, setUrl, getFeatureInfoUrl, wmsUrl } = useWms({
44
- url: props.url,
44
+ url: undefined,
45
45
  urlParameters: props.urlParameters,
46
46
  });
47
47
 
@@ -72,6 +72,8 @@ const MlWmsLoader = (props) => {
72
72
  }, []);
73
73
 
74
74
  useEffect(() => {
75
+ if (!initializedRef.current) return;
76
+
75
77
  setUrl(props.url);
76
78
  }, [props.url]);
77
79
 
@@ -199,17 +201,19 @@ const MlWmsLoader = (props) => {
199
201
  // initialize the layer and add it to the MapLibre-gl instance or do something else with it
200
202
  initializedRef.current = true;
201
203
  mapRef.current = mapContext.getMap(props.mapId);
202
- }, [mapContext.mapIds, mapContext, props.mapId]);
204
+ console.log("set url " + props.url);
205
+ setUrl(props.url);
206
+ }, [mapContext.mapIds, mapContext, props.mapId, props.url]);
203
207
 
204
208
  return (
205
209
  <>
206
210
  {error && <p>{error}</p>}
207
211
  <h3 key="title">{capabilities?.Service?.Title}</h3>
212
+ {console.log(componentId.current)}
208
213
  {capabilities?.Capability?.Layer?.Layer.map((layer, idx) => (
209
214
  <MlLayer
210
- layerId="Order-"
215
+ layerId={"Order-" + componentId.current + "-" + idx}
211
216
  key={componentId.current + "-" + idx}
212
- idSuffix={componentId.current + "-" + idx}
213
217
  {...(idx > 0
214
218
  ? {
215
219
  insertBeforeLayer: "Order-" + componentId.current + "-" + (idx - 1),
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "MlWmsLoader",
3
- "title": "WMS Info",
3
+ "title": "WMS loader",
4
4
  "description": "",
5
5
  "i18n": {
6
6
  "de": {
@@ -18,11 +18,11 @@ const storyoptions = {
18
18
  export default storyoptions;
19
19
 
20
20
  const Template = (props) => {
21
- const [url, setUrl] = useState("");
21
+ const [url, setUrl] = useState(props.url);
22
22
 
23
23
  return (
24
24
  <>
25
- <Sidebar sx={{ width: "500px", wordBreak: "break-word" }}>
25
+ <Sidebar sx={{ wordBreak: "break-word" }}>
26
26
  <TextField
27
27
  label="WMS Url"
28
28
  variant="standard"
@@ -40,7 +40,8 @@ ExampleConfig.parameters = {};
40
40
  ExampleConfig.args = {
41
41
  /**
42
42
  * try https://maps.heigit.org/histosm/wms or https://magosm.magellium.com/geoserver/wms
43
- *
43
+ * https://www.wms.nrw.de/wms/kitas
44
+ * https://www.wms.nrw.de/geobasis/wms_nw_vdop
44
45
  */
45
- url: "https://www.wms.nrw.de/geobasis/wms_nw_vdop",
46
+ url: "https://www.wms.nrw.de/wms/kitas",
46
47
  };
@@ -4,16 +4,21 @@ import { MapComponentsProvider } from "@mapcomponents/react-core";
4
4
  import { LoadingOverlayProvider } from "../ui_components/LoadingOverlayContext";
5
5
  import LoadingOverlay from "../ui_components/LoadingOverlay";
6
6
  import "./style.css";
7
+ import { createTheme, ThemeProvider } from "@mui/material/styles";
8
+
9
+ const theme = createTheme({});
7
10
 
8
11
  const decorators = [
9
12
  (Story) => (
10
- <MapComponentsProvider>
11
- <LoadingOverlayProvider>
12
- <LoadingOverlay></LoadingOverlay>
13
+ <ThemeProvider theme={theme}>
14
+ <MapComponentsProvider>
15
+ <LoadingOverlayProvider>
16
+ <LoadingOverlay></LoadingOverlay>
13
17
 
14
- <Story />
15
- </LoadingOverlayProvider>
16
- </MapComponentsProvider>
18
+ <Story />
19
+ </LoadingOverlayProvider>
20
+ </MapComponentsProvider>
21
+ </ThemeProvider>
17
22
  ),
18
23
  ];
19
24
 
@@ -3,30 +3,35 @@ import React from "react";
3
3
  import { MapComponentsProvider } from "@mapcomponents/react-core";
4
4
  import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
5
5
  import "./style.css";
6
+ import { createTheme, ThemeProvider } from "@mui/material/styles";
7
+
8
+ const theme = createTheme({});
6
9
 
7
10
  const decorators = [
8
11
  (Story) => (
9
12
  <div className="fullscreen_map">
10
- <MapComponentsProvider>
11
- <Story />
12
- <MapLibreMap
13
- options={{
14
- //style: "mapbox://styles/mapbox/light-v10",
15
- //center: [-87.62712, 41.89033],
16
- zoom: 14.5,
17
- //pitch: 45,
18
- //style: "https://wms.wheregroup.com/tileserver/style/osm-bright.json",
19
- style: "https://wms.wheregroup.com/tileserver/style/osm-liberty.json",
20
- //center: [8.607, 53.1409349],
21
- // zoom: 13,
22
- center: [7.0851268, 50.73884],
23
- // maxBounds: [
24
- // [1.40625, 43.452919],
25
- // [17.797852, 55.973798],
26
- // ],
27
- }}
28
- />
29
- </MapComponentsProvider>
13
+ <ThemeProvider theme={theme}>
14
+ <MapComponentsProvider>
15
+ <Story />
16
+ <MapLibreMap
17
+ options={{
18
+ //style: "mapbox://styles/mapbox/light-v10",
19
+ //center: [-87.62712, 41.89033],
20
+ zoom: 14.5,
21
+ //pitch: 45,
22
+ //style: "https://wms.wheregroup.com/tileserver/style/osm-bright.json",
23
+ style: "https://wms.wheregroup.com/tileserver/style/osm-liberty.json",
24
+ //center: [8.607, 53.1409349],
25
+ // zoom: 13,
26
+ center: [7.0851268, 50.73884],
27
+ // maxBounds: [
28
+ // [1.40625, 43.452919],
29
+ // [17.797852, 55.973798],
30
+ // ],
31
+ }}
32
+ />
33
+ </MapComponentsProvider>
34
+ </ThemeProvider>
30
35
  </div>
31
36
  ),
32
37
  ];
@@ -2,12 +2,17 @@ import React from "react";
2
2
 
3
3
  import { MapComponentsProvider } from "@mapcomponents/react-core";
4
4
  import "./style.css";
5
+ import { createTheme, ThemeProvider } from "@mui/material/styles";
6
+
7
+ const theme = createTheme({});
5
8
 
6
9
  const decorators = [
7
10
  (Story) => (
8
- <MapComponentsProvider>
11
+ <ThemeProvider theme={theme}>
12
+ <MapComponentsProvider>
9
13
  <Story />
10
- </MapComponentsProvider>
14
+ </MapComponentsProvider>
15
+ </ThemeProvider>
11
16
  ),
12
17
  ];
13
18
 
@@ -3,12 +3,15 @@ import React from "react";
3
3
  import { MapComponentsProvider } from "@mapcomponents/react-core";
4
4
  import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
5
5
  import "./style.css";
6
+ import { createTheme, ThemeProvider } from "@mui/material/styles";
7
+
8
+ const theme = createTheme({});
6
9
 
7
10
  const decorators = [
8
11
  (Story) => (
9
12
  <div className="fullscreen_map">
10
- <MapComponentsProvider>
11
-
13
+ <ThemeProvider theme={theme}>
14
+ <MapComponentsProvider>
12
15
  <Story />
13
16
  <MapLibreMap
14
17
  options={{
@@ -18,7 +21,8 @@ const decorators = [
18
21
  }}
19
22
  mapId="map_1"
20
23
  />
21
- </MapComponentsProvider>
24
+ </MapComponentsProvider>
25
+ </ThemeProvider>
22
26
  </div>
23
27
  ),
24
28
  ];
@@ -3,11 +3,15 @@ import React from "react";
3
3
  import { MapComponentsProvider } from "@mapcomponents/react-core";
4
4
  import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
5
5
  import "./style.css";
6
+ import { createTheme, ThemeProvider } from "@mui/material/styles";
7
+
8
+ const theme = createTheme({});
6
9
 
7
10
  const decorators = [
8
11
  (Story) => (
9
12
  <div className="fullscreen_map">
10
- <MapComponentsProvider>
13
+ <ThemeProvider theme={theme}>
14
+ <MapComponentsProvider>
11
15
  <Story />
12
16
  <MapLibreMap
13
17
  options={{
@@ -15,8 +19,7 @@ const decorators = [
15
19
  //center: [-87.62712, 41.89033],
16
20
  zoom: 14.5,
17
21
  //pitch: 45,
18
- style:
19
- "https://wms.wheregroup.com/tileserver/style/klokantech-basic.json",
22
+ style: "https://wms.wheregroup.com/tileserver/style/klokantech-basic.json",
20
23
  //style:"https://wms.wheregroup.com/tileserver/style/osm-liberty.json",
21
24
  //center: [8.607, 53.1409349],
22
25
  // zoom: 13,
@@ -27,7 +30,8 @@ const decorators = [
27
30
  // ],
28
31
  }}
29
32
  />
30
- </MapComponentsProvider>
33
+ </MapComponentsProvider>
34
+ </ThemeProvider>
31
35
  </div>
32
36
  ),
33
37
  ];
@@ -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">