@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.
- package/.github/workflows/storybook.yml +10 -5
- package/coverage/clover.xml +894 -747
- package/coverage/coverage-final.json +22 -17
- package/coverage/lcov-report/block-navigation.js +8 -0
- package/coverage/lcov-report/index.html +188 -122
- 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 +84 -69
- 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 +162 -48
- package/coverage/lcov-report/{components → src/components}/MlGeoJsonLayer/index.html +35 -29
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +311 -0
- package/coverage/lcov-report/{components → src/components}/MlImageMarkerLayer/index.html +35 -29
- package/coverage/lcov-report/{components/MlImageMarkerLayer/MlImageMarkerLayer.js.html → src/components/MlLayer/MlLayer.js.html} +123 -126
- package/coverage/lcov-report/src/components/MlLayer/index.html +117 -0
- 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 +57 -42
- package/coverage/lcov-report/{components → src/components}/MlNavigationTools/index.html +25 -19
- 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 +224 -26
- package/coverage/lcov-report/{components → src/components}/MlShareMapState/index.html +25 -19
- 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/src/hooks/index.html +147 -0
- package/coverage/lcov-report/{components/MlLayer/MlLayer.js.html → src/hooks/useMap.js.html} +86 -119
- package/coverage/lcov-report/{hooks → src/hooks}/useMapState.js.html +98 -92
- 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 +1620 -1306
- package/dist/b556faa3bc6829d2.png +0 -0
- package/dist/index.esm.js +976 -688
- 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 +7 -1
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +53 -67
- package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta.json +1 -1
- package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +2 -2
- package/src/components/MlFollowGps/MlFollowGps.js +49 -46
- 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 +45 -9
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -1
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +21 -57
- package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.test.js +6 -7
- package/src/components/MlLayer/MlLayer.js +28 -6
- 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 +29 -26
- package/src/components/MlScaleReference/MlScaleReference.meta.json +1 -1
- package/src/components/MlScaleReference/MlScaleReference.stories.js +25 -21
- package/src/components/MlShareMapState/MlShareMapState.js +73 -9
- package/src/components/MlShareMapState/MlShareMapState.stories.js +24 -1
- 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 -2
- package/src/decorators/MapContextDecorator.js +7 -3
- package/src/decorators/MapContextKlokantechBasicDecorator.js +8 -4
- package/src/decorators/MultiMapContextDecorator.js +2 -1
- package/src/hooks/useMap.js +36 -62
- package/src/hooks/useMapState.js +3 -3
- package/src/hooks/useWms.js +7 -6
- package/src/i18n.js +28 -0
- package/src/index.js +3 -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
- package/coverage/lcov-report/components/MlLayer/index.html +0 -111
- package/coverage/lcov-report/hooks/index.html +0 -141
- 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
|
-
|
|
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 = {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {useRef, useEffect, useContext, useState} from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
-
|
|
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
|
-
{
|
|
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
|
-
|
|
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({
|
|
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(
|
|
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="
|
|
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
|
};
|
|
@@ -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
|
-
<
|
|
11
|
-
<
|
|
12
|
-
<
|
|
13
|
+
<ThemeProvider theme={theme}>
|
|
14
|
+
<MapComponentsProvider>
|
|
15
|
+
<LoadingOverlayProvider>
|
|
16
|
+
<LoadingOverlay></LoadingOverlay>
|
|
13
17
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
<
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
<
|
|
11
|
+
<ThemeProvider theme={theme}>
|
|
12
|
+
<MapComponentsProvider>
|
|
9
13
|
<Story />
|
|
10
|
-
|
|
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
|
-
<
|
|
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
|
-
|
|
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
|
-
<
|
|
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
|
-
|
|
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">
|