@mapcomponents/react-maplibre 0.1.9 → 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.
- package/.github/ISSUE_TEMPLATE/bug_report.md +2 -2
- package/.github/ISSUE_TEMPLATE/feature_request.md +3 -3
- package/.github/workflows/node_version_test.yml +25 -0
- package/.github/workflows/storybook.yml +6 -3
- package/CONTRIBUTING.md +2 -2
- package/README.md +3 -7
- package/coverage/clover.xml +748 -625
- package/coverage/coverage-final.json +19 -14
- package/coverage/lcov-report/block-navigation.js +8 -0
- package/coverage/lcov-report/index.html +170 -104
- package/coverage/lcov-report/sorter.js +26 -0
- package/coverage/lcov-report/{components → src/components}/MapLibreMap/MapLibreMap.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MapLibreMap/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/MlCreatePdfButton.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlCreatePdfButton/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/MlFeatureEditor.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFeatureEditor/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFillExtrusionLayer/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlFollowGps/MlFollowGps.js.html +99 -48
- package/coverage/lcov-report/{components → src/components}/MlFollowGps/index.html +27 -21
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/MlGPXViewer.js.html +73 -61
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/gpxConverter.js.html +56 -71
- package/coverage/lcov-report/{components → src/components}/MlGPXViewer/index.html +32 -26
- package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/MlGeoJsonLayer.js.html +91 -31
- package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/index.html +35 -29
- package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/MlImageMarkerLayer.js.html +26 -23
- package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/index.html +26 -20
- package/coverage/lcov-report/{components → src/components}/MlLayer/MlLayer.js.html +37 -31
- package/coverage/lcov-report/{components → src/components}/MlLayer/index.html +33 -27
- package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/MlLayerMagnify.js.html +48 -42
- package/coverage/lcov-report/{components → src/components}/MlLayerMagnify/index.html +31 -25
- package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/MlLayerSwipe.js.html +45 -42
- package/coverage/lcov-report/{components → src/components}/MlLayerSwipe/index.html +31 -25
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +755 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +380 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +117 -0
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +117 -0
- package/coverage/lcov-report/{components → src/components}/MlMarker/MlMarker.js.html +18 -12
- package/coverage/lcov-report/{components → src/components}/MlMarker/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/MlNavigationCompass.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlNavigationCompass/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlNavigationTools/MlNavigationTools.js.html +55 -37
- package/coverage/lcov-report/{components → src/components}/MlNavigationTools/index.html +23 -17
- package/coverage/lcov-report/{components → src/components}/MlOsmLayer/MlOsmLayer.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlOsmLayer/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlScaleReference/MlScaleReference.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlScaleReference/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlShareMapState/MlShareMapState.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlShareMapState/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlSpatialElevationProfile/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/MlThreeJsLayer.js.html +37 -55
- package/coverage/lcov-report/{components → src/components}/MlThreeJsLayer/index.html +31 -25
- package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/MlUseMapDebugger.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlUseMapDebugger/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/MlVectorTileLayer.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlVectorTileLayer/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlWmsFeatureInfoPopup/index.html +17 -11
- package/coverage/lcov-report/{components → src/components}/MlWmsLayer/MlWmsLayer.js.html +20 -14
- package/coverage/lcov-report/{components → src/components}/MlWmsLayer/index.html +21 -15
- package/coverage/lcov-report/{components → src/components}/MlWmsLoader/MlWmsLoader.js.html +38 -20
- package/coverage/lcov-report/{components → src/components}/MlWmsLoader/index.html +23 -17
- package/coverage/lcov-report/{hooks → src/hooks}/index.html +17 -11
- package/coverage/lcov-report/{hooks → src/hooks}/useMap.js.html +17 -11
- package/coverage/lcov-report/{hooks → src/hooks}/useMapState.js.html +17 -11
- package/coverage/lcov-report/{hooks → src/hooks}/useWms.js.html +25 -19
- package/coverage/lcov-report/src/i18n.js.html +167 -0
- package/coverage/lcov-report/src/index.html +117 -0
- package/coverage/lcov-report/src/translations/english.js.html +95 -0
- package/coverage/lcov-report/src/translations/german.js.html +95 -0
- package/coverage/lcov-report/src/translations/index.html +132 -0
- package/coverage/lcov.info +1278 -1010
- package/dist/b556faa3bc6829d2.png +0 -0
- package/dist/index.esm.js +170 -109
- package/dist/index.esm.js.map +1 -1
- package/package.json +3 -1
- package/public/assets/dop.png +0 -0
- package/public/assets/historic.png +0 -0
- package/public/assets/osm.png +0 -0
- package/public/thumbnails/MlFollowGps.png +0 -0
- package/public/thumbnails/MlThreeJsLayer.png +0 -0
- package/rollup.config.js +10 -2
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +58 -73
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta.json +1 -1
- package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -2
- package/src/components/MlFollowGps/MlFollowGps.js +46 -31
- package/src/components/MlFollowGps/MlFollowGps.meta.json +2 -2
- package/src/components/MlFollowGps/assets/marker.png +0 -0
- package/src/components/MlGPXViewer/MlGPXViewer.js +45 -43
- package/src/components/MlGPXViewer/gpxConverter.js +22 -29
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +27 -9
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -1
- package/src/components/MlGeoJsonLayer/util/transitionFunctions.js +19 -12
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +3 -4
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +6 -7
- package/src/components/MlLayer/MlLayer.js +2 -2
- package/src/components/MlLayer/MlLayer.test.js +12 -10
- package/src/components/MlLayerMagnify/MlLayerMagnify.js +3 -3
- package/src/components/MlLayerSwipe/MlLayerSwipe.js +4 -5
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.css +17 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.doc.de.md +3 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +223 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.meta_.json +15 -0
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +106 -0
- package/src/components/MlLayerSwitcher/assets/sample_1.json +26 -0
- package/src/components/MlLayerSwitcher/assets/sample_2.json +22 -0
- package/src/components/MlLayerSwitcher/components/LayerBox.js +98 -0
- package/src/components/MlMarker/MlMarker.js +1 -1
- package/src/components/MlNavigationTools/MlNavigationTools.js +26 -22
- package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -1
- package/src/components/MlScaleReference/MlScaleReference.stories.js +25 -21
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +12 -6
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +8 -15
- package/src/components/MlVectorTileLayer/MlVectorTileLayer.meta.json +3 -3
- package/src/components/MlWmsLayer/MlWmsLayer.js +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.js +8 -4
- package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.stories.js +5 -4
- package/src/decorators/EmptyMapContextDecorator.js +11 -6
- package/src/decorators/MapContext3DDecorator.js +25 -20
- package/src/decorators/MapContextDashboardDecorator.js +7 -7
- package/src/decorators/MapContextDecorator.js +7 -8
- package/src/decorators/MapContextKlokantechBasicDecorator.js +8 -9
- package/src/decorators/MultiMapContextDecorator.js +2 -6
- package/src/hooks/useMapState.stories.js +7 -2
- package/src/hooks/useWms.js +7 -6
- package/src/i18n.js +28 -0
- package/src/translations/english.js +4 -0
- package/src/translations/german.js +4 -0
- package/src/ui_components/ImageLoader.js +73 -0
- package/src/ui_components/Sidebar.js +76 -22
- package/src/ui_components/TopToolbar.js +18 -18
|
@@ -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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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 {
|
|
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,17 +23,19 @@ 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: "
|
|
27
|
-
minHeight: "
|
|
28
|
-
width: "30px",
|
|
29
|
-
height: "30px",
|
|
28
|
+
minWidth: "20px",
|
|
29
|
+
minHeight: "20px",
|
|
30
|
+
width: mediaIsMobile ? "50px" : "30px",
|
|
31
|
+
height: mediaIsMobile ? "50px" : "30px",
|
|
30
32
|
color: "#bbb",
|
|
31
33
|
backgroundColor: "#414141",
|
|
32
34
|
borderRadius: "23%",
|
|
33
35
|
//border: "1px solid #bbb",
|
|
34
36
|
//boxShadow: "0px 0px 4px rgba(0,0,0,.5)",
|
|
35
37
|
margin: 0.15,
|
|
38
|
+
fontSize: mediaIsMobile ? "1.5em" : "1.2em",
|
|
36
39
|
":hover": {
|
|
37
40
|
backgroundColor: "#515151",
|
|
38
41
|
color: "#ececec",
|
|
@@ -77,7 +80,7 @@ const MlNavigationTools = (props) => {
|
|
|
77
80
|
if (!mapRef.current) return;
|
|
78
81
|
|
|
79
82
|
if (mapRef.current.transform._zoom + 0.5 <= mapRef.current.transform._maxZoom) {
|
|
80
|
-
mapRef.current.easeTo({
|
|
83
|
+
mapRef.current.easeTo({zoom: mapRef.current.transform._zoom + 0.5});
|
|
81
84
|
}
|
|
82
85
|
};
|
|
83
86
|
|
|
@@ -85,7 +88,7 @@ const MlNavigationTools = (props) => {
|
|
|
85
88
|
if (!mapRef.current) return;
|
|
86
89
|
|
|
87
90
|
if (mapRef.current.transform._zoom - 0.5 >= mapRef.current.transform._minZoom) {
|
|
88
|
-
mapRef.current.easeTo({
|
|
91
|
+
mapRef.current.easeTo({zoom: mapRef.current.transform._zoom - 0.5});
|
|
89
92
|
}
|
|
90
93
|
};
|
|
91
94
|
|
|
@@ -96,7 +99,7 @@ const MlNavigationTools = (props) => {
|
|
|
96
99
|
if (mapRef.current.getPitch() !== 0) {
|
|
97
100
|
targetPitch = 0;
|
|
98
101
|
}
|
|
99
|
-
mapRef.current.easeTo({
|
|
102
|
+
mapRef.current.easeTo({pitch: targetPitch});
|
|
100
103
|
};
|
|
101
104
|
|
|
102
105
|
const moveToCurrentLocation = () => {
|
|
@@ -117,8 +120,8 @@ const MlNavigationTools = (props) => {
|
|
|
117
120
|
style={{
|
|
118
121
|
zIndex: 501,
|
|
119
122
|
position: "absolute",
|
|
120
|
-
right: "
|
|
121
|
-
bottom: "20px",
|
|
123
|
+
right: mediaIsMobile ? "15px" : "5px",
|
|
124
|
+
bottom: mediaIsMobile ? "40px" : "20px",
|
|
122
125
|
display: "flex",
|
|
123
126
|
flexDirection: "column",
|
|
124
127
|
}}
|
|
@@ -127,34 +130,35 @@ const MlNavigationTools = (props) => {
|
|
|
127
130
|
style={{
|
|
128
131
|
width: "31px",
|
|
129
132
|
position: "relative",
|
|
130
|
-
height: "
|
|
131
|
-
marginLeft: "-5px",
|
|
133
|
+
height: mediaIsMobile ? "55px" : "45px",
|
|
134
|
+
marginLeft: mediaIsMobile ? "3px" : "-5px",
|
|
135
|
+
transform: mediaIsMobile ? "scale(1.6)" : "scale(1)"
|
|
132
136
|
}}
|
|
133
137
|
backgroundStyle={{
|
|
134
138
|
boxShadow: "0px 0px 18px rgba(0,0,0,.5)",
|
|
135
139
|
}}
|
|
136
140
|
/>
|
|
137
|
-
<Button sx={{
|
|
141
|
+
<Button sx={{...buttonStyle, fontWeight: 600}} onClick={adjustPitch}>
|
|
138
142
|
{pitch ? "2D" : "3D"}
|
|
139
143
|
</Button>
|
|
140
144
|
<Button sx={buttonStyle} onClick={moveToCurrentLocation} disabled={locationAccessDenied}>
|
|
141
|
-
<GpsFixedIcon sx={{
|
|
145
|
+
<GpsFixedIcon sx={{fontSize: mediaIsMobile ? "1.5em" : "1.2em"}}/>
|
|
142
146
|
</Button>
|
|
143
|
-
<MlFollowGps />
|
|
147
|
+
<MlFollowGps style={buttonStyle}/>
|
|
144
148
|
<ButtonGroup
|
|
145
149
|
orientation="vertical"
|
|
146
150
|
sx={{
|
|
147
|
-
width: "
|
|
151
|
+
width: "50px",
|
|
148
152
|
border: "none",
|
|
149
|
-
Button: {
|
|
150
|
-
"Button:hover": {
|
|
153
|
+
Button: {minWidth: "20px !important", border: "none", padding: 0},
|
|
154
|
+
"Button:hover": {border: "none"},
|
|
151
155
|
}}
|
|
152
156
|
>
|
|
153
157
|
<Button sx={buttonStyle} onClick={zoomIn}>
|
|
154
|
-
<ControlPointIcon />
|
|
158
|
+
<ControlPointIcon sx={{fontSize: mediaIsMobile ? "1.5em" : "1.2em"}}/>
|
|
155
159
|
</Button>
|
|
156
160
|
<Button sx={buttonStyle} onClick={zoomOut}>
|
|
157
|
-
<RemoveCircleOutlineIcon />
|
|
161
|
+
<RemoveCircleOutlineIcon sx={{fontSize: mediaIsMobile ? "1.5em" : "1.2em"}}/>
|
|
158
162
|
</Button>
|
|
159
163
|
</ButtonGroup>
|
|
160
164
|
</div>
|
|
@@ -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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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 = {
|
|
@@ -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="
|
|
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.
|
|
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
|
-
|
|
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": "
|
|
4
|
-
"description": "
|
|
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": [
|
|
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(
|
|
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:
|
|
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
|
-
|
|
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),
|
|
@@ -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={{
|
|
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/
|
|
46
|
+
url: "https://www.wms.nrw.de/wms/kitas",
|
|
46
47
|
};
|