@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
@@ -0,0 +1,223 @@
1
+ //CSS
2
+ import "@fontsource/roboto/300.css";
3
+ import "@fontsource/roboto/400.css";
4
+ import "@fontsource/roboto/500.css";
5
+ import { css, cx } from '@emotion/css'
6
+ import "./MlLayerSwitcher.css";
7
+ //External
8
+ import { useEffect, useContext, useState } from "react";
9
+ import PropTypes from "prop-types";
10
+ import { useTranslation } from "react-i18next";
11
+ import { Card, CardContent, Typography, Box } from "@mui/material";
12
+ //Internal
13
+ import { MapContext } from "@mapcomponents/react-core";
14
+ import LayerBox from "./components/LayerBox";
15
+ import Divider from "@mui/material/Divider";
16
+ import useMapState from "../../hooks/useMapState";
17
+ import LoadingOverlay from "../../ui_components/LoadingOverlay";
18
+ /**
19
+ * @component
20
+ *
21
+ *
22
+ */
23
+ const MlLayerSwitcher = (props) => {
24
+ const mapContext = useContext(MapContext);
25
+ const showBaseSources = !!props.baseSourceConfig?.layers?.length;
26
+ const showDetailLayer = !!props.detailLayerConfig?.layers?.length;
27
+ const { layers } = useMapState({
28
+ mapId: props.mapId,
29
+ watch: {
30
+ viewport: false,
31
+ layers: true,
32
+ sources: false,
33
+ },
34
+ filter: {},
35
+ });
36
+ const [activeLayers, setActiveLayers] = useState([]);
37
+ const [activeDetailLayers, setActiveDetailLayers] = useState([]);
38
+ const { t } = useTranslation();
39
+
40
+ useEffect(() => {
41
+ //Set base state to activate only the first layer
42
+ if (mapContext.map) {
43
+ const disableAllButFirst = (config, i) => {
44
+ const layers = getLayerListFromId(config.layerId);
45
+ const visible = i === 0 ? "visible" : "none";
46
+
47
+ layers.forEach((layer) => {
48
+ if (layer) {
49
+ changeLayerState(layer, visible);
50
+ }
51
+ });
52
+ };
53
+
54
+ props.baseSourceConfig.layers.forEach((config, i) => disableAllButFirst(config, i));
55
+ props.detailLayerConfig.layers.forEach((config, i) => disableAllButFirst(config, i));
56
+ }
57
+ return () => {
58
+ // This is the cleanup function, it is called when this react component is removed from react-dom
59
+ // try to remove anything this component has added to the MapLibre-gl instance
60
+ // e.g.: remove the layer
61
+ // mapContext.getMap(props.mapId).removeLayer(layerRef.current);
62
+ // check for the existence of map.style before calling getLayer or getSource
63
+ };
64
+ }, [mapContext.map]);
65
+
66
+ useEffect(() => {
67
+ if (mapContext.map?.style?._layers) {
68
+ let newactiveLayers = [];
69
+ let newactiveDetailLayers = [];
70
+ props.baseSourceConfig.layers.forEach((layerConfig) => {
71
+ const layers = getLayerListFromId(layerConfig.layerId);
72
+
73
+ layers.forEach((layer) => {
74
+ const visibilty = mapContext.map?.getLayoutProperty(layer, "visibility");
75
+ if (mapContext.map.baseLayers.indexOf(layer) !== -1) {
76
+ layer = "styleBase";
77
+ }
78
+
79
+ if (newactiveLayers.indexOf(layer) === -1 && visibilty === "visible") {
80
+ newactiveLayers.push(layer);
81
+ }
82
+ });
83
+ });
84
+ props.detailLayerConfig.layers.forEach(({ layerId }) => {
85
+ const visibilty = mapContext.map?.getLayoutProperty(layerId, "visibility");
86
+ if (newactiveDetailLayers.indexOf(layerId) === -1 && visibilty === "visible") {
87
+ newactiveDetailLayers.push(layerId);
88
+ }
89
+ });
90
+ setActiveLayers(newactiveLayers);
91
+
92
+ setActiveDetailLayers(newactiveDetailLayers);
93
+ }
94
+ }, [layers]);
95
+
96
+ const getLayerListFromId = (id) => {
97
+ return id === "styleBase" ? mapContext?.map.baseLayers : [id];
98
+ };
99
+
100
+ const handleDetailLayerBoxClick = (layerId) => {
101
+ const cfg = props.detailLayerConfig.layers.find((e) => e.layerId === layerId);
102
+ if (cfg.linkedTo) {
103
+ handleLayerBoxClick(cfg.linkedTo);
104
+ }
105
+ const nextVisiblityClickedLayer =
106
+ mapContext?.map.getLayer(layerId)?.getLayoutProperty("visibility") === "visible"
107
+ ? "none"
108
+ : "visible";
109
+ changeLayerState(layerId, nextVisiblityClickedLayer);
110
+ };
111
+
112
+ const handleLayerBoxClick = (id) => {
113
+ let layers = getLayerListFromId(id);
114
+ const nextVisiblityClickedLayer =
115
+ mapContext?.map.getLayer(layers[0])?.getLayoutProperty("visibility") === "visible"
116
+ ? "none"
117
+ : "visible";
118
+
119
+ props.baseSourceConfig.layers.forEach((config, i) => {
120
+ let layers = getLayerListFromId(config.layerId);
121
+ let visible = "none";
122
+ if (config.layerId === id) {
123
+ visible = nextVisiblityClickedLayer;
124
+ }
125
+
126
+ //To avoid disabling all base layers we activate the first one
127
+ if (nextVisiblityClickedLayer === "none" && i === 0) {
128
+ visible = "visible";
129
+ }
130
+ layers.forEach((layer) => {
131
+ if (layer) {
132
+ changeLayerState(layer, visible);
133
+ }
134
+ });
135
+ });
136
+ };
137
+
138
+ const changeLayerState = (layer, visible = "none") => {
139
+ mapContext.map?.setLayoutProperty(layer, "visibility", visible);
140
+ };
141
+
142
+ return (
143
+ <>
144
+ <Card sx={{ zIndex: 101, position: "absolute", minWidth: "200px" }}>
145
+ <CardContent>
146
+ {showBaseSources && (
147
+ <Box sx={{ minHeight: "150px" }}>
148
+ <Typography variant="h6">{t(props.baseSourceConfig.label || "Map type")}</Typography>
149
+ <Divider />
150
+ <Box sx={{ display: "flex", paddingTop: "1rem" }}>
151
+ {props.baseSourceConfig.layers.map(({ src, label, layerId }) => {
152
+ return (
153
+ <LayerBox
154
+ mapId={props.mapId}
155
+ key={layerId}
156
+ activeLayers={activeLayers}
157
+ label={t(label)}
158
+ layerId={layerId}
159
+ thumbnail={src}
160
+ handleLayerBoxClick={() => {
161
+ handleLayerBoxClick(layerId);
162
+ }}
163
+ />
164
+ );
165
+ })}
166
+ </Box>
167
+ </Box>
168
+ )}
169
+ {showDetailLayer && (
170
+ <Box sx={{ minHeight: "150px" }}>
171
+ <Typography variant="h6">{t("Map details")}</Typography>
172
+ <Divider />
173
+ <Box sx={{ display: "flex", paddingTop: "1rem" }}>
174
+ {props.detailLayerConfig.layers.map(({ src, label, layerId }) => {
175
+ return (
176
+ <LayerBox
177
+ mapId={props.mapId}
178
+ activeLayers={activeDetailLayers}
179
+ label={t(label)}
180
+ layerId={layerId}
181
+ key={layerId}
182
+ thumbnail={src}
183
+ handleLayerBoxClick={() => {
184
+ handleDetailLayerBoxClick(layerId);
185
+ }}
186
+ />
187
+ );
188
+ })}
189
+ </Box>
190
+ </Box>
191
+ )}
192
+ </CardContent>{" "}
193
+ </Card>
194
+ </>
195
+ );
196
+ };
197
+
198
+ MlLayerSwitcher.propTypes = {
199
+ baseSourceConfig: PropTypes.shape({
200
+ label: PropTypes.string,
201
+ layers: PropTypes.arrayOf(
202
+ PropTypes.shape({
203
+ layerId: PropTypes.string.isRequired,
204
+ src: PropTypes.string,
205
+ label: PropTypes.string.isRequired,
206
+ })
207
+ ),
208
+ }),
209
+ detailLayerConfig: PropTypes.shape({
210
+ label: PropTypes.string,
211
+ layers: PropTypes.arrayOf(
212
+ PropTypes.shape({
213
+ layerId: PropTypes.string.isRequired,
214
+ src: PropTypes.string,
215
+ label: PropTypes.string.isRequired,
216
+ linkedTo: PropTypes.string,
217
+ })
218
+ ),
219
+ }),
220
+ mapId: PropTypes.string,
221
+ };
222
+
223
+ export default MlLayerSwitcher;
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "MlLayerSwitcher",
3
+ "title": "Layer switcher",
4
+ "description": "",
5
+ "i18n": {
6
+ "de": {
7
+ "title": "Ebenen wechsler",
8
+ "description": ""
9
+ }
10
+ },
11
+ "tags": [],
12
+ "category": "",
13
+ "type": "component",
14
+ "price": 0
15
+ }
@@ -0,0 +1,106 @@
1
+ import React, { useState, useContext, useRef, useEffect } from "react";
2
+ import MlWmsLayer from "../MlWmsLayer/MlWmsLayer";
3
+ import MlLayerSwitcher from "./MlLayerSwitcher";
4
+ import MlGeoJsonLayer from '../MlGeoJsonLayer/MlGeoJsonLayer'
5
+ import mapContextDecorator from "../../decorators/MapContextDecorator";
6
+ import sample_geojson_1 from "./assets/sample_1.json";
7
+ import sample_geojson_2 from "./assets/sample_2.json";
8
+ import { Props } from "@storybook/addon-docs/blocks";
9
+
10
+ const storyoptions = {
11
+ title: "MapComponents/MlLayerSwitcher",
12
+ component: MlLayerSwitcher,
13
+ argTypes: {
14
+ url: {},
15
+ layer: {},
16
+ },
17
+ decorators: mapContextDecorator,
18
+ };
19
+ export default storyoptions;
20
+ const layerId = "nw_uraufnahme_rw";
21
+ const Template = (args) => {
22
+ const [geojson, setGeojson] = useState(sample_geojson_1);
23
+ return (
24
+ <>
25
+ <MlWmsLayer
26
+ url={args.url}
27
+ urlParameters={{ layers: args.layer }}
28
+ sourceOptions={args.sourceOptions}
29
+ layerId="historic"
30
+ visible={args.layerVisible}
31
+ />
32
+ <MlWmsLayer
33
+ url={args.url2}
34
+ urlParameters={{ layers: args.layer2 }}
35
+ sourceOptions={args.sourceOptions}
36
+ layerId={args.layer2}
37
+ visible={args.layer2Visible}
38
+ />
39
+ <MlGeoJsonLayer
40
+ type="line"
41
+ layout={{ visibility: args.geojsonLayerVisible ? "visible" : "none" }}
42
+ geojson={geojson}
43
+ layerId="geojson1"
44
+ />
45
+ <MlGeoJsonLayer
46
+ type="line"
47
+ layout={{ visibility: args.geojson2LayerVisible ? "visible" : "none" }}
48
+ geojson={sample_geojson_2}
49
+ layerId="geojson2"
50
+ />
51
+ <MlLayerSwitcher
52
+ baseSourceConfig={{
53
+ active: args.baseSourcesActive,
54
+ layers: args.layers,
55
+ }}
56
+ detailLayerConfig={args.detailLayerConfig}
57
+ />
58
+ ;
59
+ </>
60
+ );
61
+ };
62
+
63
+ export const ExampleConfig = Template.bind({});
64
+ ExampleConfig.parameters = {};
65
+ ExampleConfig.args = {
66
+ url: "https://www.wms.nrw.de/geobasis/wms_nw_uraufnahme",
67
+ layer: "nw_uraufnahme_rw",
68
+ layerVisible: true,
69
+ url2: "https://www.wms.nrw.de/geobasis/wms_nw_dop",
70
+ layer2: "WMS_NW_DOP",
71
+ layer2Visible: false,
72
+ geojsonLayerVisible: true,
73
+ geojson2LayerVisible: true,
74
+ sourceOptions: {
75
+ minzoom: 13,
76
+ maxzoom: 20,
77
+ },
78
+ baseSourcesActive: true,
79
+ layers: [
80
+ {
81
+ label: "Historic",
82
+ layerId: "historic",
83
+ src: "assets/historic.png",
84
+ },
85
+ {
86
+ label: "Straßenkarte",
87
+ layerId: "styleBase",
88
+ src: "assets/osm.png",
89
+ },
90
+ {
91
+ label: "DOP",
92
+ layerId: "WMS_NW_DOP",
93
+ src: "assets/dop.png",
94
+ },
95
+ ],
96
+ detailLayerConfig: {
97
+ layers: [
98
+ {
99
+ label: "GeoJson 1",
100
+ layerId: "geojson1",
101
+ src: "assets/historic.png",
102
+ active: true,
103
+ },
104
+ ],
105
+ },
106
+ };
@@ -0,0 +1,26 @@
1
+ {
2
+ "type": "Feature",
3
+ "properties": {},
4
+ "geometry": {
5
+ "type": "LineString",
6
+ "coordinates": [
7
+ [7.1074676513671875, 50.74340774029213],
8
+ [7.0992279052734375, 50.756441089372665],
9
+ [7.079315185546874, 50.764693667025014],
10
+ [7.045669555664062, 50.77945780529241],
11
+ [7.030563354492187, 50.79161300845443],
12
+ [7.0291900634765625, 50.80940599750376],
13
+ [7.0236968994140625, 50.820685846099174],
14
+ [7.0085906982421875, 50.825891011253546],
15
+ [6.9879913330078125, 50.826758482363275],
16
+ [6.97906494140625, 50.835432306955276],
17
+ [6.9824981689453125, 50.84583876895451],
18
+ [6.9962310791015625, 50.85147463352982],
19
+ [7.012023925781249, 50.85710981721644],
20
+ [7.021636962890625, 50.86664473085768],
21
+ [7.0367431640625, 50.872278081520406],
22
+ [7.0477294921875, 50.877044231111014],
23
+ [7.052536010742187, 50.88397594225127]
24
+ ]
25
+ }
26
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "type": "Feature",
3
+ "properties": {},
4
+ "geometry": {
5
+ "type": "LineString",
6
+ "coordinates": [
7
+ [7.0635223388671875, 50.71385204707258],
8
+ [7.06146240234375, 50.709721458354075],
9
+ [7.063865661621094, 50.70298129536074],
10
+ [7.064552307128906, 50.69906720767511],
11
+ [7.059059143066406, 50.69428287906098],
12
+ [7.05596923828125, 50.68797551838366],
13
+ [7.0580291748046875, 50.680797145321655],
14
+ [7.062835693359375, 50.67514068397085],
15
+ [7.060432434082031, 50.6686131506577],
16
+ [7.051849365234375, 50.659255436656736],
17
+ [7.044639587402344, 50.6512019574539],
18
+ [7.0484161376953125, 50.64271166020676],
19
+ [7.0566558837890625, 50.63748609931014]
20
+ ]
21
+ }
22
+ }
@@ -0,0 +1,98 @@
1
+ import { React, useEffect, useState } from "react";
2
+ import { css, cx } from "@emotion/css";
3
+ import { Box } from "@mui/system";
4
+ import ImageLoader from "../../../ui_components/ImageLoader";
5
+ import { propsToClassKey } from "@mui/styles";
6
+ import useMapState from "../../../hooks/useMapState";
7
+
8
+ /**
9
+ * @component
10
+ *
11
+ */
12
+ const LayerBox = (props) => {
13
+ const [activeClassName, setActiveClassName] = useState("");
14
+ const [className, setClassName] = useState("mllayerswitcher-layer-box ");
15
+ const { layers } = useMapState({
16
+ mapId: props.mapId,
17
+ watch: {
18
+ viewport: false,
19
+ layers: true,
20
+ sources: false,
21
+ },
22
+ filter: {
23
+ matchLayerIds: props.layerId,
24
+ },
25
+ });
26
+ const hoverBorderColor = "#1C62D7"; //Navy Blue
27
+ const activeBorderColor = "";
28
+ const width = "40px";
29
+
30
+ const defaultClass = css`
31
+ & img:hover {
32
+ }
33
+ `;
34
+ const activeClass =
35
+ defaultClass +
36
+ `& img {
37
+ border-color: rgb(196, 240, 0);
38
+ border-radius: 8px;
39
+ }
40
+
41
+ `;
42
+ const hoverClass = css``;
43
+
44
+ useEffect(() => {
45
+ const isActive = props.activeLayers?.indexOf(props.layerId) !== -1;
46
+
47
+ if (isActive) {
48
+ setClassName(activeClass);
49
+ } else {
50
+ setClassName(defaultClass);
51
+ }
52
+ }, [props.activeLayers]);
53
+
54
+ return (
55
+ <>
56
+ <Box
57
+ key={props.layerId}
58
+ className={defaultClass}
59
+ sx={{
60
+ width,
61
+ height: "53px",
62
+ justifyContent: "center",
63
+ py: 0.25,
64
+ px: "1rem",
65
+ cursor: "pointer",
66
+ }}
67
+ onClick={() => {
68
+ props?.handleLayerBoxClick?.(props.layerId);
69
+ }}
70
+ >
71
+ <ImageLoader
72
+ style={{
73
+ border: "2px solid " + (layers?.[0]?.visible ? "#64c864" : "#fd720f"),
74
+ borderRadius: "8px",
75
+ height: "40px",
76
+ width: "40px",
77
+ }}
78
+ src={props.thumbnail}
79
+ />
80
+
81
+ <div
82
+ className="mllayerswitcher-layer-text"
83
+ style={{
84
+ textAlign: "center",
85
+ color: "rgb(112, 117, 122)",
86
+ fontFamily: "Roboto, Arial",
87
+ width,
88
+ fontSize: "0.60rem",
89
+ }}
90
+ >
91
+ {props.label}
92
+ </div>
93
+ </Box>
94
+ </>
95
+ );
96
+ };
97
+
98
+ export default LayerBox;
@@ -115,7 +115,7 @@ const MlMarker = (props) => {
115
115
  "&:hover": {
116
116
  opacity: 1,
117
117
  },
118
- zIndex: 1000,
118
+ zIndex: -1,
119
119
  }}
120
120
  >
121
121
  <iframe
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
 
3
- import { MapContext } from "@mapcomponents/react-core";
4
- import { useEffect, useRef, useContext, useState } from "react";
3
+ import {MapContext} from "@mapcomponents/react-core";
4
+ import {useEffect, useRef, useContext, useState} from "react";
5
5
  import Button from "@mui/material/Button";
6
6
  import ButtonGroup from "@mui/material/ButtonGroup";
7
7
  import ControlPointIcon from "@mui/icons-material/ControlPoint";
@@ -9,10 +9,11 @@ import RemoveCircleOutlineIcon from "@mui/icons-material/RemoveCircleOutline";
9
9
  //import ZoomOutIcon from "@mui/icons-material/ZoomOut";
10
10
  //import ZoomInIcon from "@mui/icons-material/ZoomIn";
11
11
  import GpsFixedIcon from "@mui/icons-material/GpsFixed";
12
- import { v4 as uuidv4 } from "uuid";
12
+ import {v4 as uuidv4} from "uuid";
13
13
 
14
14
  import MlNavigationCompass from "../MlNavigationCompass/MlNavigationCompass";
15
15
  import MlFollowGps from "../MlFollowGps/MlFollowGps";
16
+ import useMediaQuery from "@mui/material/useMediaQuery";
16
17
 
17
18
  const MlNavigationTools = (props) => {
18
19
  const mapContext = useContext(MapContext);
@@ -22,21 +23,22 @@ const MlNavigationTools = (props) => {
22
23
 
23
24
  const [pitch, setPitch] = useState(0);
24
25
  const [locationAccessDenied, setLocationAccessDenied] = useState(false);
26
+ const mediaIsMobile = useMediaQuery("(max-width:900px)");
25
27
  const buttonStyle = {
26
- minWidth: "30px",
27
- minHeight: "30px",
28
- width: "30px",
29
- height: "30px",
30
- color: "#bbb",
28
+ minWidth: "20px",
29
+ minHeight: "20px",
30
+ width: mediaIsMobile ? "50px" : "30px",
31
+ height: mediaIsMobile ? "50px" : "30px",
31
32
  backgroundColor: "#414141",
32
33
  borderRadius: "23%",
33
34
  //border: "1px solid #bbb",
34
35
  //boxShadow: "0px 0px 4px rgba(0,0,0,.5)",
35
36
  margin: 0.15,
37
+ fontSize: mediaIsMobile ? "1.5em" : "1.2em",
36
38
  ":hover": {
37
39
  backgroundColor: "#515151",
38
- color: "#ececec",
39
40
  },
41
+ color: "#ececec"
40
42
  };
41
43
 
42
44
  useEffect(() => {
@@ -77,7 +79,7 @@ const MlNavigationTools = (props) => {
77
79
  if (!mapRef.current) return;
78
80
 
79
81
  if (mapRef.current.transform._zoom + 0.5 <= mapRef.current.transform._maxZoom) {
80
- mapRef.current.easeTo({ zoom: mapRef.current.transform._zoom + 0.5 });
82
+ mapRef.current.easeTo({zoom: mapRef.current.transform._zoom + 0.5});
81
83
  }
82
84
  };
83
85
 
@@ -85,7 +87,7 @@ const MlNavigationTools = (props) => {
85
87
  if (!mapRef.current) return;
86
88
 
87
89
  if (mapRef.current.transform._zoom - 0.5 >= mapRef.current.transform._minZoom) {
88
- mapRef.current.easeTo({ zoom: mapRef.current.transform._zoom - 0.5 });
90
+ mapRef.current.easeTo({zoom: mapRef.current.transform._zoom - 0.5});
89
91
  }
90
92
  };
91
93
 
@@ -96,7 +98,7 @@ const MlNavigationTools = (props) => {
96
98
  if (mapRef.current.getPitch() !== 0) {
97
99
  targetPitch = 0;
98
100
  }
99
- mapRef.current.easeTo({ pitch: targetPitch });
101
+ mapRef.current.easeTo({pitch: targetPitch});
100
102
  };
101
103
 
102
104
  const moveToCurrentLocation = () => {
@@ -117,8 +119,8 @@ const MlNavigationTools = (props) => {
117
119
  style={{
118
120
  zIndex: 501,
119
121
  position: "absolute",
120
- right: "20px",
121
- bottom: "20px",
122
+ right: mediaIsMobile ? "15px" : "5px",
123
+ bottom: mediaIsMobile ? "40px" : "20px",
122
124
  display: "flex",
123
125
  flexDirection: "column",
124
126
  }}
@@ -127,34 +129,35 @@ const MlNavigationTools = (props) => {
127
129
  style={{
128
130
  width: "31px",
129
131
  position: "relative",
130
- height: "50px",
131
- marginLeft: "-5px",
132
+ height: mediaIsMobile ? "55px" : "45px",
133
+ marginLeft: mediaIsMobile ? "3px" : "-5px",
134
+ transform: mediaIsMobile ? "scale(1.6)" : "scale(1)"
132
135
  }}
133
136
  backgroundStyle={{
134
137
  boxShadow: "0px 0px 18px rgba(0,0,0,.5)",
135
138
  }}
136
139
  />
137
- <Button sx={{ ...buttonStyle, fontSize: ".9em", fontWeight: 600 }} onClick={adjustPitch}>
140
+ <Button sx={{...buttonStyle, fontWeight: 600}} onClick={adjustPitch}>
138
141
  {pitch ? "2D" : "3D"}
139
142
  </Button>
140
143
  <Button sx={buttonStyle} onClick={moveToCurrentLocation} disabled={locationAccessDenied}>
141
- <GpsFixedIcon sx={{ width: ".9em" }} />
144
+ <GpsFixedIcon sx={{fontSize: mediaIsMobile ? "1.5em" : "1.2em"}}/>
142
145
  </Button>
143
- <MlFollowGps />
146
+ <MlFollowGps style={{...(({color, ...rest}) => rest)(buttonStyle)}} />
144
147
  <ButtonGroup
145
148
  orientation="vertical"
146
149
  sx={{
147
- width: "30px",
150
+ width: "50px",
148
151
  border: "none",
149
- Button: { minWidth: "30px !important", border: "none", padding: 0 },
150
- "Button:hover": { border: "none" },
152
+ Button: {minWidth: "20px !important", border: "none", padding: 0},
153
+ "Button:hover": {border: "none"},
151
154
  }}
152
155
  >
153
- <Button sx={buttonStyle} onClick={zoomIn}>
154
- <ControlPointIcon />
156
+ <Button sx={{...buttonStyle, color: "#ececec",}} onClick={zoomIn}>
157
+ <ControlPointIcon sx={{fontSize: mediaIsMobile ? "1.5em" : "1.2em"}}/>
155
158
  </Button>
156
- <Button sx={buttonStyle} onClick={zoomOut}>
157
- <RemoveCircleOutlineIcon />
159
+ <Button sx={{...buttonStyle, color: "#ececec",}} onClick={zoomOut}>
160
+ <RemoveCircleOutlineIcon sx={{fontSize: mediaIsMobile ? "1.5em" : "1.2em"}}/>
158
161
  </Button>
159
162
  </ButtonGroup>
160
163
  </div>
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "MlScaleReference",
3
- "title": "Referencescale",
3
+ "title": "Reference scale",
4
4
  "description": "",
5
5
  "i18n": {
6
6
  "de": {