@mapcomponents/react-maplibre 0.1.52 → 0.1.55
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 +25 -2
- package/coverage/clover.xml +32 -31
- package/coverage/coverage-final.json +2 -2
- package/coverage/lcov-report/index.html +13 -13
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
- 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 +20 -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 +107 -26
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +12 -12
- 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 +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov.info +81 -78
- package/dist/components/MlLayer/MlLayer.d.ts +5 -0
- package/dist/components/MlNavigationTools/MlNavigationTools.d.ts +14 -0
- package/dist/components/MlNavigationTools/MlNavigationTools.stories.d.ts +8 -3
- package/dist/decorators/NoNavToolsDecorator.d.ts +2 -0
- package/dist/index.esm.js +25 -17
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MlLayer/MlLayer.tsx +6 -0
- package/src/components/MlNavigationTools/MlNavigationTools.stories.js +41 -5
- package/src/components/MlNavigationTools/MlNavigationTools.tsx +46 -19
- package/src/decorators/NoNavToolsDecorator.js +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import useLayer from "../../hooks/useLayer";
|
|
4
|
+
import { Feature, FeatureCollection } from "@turf/turf";
|
|
4
5
|
|
|
5
6
|
interface MlLayerProps {
|
|
6
7
|
/**
|
|
@@ -20,6 +21,10 @@ interface MlLayerProps {
|
|
|
20
21
|
* Javascript object that is passed the addLayer command as first parameter.
|
|
21
22
|
*/
|
|
22
23
|
options?: any;
|
|
24
|
+
/**
|
|
25
|
+
* GeoJSON data that is supposed to be rendered by this component.
|
|
26
|
+
*/
|
|
27
|
+
geojson?: Feature | FeatureCollection | undefined;
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
/**
|
|
@@ -32,6 +37,7 @@ const MlLayer = (props: MlLayerProps) => {
|
|
|
32
37
|
idPrefix: 'MlLayer-',
|
|
33
38
|
layerId: props.layerId,
|
|
34
39
|
mapId: props.mapId,
|
|
40
|
+
geojson: props.geojson,
|
|
35
41
|
options: {
|
|
36
42
|
type: "background",
|
|
37
43
|
paint: {
|
|
@@ -2,7 +2,9 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
import MlNavigationTools from "./MlNavigationTools";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import noNavToolsDecorator from "../../decorators/NoNavToolsDecorator";
|
|
6
|
+
import BuildIcon from "@mui/icons-material/Build";
|
|
7
|
+
import Button from "@mui/material/Button";
|
|
6
8
|
|
|
7
9
|
const storyoptions = {
|
|
8
10
|
title: "MapComponents/MlNavigationTools",
|
|
@@ -11,13 +13,47 @@ const storyoptions = {
|
|
|
11
13
|
url: {},
|
|
12
14
|
layer: {},
|
|
13
15
|
},
|
|
14
|
-
decorators:
|
|
16
|
+
decorators: noNavToolsDecorator,
|
|
15
17
|
};
|
|
16
18
|
export default storyoptions;
|
|
17
19
|
|
|
18
20
|
const Template = (args) => <MlNavigationTools {...args} />;
|
|
19
21
|
|
|
20
|
-
export const
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
export const DefaultConfig = Template.bind({});
|
|
23
|
+
DefaultConfig.parameters = {};
|
|
24
|
+
DefaultConfig.args = {};
|
|
25
|
+
|
|
26
|
+
export const No3DButton = Template.bind({});
|
|
27
|
+
No3DButton.parameters = {};
|
|
28
|
+
No3DButton.args = {
|
|
29
|
+
show3DButton: false,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const ShowCenterLocationButton = Template.bind({});
|
|
33
|
+
ShowCenterLocationButton.parameters = {};
|
|
34
|
+
ShowCenterLocationButton.args = {
|
|
35
|
+
showFollowGpsButton: false,
|
|
36
|
+
showCenterLocationButton: true,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const NoZoomButtons = Template.bind({});
|
|
40
|
+
NoZoomButtons.parameters = {};
|
|
41
|
+
NoZoomButtons.args = {
|
|
42
|
+
showZoomButtons: false,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const NoFollowGpsButton = Template.bind({});
|
|
46
|
+
NoFollowGpsButton.parameters = {};
|
|
47
|
+
NoFollowGpsButton.args = {
|
|
48
|
+
showFollowGpsButton: false,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const CustomButton = Template.bind({});
|
|
52
|
+
CustomButton.parameters = {};
|
|
53
|
+
CustomButton.args = {
|
|
54
|
+
children: (
|
|
55
|
+
<Button onClick={() => {}}>
|
|
56
|
+
<BuildIcon sx={{ fontSize: "1em" }} />
|
|
57
|
+
</Button>
|
|
58
|
+
),
|
|
23
59
|
};
|
|
@@ -20,6 +20,14 @@ interface MlNavigationToolsProps {
|
|
|
20
20
|
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
21
21
|
*/
|
|
22
22
|
insertBeforeLayer?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Show 3D button
|
|
25
|
+
*/
|
|
26
|
+
show3DButton?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Show zoom button
|
|
29
|
+
*/
|
|
30
|
+
showZoomButtons?: boolean;
|
|
23
31
|
/**
|
|
24
32
|
* Show follow GPS button
|
|
25
33
|
*/
|
|
@@ -28,6 +36,10 @@ interface MlNavigationToolsProps {
|
|
|
28
36
|
* Show center on current position button
|
|
29
37
|
*/
|
|
30
38
|
showCenterLocationButton?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Additional JSX Elements to be rendered below MlNavigationTools buttons
|
|
41
|
+
*/
|
|
42
|
+
children?: JSX.Element;
|
|
31
43
|
}
|
|
32
44
|
|
|
33
45
|
/**
|
|
@@ -51,12 +63,15 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
51
63
|
//border: "1px solid #bbb",
|
|
52
64
|
//boxShadow: "0px 0px 4px rgba(0,0,0,.5)",
|
|
53
65
|
margin: 0.15,
|
|
54
|
-
fontSize: mediaIsMobile ? "1.
|
|
66
|
+
fontSize: mediaIsMobile ? "1.4em" : "1.2em",
|
|
55
67
|
":hover": {
|
|
56
68
|
backgroundColor: "#515151",
|
|
57
69
|
},
|
|
58
70
|
color: "#ececec",
|
|
59
71
|
};
|
|
72
|
+
const iconStyle = {
|
|
73
|
+
fontSize: buttonStyle.fontSize,
|
|
74
|
+
}
|
|
60
75
|
|
|
61
76
|
useEffect(() => {
|
|
62
77
|
if (!mapHook.map) return;
|
|
@@ -122,18 +137,20 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
122
137
|
boxShadow: "0px 0px 18px rgba(0,0,0,.5)",
|
|
123
138
|
}}
|
|
124
139
|
/>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
{props.show3DButton && (
|
|
141
|
+
<Button
|
|
142
|
+
sx={{ ...buttonStyle, fontSize: mediaIsMobile ? "1.4em" : "1em", fontWeight: 600 }}
|
|
143
|
+
onClick={adjustPitch}
|
|
144
|
+
>
|
|
145
|
+
{pitch ? "2D" : "3D"}
|
|
146
|
+
</Button>
|
|
147
|
+
)}
|
|
148
|
+
{props.showFollowGpsButton && (
|
|
149
|
+
<MlFollowGps style={{ ...(({ color, ...rest }) => rest)(buttonStyle) }} />
|
|
150
|
+
)}
|
|
151
|
+
{props.showCenterLocationButton && (
|
|
152
|
+
<MlCenterPosition style={{ ...(({ color, ...rest }) => rest)(buttonStyle) }} />
|
|
153
|
+
)}
|
|
137
154
|
<ButtonGroup
|
|
138
155
|
orientation="vertical"
|
|
139
156
|
sx={{
|
|
@@ -143,21 +160,31 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
143
160
|
"Button:hover": { border: "none" },
|
|
144
161
|
}}
|
|
145
162
|
>
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
163
|
+
{props.showZoomButtons && (
|
|
164
|
+
<>
|
|
165
|
+
<Button sx={{ ...buttonStyle }} onClick={zoomIn}>
|
|
166
|
+
<ControlPointIcon sx={{...iconStyle}} />
|
|
167
|
+
</Button>
|
|
168
|
+
<Button sx={{ ...buttonStyle }} onClick={zoomOut}>
|
|
169
|
+
<RemoveCircleOutlineIcon sx={{...iconStyle}} />
|
|
170
|
+
</Button>
|
|
171
|
+
</>
|
|
172
|
+
)}
|
|
152
173
|
</ButtonGroup>
|
|
174
|
+
{props.children &&
|
|
175
|
+
React.cloneElement(props.children, {
|
|
176
|
+
sx: { ...buttonStyle },
|
|
177
|
+
})}
|
|
153
178
|
</div>
|
|
154
179
|
);
|
|
155
180
|
};
|
|
156
181
|
|
|
157
182
|
MlNavigationTools.defaultProps = {
|
|
158
183
|
mapId: undefined,
|
|
184
|
+
show3DButton: true,
|
|
159
185
|
showFollowGpsButton: true,
|
|
160
186
|
showCenterLocationButton: false,
|
|
187
|
+
showZoomButtons: true,
|
|
161
188
|
};
|
|
162
189
|
|
|
163
190
|
export default MlNavigationTools;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { MapComponentsProvider } from "../index";
|
|
4
|
+
import MapLibreMap from "../components/MapLibreMap/MapLibreMap";
|
|
5
|
+
import "./style.css";
|
|
6
|
+
import { createTheme, ThemeProvider } from "@mui/material/styles";
|
|
7
|
+
import MlNavgiationTools from "../components/MlNavigationTools/MlNavigationTools";
|
|
8
|
+
|
|
9
|
+
const theme = createTheme({});
|
|
10
|
+
|
|
11
|
+
const decorators = [
|
|
12
|
+
(Story) => (
|
|
13
|
+
<div className="fullscreen_map">
|
|
14
|
+
<ThemeProvider theme={theme}>
|
|
15
|
+
<MapComponentsProvider>
|
|
16
|
+
<Story />
|
|
17
|
+
<MapLibreMap
|
|
18
|
+
options={{
|
|
19
|
+
zoom: 14.5,
|
|
20
|
+
style: "https://wms.wheregroup.com/tileserver/style/osm-bright.json",
|
|
21
|
+
center: [7.0851268, 50.73884],
|
|
22
|
+
}}
|
|
23
|
+
mapId="map_1"
|
|
24
|
+
/>
|
|
25
|
+
</MapComponentsProvider>
|
|
26
|
+
</ThemeProvider>
|
|
27
|
+
</div>
|
|
28
|
+
),
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
export default decorators;
|