@mapcomponents/react-maplibre 0.1.54 → 0.1.57
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/CHANGELOG.md +31 -1
- package/coverage/clover.xml +89 -83
- package/coverage/coverage-final.json +3 -3
- package/coverage/lcov-report/index.html +22 -22
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +123 -36
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +15 -15
- package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +2 -2
- package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +42 -12
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +3 -3
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +1 -1
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +7 -7
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +11 -11
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +1 -1
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +1 -1
- package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
- package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
- package/coverage/lcov-report/src/contexts/index.html +1 -1
- package/coverage/lcov-report/src/hooks/index.html +1 -1
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useMap.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useMapState.ts.html +1 -1
- package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +5 -2
- package/coverage/lcov.info +172 -161
- package/dist/components/MlFollowGps/MlFollowGps.d.ts +26 -6
- package/dist/components/MlLayer/MlLayer.d.ts +1 -1
- package/dist/components/MlNavigationTools/MlNavigationTools.d.ts +9 -0
- package/dist/components/MlNavigationTools/MlNavigationTools.stories.d.ts +1 -0
- package/dist/decorators/ThemeWrapper.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +348 -173
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MlFollowGps/MlFollowGps.stories.js +4 -2
- package/src/components/MlFollowGps/MlFollowGps.tsx +53 -24
- package/src/components/MlLayer/MlLayer.tsx +1 -1
- package/src/components/MlNavigationTools/MlNavigationTools.stories.js +6 -0
- package/src/components/MlNavigationTools/MlNavigationTools.tsx +19 -9
- package/src/components/MlScaleReference/MlScaleReference.stories.js +22 -24
- package/src/decorators/MapContextDecorator.js +9 -10
- package/src/decorators/MultiMapContextDecorator.js +54 -55
- package/src/decorators/ThemeWrapper.jsx +9 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -13,8 +13,10 @@ const storyoptions = {
|
|
|
13
13
|
};
|
|
14
14
|
export default storyoptions;
|
|
15
15
|
|
|
16
|
-
const Template = (
|
|
16
|
+
const Template = (props) => <MlFollowGps {...props}/>;
|
|
17
17
|
|
|
18
18
|
export const ExampleConfig = Template.bind({});
|
|
19
19
|
ExampleConfig.parameters = {};
|
|
20
|
-
ExampleConfig.args = {
|
|
20
|
+
ExampleConfig.args = {
|
|
21
|
+
followUserPosition: false
|
|
22
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React, { useEffect, useState, useCallback, useMemo } from "react";
|
|
1
|
+
import React, { useRef, useEffect, useState, useCallback, useMemo } from "react";
|
|
2
2
|
import useMap from "../../hooks/useMap";
|
|
3
3
|
import MlGeoJsonLayer from "../MlGeoJsonLayer/MlGeoJsonLayer";
|
|
4
4
|
|
|
5
|
-
import { Button } from "@mui/material";
|
|
6
|
-
import
|
|
5
|
+
import { Button, SxProps } from "@mui/material";
|
|
6
|
+
import GpsFixedIcon from "@mui/icons-material/GpsFixed";
|
|
7
7
|
|
|
8
8
|
import { point, circle, lineArc, Feature, Point } from "@turf/turf";
|
|
9
|
+
import { CircleLayerSpecification, FillLayerSpecification } from "maplibre-gl";
|
|
9
10
|
|
|
10
11
|
interface MlFollowGpsProps {
|
|
11
12
|
/**
|
|
@@ -30,13 +31,29 @@ interface MlFollowGpsProps {
|
|
|
30
31
|
* By default, if showUserLocation is true, a transparent circle will be drawn around the user location
|
|
31
32
|
* indicating the accuracy (95% confidence level) of the user's location. Set to false to disable.
|
|
32
33
|
*/
|
|
33
|
-
showAccuracyCircle?: boolean
|
|
34
|
+
showAccuracyCircle?: boolean;
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
+
* Use the MapLibre.flyTo function to center the map to the current users position if true.
|
|
37
|
+
* Otherwise the MapLibre.setCenter function is used.
|
|
38
|
+
*/
|
|
39
|
+
useFlyTo?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Center map to current position once updated location data is recieved.
|
|
42
|
+
* "false" will center the map once on component activation and then display the updated user location on the map.
|
|
43
|
+
*/
|
|
44
|
+
centerUserPosition?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Orientation cone paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the orientation cone polygon.
|
|
36
47
|
* Use any available paint prop from layer type "fill".
|
|
37
48
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
38
49
|
*/
|
|
39
|
-
|
|
50
|
+
orientationConePaint?: FillLayerSpecification["paint"];
|
|
51
|
+
/**
|
|
52
|
+
* Position circle paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the position circle.
|
|
53
|
+
* Use any available paint prop from layer type "circle".
|
|
54
|
+
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
55
|
+
*/
|
|
56
|
+
circlePaint?: CircleLayerSpecification["paint"];
|
|
40
57
|
/**
|
|
41
58
|
* Active button font color
|
|
42
59
|
*/
|
|
@@ -46,15 +63,15 @@ interface MlFollowGpsProps {
|
|
|
46
63
|
*/
|
|
47
64
|
offColor?: string;
|
|
48
65
|
/**
|
|
49
|
-
* Accuracy paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy
|
|
66
|
+
* Accuracy paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy polygon.
|
|
50
67
|
* Use any available paint prop from layer type "fill".
|
|
51
68
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
52
69
|
*/
|
|
53
|
-
accuracyPaint?:
|
|
70
|
+
accuracyPaint?: FillLayerSpecification["paint"];
|
|
54
71
|
/**
|
|
55
72
|
* CSS style object that is applied to the button component
|
|
56
73
|
*/
|
|
57
|
-
|
|
74
|
+
buttonSx?: SxProps | any;
|
|
58
75
|
}
|
|
59
76
|
|
|
60
77
|
/**
|
|
@@ -69,22 +86,30 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
69
86
|
});
|
|
70
87
|
|
|
71
88
|
const [isFollowed, setIsFollowed] = useState(false);
|
|
72
|
-
const [userLocationGeoJson, setUserLocationGeoJson] =
|
|
73
|
-
useState<Feature<Point>>();
|
|
89
|
+
const [userLocationGeoJson, setUserLocationGeoJson] = useState<Feature<Point>>();
|
|
74
90
|
const [locationAccessDenied, setLocationAccessDenied] = useState(false);
|
|
75
91
|
const [accuracyGeoJson, setAccuracyGeoJson] = useState<Feature>();
|
|
76
92
|
const [deviceOrientation, setDeviceOrientation] = useState(0);
|
|
93
|
+
const initiallyCentered = useRef(false);
|
|
77
94
|
|
|
78
95
|
const getLocationSuccess = useCallback(
|
|
79
96
|
(pos) => {
|
|
80
97
|
if (!mapHook.map) return;
|
|
81
98
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
if ((!props.centerUserPosition && !initiallyCentered.current) || props.centerUserPosition) {
|
|
100
|
+
if (props.useFlyTo) {
|
|
101
|
+
mapHook.map.map.flyTo({
|
|
102
|
+
center: [pos.coords.longitude, pos.coords.latitude],
|
|
103
|
+
zoom: 18,
|
|
104
|
+
speed: 1,
|
|
105
|
+
curve: 1,
|
|
106
|
+
});
|
|
107
|
+
} else {
|
|
108
|
+
mapHook.map.map.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
initiallyCentered.current = true;
|
|
112
|
+
}
|
|
88
113
|
if (!props.showUserLocation) return;
|
|
89
114
|
const geoJsonPoint = point([pos.coords.longitude, pos.coords.latitude]);
|
|
90
115
|
setUserLocationGeoJson(geoJsonPoint);
|
|
@@ -124,6 +149,8 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
124
149
|
return () => {
|
|
125
150
|
window.removeEventListener("deviceorientation", _handleOrientation);
|
|
126
151
|
};
|
|
152
|
+
} else {
|
|
153
|
+
initiallyCentered.current = false;
|
|
127
154
|
}
|
|
128
155
|
return;
|
|
129
156
|
}, [isFollowed]);
|
|
@@ -132,10 +159,7 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
132
159
|
if (!mapHook.map) return;
|
|
133
160
|
|
|
134
161
|
if (isFollowed) {
|
|
135
|
-
let _watchId = navigator.geolocation.watchPosition(
|
|
136
|
-
getLocationSuccess,
|
|
137
|
-
getLocationError
|
|
138
|
-
);
|
|
162
|
+
let _watchId = navigator.geolocation.watchPosition(getLocationSuccess, getLocationError);
|
|
139
163
|
|
|
140
164
|
return () => {
|
|
141
165
|
navigator.geolocation.clearWatch(_watchId);
|
|
@@ -167,6 +191,7 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
167
191
|
"fill-color": "#0000ff",
|
|
168
192
|
"fill-antialias": false,
|
|
169
193
|
"fill-opacity": 0.3,
|
|
194
|
+
...props.orientationConePaint,
|
|
170
195
|
}}
|
|
171
196
|
insertBeforeLayer={props.insertBeforeLayer}
|
|
172
197
|
/>
|
|
@@ -191,7 +216,7 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
191
216
|
sx={{
|
|
192
217
|
zIndex: 1002,
|
|
193
218
|
color: isFollowed ? props.onColor : props.offColor,
|
|
194
|
-
...props.
|
|
219
|
+
...props.buttonSx,
|
|
195
220
|
}}
|
|
196
221
|
disabled={locationAccessDenied}
|
|
197
222
|
onClick={() => {
|
|
@@ -199,7 +224,9 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
199
224
|
}}
|
|
200
225
|
>
|
|
201
226
|
{" "}
|
|
202
|
-
<GpsFixedIcon
|
|
227
|
+
<GpsFixedIcon
|
|
228
|
+
sx={{ ...(props.buttonSx?.fontSize ? { fontSize: props.buttonSx?.fontSize } : {}) }}
|
|
229
|
+
/>{" "}
|
|
203
230
|
</Button>
|
|
204
231
|
</>
|
|
205
232
|
);
|
|
@@ -207,7 +234,7 @@ const MlFollowGps = (props: MlFollowGpsProps) => {
|
|
|
207
234
|
|
|
208
235
|
MlFollowGps.defaultProps = {
|
|
209
236
|
mapId: undefined,
|
|
210
|
-
|
|
237
|
+
buttonSx: {
|
|
211
238
|
minWidth: "30px",
|
|
212
239
|
minHeight: "30px",
|
|
213
240
|
width: "30px",
|
|
@@ -226,6 +253,8 @@ MlFollowGps.defaultProps = {
|
|
|
226
253
|
showAccuracyCircle: true,
|
|
227
254
|
showUserLocation: true,
|
|
228
255
|
showOrientation: true,
|
|
256
|
+
centerUserPosition: true,
|
|
257
|
+
useFlyTo: false,
|
|
229
258
|
};
|
|
230
259
|
|
|
231
260
|
export default MlFollowGps;
|
|
@@ -36,6 +36,12 @@ ShowCenterLocationButton.args = {
|
|
|
36
36
|
showCenterLocationButton: true,
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
export const AlterToolPosition = Template.bind({});
|
|
40
|
+
AlterToolPosition.parameters = {};
|
|
41
|
+
AlterToolPosition.args = {
|
|
42
|
+
sx: { top: "10px", right: "5px" },
|
|
43
|
+
};
|
|
44
|
+
|
|
39
45
|
export const NoZoomButtons = Template.bind({});
|
|
40
46
|
NoZoomButtons.parameters = {};
|
|
41
47
|
NoZoomButtons.args = {
|
|
@@ -3,6 +3,8 @@ import Button from "@mui/material/Button";
|
|
|
3
3
|
import ButtonGroup from "@mui/material/ButtonGroup";
|
|
4
4
|
import ControlPointIcon from "@mui/icons-material/ControlPoint";
|
|
5
5
|
import RemoveCircleOutlineIcon from "@mui/icons-material/RemoveCircleOutline";
|
|
6
|
+
import Box from "@mui/material/Box";
|
|
7
|
+
import { SxProps } from "@mui/material";
|
|
6
8
|
|
|
7
9
|
import MlNavigationCompass from "../MlNavigationCompass/MlNavigationCompass";
|
|
8
10
|
import MlFollowGps from "../MlFollowGps/MlFollowGps";
|
|
@@ -40,6 +42,10 @@ interface MlNavigationToolsProps {
|
|
|
40
42
|
* Additional JSX Elements to be rendered below MlNavigationTools buttons
|
|
41
43
|
*/
|
|
42
44
|
children?: JSX.Element;
|
|
45
|
+
/**
|
|
46
|
+
* Style attribute for NavigationTools container
|
|
47
|
+
*/
|
|
48
|
+
sx?: SxProps;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
/**
|
|
@@ -71,7 +77,7 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
71
77
|
};
|
|
72
78
|
const iconStyle = {
|
|
73
79
|
fontSize: buttonStyle.fontSize,
|
|
74
|
-
}
|
|
80
|
+
};
|
|
75
81
|
|
|
76
82
|
useEffect(() => {
|
|
77
83
|
if (!mapHook.map) return;
|
|
@@ -115,14 +121,14 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
115
121
|
};
|
|
116
122
|
|
|
117
123
|
return (
|
|
118
|
-
<
|
|
119
|
-
|
|
124
|
+
<Box
|
|
125
|
+
sx={{
|
|
120
126
|
zIndex: 501,
|
|
121
127
|
position: "absolute",
|
|
122
|
-
right: mediaIsMobile ? "15px" : "5px",
|
|
123
|
-
bottom: mediaIsMobile ? "40px" : "20px",
|
|
124
128
|
display: "flex",
|
|
125
129
|
flexDirection: "column",
|
|
130
|
+
...(mediaIsMobile ? { margin: "20px 10px 20px 10px" } : {}),
|
|
131
|
+
...props.sx,
|
|
126
132
|
}}
|
|
127
133
|
>
|
|
128
134
|
<MlNavigationCompass
|
|
@@ -146,7 +152,7 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
146
152
|
</Button>
|
|
147
153
|
)}
|
|
148
154
|
{props.showFollowGpsButton && (
|
|
149
|
-
<MlFollowGps
|
|
155
|
+
<MlFollowGps buttonSx={{ ...(({ color, ...rest }) => rest)(buttonStyle) }} />
|
|
150
156
|
)}
|
|
151
157
|
{props.showCenterLocationButton && (
|
|
152
158
|
<MlCenterPosition style={{ ...(({ color, ...rest }) => rest)(buttonStyle) }} />
|
|
@@ -163,10 +169,10 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
163
169
|
{props.showZoomButtons && (
|
|
164
170
|
<>
|
|
165
171
|
<Button sx={{ ...buttonStyle }} onClick={zoomIn}>
|
|
166
|
-
<ControlPointIcon sx={{...iconStyle}} />
|
|
172
|
+
<ControlPointIcon sx={{ ...iconStyle }} />
|
|
167
173
|
</Button>
|
|
168
174
|
<Button sx={{ ...buttonStyle }} onClick={zoomOut}>
|
|
169
|
-
<RemoveCircleOutlineIcon
|
|
175
|
+
<RemoveCircleOutlineIcon sx={{ ...iconStyle }} />
|
|
170
176
|
</Button>
|
|
171
177
|
</>
|
|
172
178
|
)}
|
|
@@ -175,7 +181,7 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
175
181
|
React.cloneElement(props.children, {
|
|
176
182
|
sx: { ...buttonStyle },
|
|
177
183
|
})}
|
|
178
|
-
</
|
|
184
|
+
</Box>
|
|
179
185
|
);
|
|
180
186
|
};
|
|
181
187
|
|
|
@@ -185,6 +191,10 @@ MlNavigationTools.defaultProps = {
|
|
|
185
191
|
showFollowGpsButton: true,
|
|
186
192
|
showCenterLocationButton: false,
|
|
187
193
|
showZoomButtons: true,
|
|
194
|
+
sx: {
|
|
195
|
+
right: "5px",
|
|
196
|
+
bottom: "20px",
|
|
197
|
+
},
|
|
188
198
|
};
|
|
189
199
|
|
|
190
200
|
export default MlNavigationTools;
|
|
@@ -17,37 +17,35 @@ const storyoptions = {
|
|
|
17
17
|
};
|
|
18
18
|
export default storyoptions;
|
|
19
19
|
|
|
20
|
-
const
|
|
20
|
+
const ToolbarTemplate = (props) => {
|
|
21
|
+
return (
|
|
22
|
+
<TopToolbar>
|
|
23
|
+
<MlScaleReference {...props} />
|
|
24
|
+
</TopToolbar>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
const OverlayTemplate = (props) => {
|
|
21
28
|
const mediaIsMobile = useMediaQuery("(max-width:900px)");
|
|
22
|
-
return(
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
zIndex: 100000,
|
|
34
|
-
bottom: mediaIsMobile ? "40px" : "20px",
|
|
35
|
-
right: "20px",
|
|
36
|
-
}}
|
|
37
|
-
>
|
|
38
|
-
<MlScaleReference {...props} />
|
|
39
|
-
</div>
|
|
40
|
-
)}
|
|
41
|
-
</>
|
|
29
|
+
return (
|
|
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>
|
|
42
40
|
);
|
|
43
|
-
}
|
|
41
|
+
};
|
|
44
42
|
|
|
45
|
-
export const Toolbar =
|
|
43
|
+
export const Toolbar = ToolbarTemplate.bind({});
|
|
46
44
|
Toolbar.args = {
|
|
47
45
|
show: "toolbar",
|
|
48
46
|
};
|
|
49
47
|
|
|
50
|
-
export const Overlay =
|
|
48
|
+
export const Overlay = OverlayTemplate.bind({});
|
|
51
49
|
Overlay.args = {
|
|
52
50
|
show: "overlay",
|
|
53
51
|
};
|
|
@@ -3,17 +3,15 @@ import React from "react";
|
|
|
3
3
|
import { MapComponentsProvider } from "../index";
|
|
4
4
|
import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
|
|
5
5
|
import "./style.css";
|
|
6
|
-
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
7
6
|
import MlNavgiationTools from "../components/MlNavigationTools/MlNavigationTools";
|
|
8
|
-
|
|
9
|
-
const theme = createTheme({});
|
|
7
|
+
import ThemeWrapper from "./ThemeWrapper";
|
|
10
8
|
|
|
11
9
|
const decorators = [
|
|
12
10
|
(Story) => (
|
|
13
11
|
<div className="fullscreen_map">
|
|
14
|
-
<
|
|
12
|
+
<ThemeWrapper>
|
|
15
13
|
<MapComponentsProvider>
|
|
16
|
-
|
|
14
|
+
{Story()}
|
|
17
15
|
<MapLibreMap
|
|
18
16
|
options={{
|
|
19
17
|
zoom: 14.5,
|
|
@@ -22,12 +20,13 @@ const decorators = [
|
|
|
22
20
|
}}
|
|
23
21
|
mapId="map_1"
|
|
24
22
|
/>
|
|
25
|
-
<MlNavgiationTools
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
<MlNavgiationTools
|
|
24
|
+
sx={{ top: "10px", right: "5px" }}
|
|
25
|
+
showZoomButtons={false}
|
|
26
|
+
mapId="map_1"
|
|
27
|
+
/>
|
|
29
28
|
</MapComponentsProvider>
|
|
30
|
-
</
|
|
29
|
+
</ThemeWrapper>
|
|
31
30
|
</div>
|
|
32
31
|
),
|
|
33
32
|
];
|
|
@@ -4,74 +4,73 @@ import { MapComponentsProvider } from "../index";
|
|
|
4
4
|
|
|
5
5
|
import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
import "./style.css";
|
|
9
8
|
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
10
9
|
import MlNavgiationTools from "../components/MlNavigationTools/MlNavigationTools";
|
|
11
10
|
|
|
12
11
|
const theme = createTheme({});
|
|
13
12
|
|
|
14
|
-
|
|
15
13
|
const decorators = [
|
|
16
14
|
(Story) => (
|
|
17
15
|
<div className="fullscreen_map">
|
|
18
16
|
<ThemeProvider theme={theme}>
|
|
19
17
|
<MapComponentsProvider>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<MlNavgiationTools
|
|
70
|
-
mapId="map_1">
|
|
18
|
+
<div
|
|
19
|
+
style={{
|
|
20
|
+
overflow: "hidden",
|
|
21
|
+
position: "absolute",
|
|
22
|
+
top: "0",
|
|
23
|
+
bottom: "0",
|
|
24
|
+
left: "0",
|
|
25
|
+
right: "0",
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<Story />
|
|
29
|
+
<div className="maps">
|
|
30
|
+
<MapLibreMap
|
|
31
|
+
mapId="map_1"
|
|
32
|
+
options={{
|
|
33
|
+
//style: "mapbox://styles/mapbox/light-v10",
|
|
34
|
+
//center: [-87.62712, 41.89033],
|
|
35
|
+
zoom: 14.5,
|
|
36
|
+
//pitch: 45,
|
|
37
|
+
//style: "https://wms.wheregroup.com/tileserver/style/osm-bright.json",
|
|
38
|
+
style: "https://wms.wheregroup.com/tileserver/style/osm-liberty.json",
|
|
39
|
+
//center: [8.607, 53.1409349],
|
|
40
|
+
//zoom: 13,
|
|
41
|
+
center: [7.0851268, 50.73884],
|
|
42
|
+
//maxBounds: [
|
|
43
|
+
// [1.40625, 43.452919],
|
|
44
|
+
// [17.797852, 55.973798],
|
|
45
|
+
//],
|
|
46
|
+
}}
|
|
47
|
+
/>
|
|
48
|
+
<MapLibreMap
|
|
49
|
+
mapId="map_2"
|
|
50
|
+
options={{
|
|
51
|
+
//style: "mapbox://styles/mapbox/light-v10",
|
|
52
|
+
//center: [-87.62712, 41.89033],
|
|
53
|
+
zoom: 14.5,
|
|
54
|
+
//pitch: 45,
|
|
55
|
+
style: "https://wms.wheregroup.com/tileserver/style/osm-bright.json",
|
|
56
|
+
//style: "https://wms.wheregroup.com/tileserver/style/osm-liberty.json",
|
|
57
|
+
//center: [8.607, 53.1409349],
|
|
58
|
+
//zoom: 13,
|
|
59
|
+
center: [7.0851268, 50.73884],
|
|
60
|
+
//maxBounds: [
|
|
61
|
+
// [1.40625, 43.452919],
|
|
62
|
+
// [17.797852, 55.973798],
|
|
63
|
+
//],
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
<MlNavgiationTools
|
|
68
|
+
sx={{ top: "10px", right: "5px" }}
|
|
69
|
+
showZoomButtons={false}
|
|
70
|
+
mapId="map_1"
|
|
71
|
+
/>
|
|
74
72
|
</div>
|
|
73
|
+
</div>
|
|
75
74
|
</MapComponentsProvider>
|
|
76
75
|
</ThemeProvider>
|
|
77
76
|
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ThemeProvider } from "@mui/styles";
|
|
3
|
+
import { createTheme } from "@mui/material";
|
|
4
|
+
|
|
5
|
+
const theme = createTheme({});
|
|
6
|
+
|
|
7
|
+
export default function ThemeWrapper(props) {
|
|
8
|
+
return <ThemeProvider theme={theme}>{props?.children}</ThemeProvider>;
|
|
9
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { default as MlNavigationCompass } from "./components/MlNavigationCompass
|
|
|
12
12
|
export { default as MlLayer } from "./components/MlLayer/MlLayer";
|
|
13
13
|
export { default as MlVectorTileLayer } from "./components/MlVectorTileLayer/MlVectorTileLayer";
|
|
14
14
|
export { default as MlWmsLayer } from "./components/MlWmsLayer/MlWmsLayer";
|
|
15
|
+
export { default as MlScaleReference } from "./components/MlScaleReference/MlScaleReference";
|
|
15
16
|
|
|
16
17
|
export { default as MlLayerMagnify } from "./components/MlLayerMagnify/MlLayerMagnify";
|
|
17
18
|
export { default as MlLayerSwipe } from "./components/MlLayerSwipe/MlLayerSwipe";
|