@mapcomponents/react-maplibre 0.1.51 → 0.1.54
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 +13 -2
- package/coverage/clover.xml +52 -31
- package/coverage/coverage-final.json +3 -2
- package/coverage/lcov-report/index.html +32 -17
- 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 +343 -0
- package/coverage/lcov-report/src/components/MlCenterPosition/index.html +116 -0
- 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 +2 -2
- 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 +195 -42
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +15 -15
- 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 +2 -2
- 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 +120 -76
- package/dist/components/MlCenterPosition/MlCenterPosition.d.ts +50 -0
- package/dist/components/MlCenterPosition/MlCenterPosition.stories.d.ts +17 -0
- package/dist/components/MlGeoJsonLayer/MlGeoJsonLayer.d.ts +1 -1
- package/dist/components/MlLayer/MlLayer.d.ts +5 -0
- package/dist/components/MlNavigationTools/MlNavigationTools.d.ts +39 -3
- package/dist/components/MlNavigationTools/MlNavigationTools.stories.d.ts +8 -3
- package/dist/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.d.ts +1 -1
- package/dist/decorators/NoNavToolsDecorator.d.ts +2 -0
- package/dist/index.esm.js +79 -15
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/scripts/create-map-component.sh +2 -2
- package/src/components/MlCenterPosition/MlCenterPosition.doc.de.md +3 -0
- package/src/components/MlCenterPosition/MlCenterPosition.meta_.json +15 -0
- package/src/components/MlCenterPosition/MlCenterPosition.stories.js +21 -0
- package/src/components/MlCenterPosition/MlCenterPosition.tsx +86 -0
- package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx +1 -1
- package/src/components/MlLayer/MlLayer.tsx +6 -0
- package/src/components/MlNavigationTools/MlNavigationTools.stories.js +43 -6
- package/src/components/MlNavigationTools/MlNavigationTools.tsx +79 -28
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx +1 -1
- package/src/decorators/NoNavToolsDecorator.js +31 -0
package/package.json
CHANGED
|
@@ -18,14 +18,14 @@ if [ ! -d "$target_path$component_name" ]; then
|
|
|
18
18
|
|
|
19
19
|
mv $target_path$component_name/$template_name.doc.de.md $target_path$component_name/$component_name.doc.de.md
|
|
20
20
|
|
|
21
|
-
mv $target_path$component_name/$template_name.
|
|
21
|
+
mv $target_path$component_name/$template_name.tsx $target_path$component_name/$component_name.tsx
|
|
22
22
|
|
|
23
23
|
mv $target_path$component_name/$template_name.meta_.json $target_path$component_name/$component_name.meta_.json
|
|
24
24
|
|
|
25
25
|
mv $target_path$component_name/$template_name.stories.js $target_path$component_name/$component_name.stories.js
|
|
26
26
|
|
|
27
27
|
sed -i "s/$template_name/$component_name/g" $target_path$component_name/$component_name.doc.de.md
|
|
28
|
-
sed -i "s/$template_name/$component_name/g" $target_path$component_name/$component_name.
|
|
28
|
+
sed -i "s/$template_name/$component_name/g" $target_path$component_name/$component_name.tsx
|
|
29
29
|
sed -i "s/$template_name/$component_name/g" $target_path$component_name/$component_name.meta_.json
|
|
30
30
|
sed -i "s/$template_name/$component_name/g" $target_path$component_name/$component_name.stories.js
|
|
31
31
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import MlCenterPosition from "./MlCenterPosition";
|
|
4
|
+
|
|
5
|
+
import mapContextDecorator from "../../decorators/MapContextDecorator";
|
|
6
|
+
|
|
7
|
+
const storyoptions = {
|
|
8
|
+
title: "MapComponents/MlCenterPosition",
|
|
9
|
+
component: MlCenterPosition,
|
|
10
|
+
argTypes: {
|
|
11
|
+
},
|
|
12
|
+
decorators: mapContextDecorator,
|
|
13
|
+
parameters: { docs: { source: { type: 'code' } } }
|
|
14
|
+
};
|
|
15
|
+
export default storyoptions;
|
|
16
|
+
|
|
17
|
+
const Template = (args) => <MlCenterPosition />;
|
|
18
|
+
|
|
19
|
+
export const ExampleConfig = Template.bind({});
|
|
20
|
+
ExampleConfig.parameters = {};
|
|
21
|
+
ExampleConfig.args = {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React, { useState, useCallback } from "react";
|
|
2
|
+
import useMap from "../../hooks/useMap";
|
|
3
|
+
import { Button } from "@mui/material";
|
|
4
|
+
import GpsFixedIcon from "@mui/icons-material/GpsFixed";
|
|
5
|
+
|
|
6
|
+
interface MlCenterPositionProps {
|
|
7
|
+
/**
|
|
8
|
+
* Id of the target MapLibre instance in mapContext
|
|
9
|
+
*/
|
|
10
|
+
mapId?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Id of an existing layer in the mapLibre instance to help specify the layer order
|
|
13
|
+
* This layer will be visually beneath the layer with the "insertBeforeLayer" id.
|
|
14
|
+
*/
|
|
15
|
+
insertBeforeLayer?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Active button font color
|
|
18
|
+
*/
|
|
19
|
+
onColor?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Inactive button font color
|
|
22
|
+
*/
|
|
23
|
+
offColor?: string;
|
|
24
|
+
/**
|
|
25
|
+
* CSS style object that is applied to the button component
|
|
26
|
+
*/
|
|
27
|
+
style?: any;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Component template
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
const MlCenterPosition = (props: MlCenterPositionProps) => {
|
|
35
|
+
const mapHook = useMap({
|
|
36
|
+
mapId: props.mapId,
|
|
37
|
+
waitForLayer: props.insertBeforeLayer,
|
|
38
|
+
});
|
|
39
|
+
const [locationAccessDenied, setLocationAccessDenied] = useState(false);
|
|
40
|
+
|
|
41
|
+
const centerCurrentLocation = () => {
|
|
42
|
+
navigator.geolocation.getCurrentPosition(getLocationSuccess, getLocationError);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getLocationSuccess = useCallback((location) => {
|
|
46
|
+
mapHook.map?.map.setCenter?.([location.coords.longitude, location.coords.latitude]);
|
|
47
|
+
}, [mapHook.map]);
|
|
48
|
+
|
|
49
|
+
const getLocationError = () => {
|
|
50
|
+
console.log("Access of user location denied");
|
|
51
|
+
setLocationAccessDenied(true);
|
|
52
|
+
};
|
|
53
|
+
return <>
|
|
54
|
+
<Button
|
|
55
|
+
sx={{
|
|
56
|
+
zIndex: 1002,
|
|
57
|
+
color: !locationAccessDenied ? props.onColor : props.offColor,
|
|
58
|
+
...props.style,
|
|
59
|
+
}}
|
|
60
|
+
onClick={centerCurrentLocation} disabled={locationAccessDenied}>
|
|
61
|
+
<GpsFixedIcon sx={{ ...(props.style?.fontSize?{fontSize: props.style?.fontSize}:{}) }} />{" "}
|
|
62
|
+
</Button>
|
|
63
|
+
</>;
|
|
64
|
+
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
MlCenterPosition.defaultProps = {
|
|
68
|
+
mapId: undefined,
|
|
69
|
+
style: {
|
|
70
|
+
minWidth: "30px",
|
|
71
|
+
minHeight: "30px",
|
|
72
|
+
width: "30px",
|
|
73
|
+
height: "30px",
|
|
74
|
+
backgroundColor: "#414141",
|
|
75
|
+
borderRadius: "23%",
|
|
76
|
+
margin: 0.15,
|
|
77
|
+
fontSize: "1.3em",
|
|
78
|
+
":hover": {
|
|
79
|
+
backgroundColor: "#515151",
|
|
80
|
+
color: "#ececec",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
onColor: "#ececec",
|
|
84
|
+
offColor: "#666",
|
|
85
|
+
};
|
|
86
|
+
export default MlCenterPosition;
|
|
@@ -43,7 +43,7 @@ type MlGeoJsonLayerProps = {
|
|
|
43
43
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
44
44
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
45
45
|
*/
|
|
46
|
-
paint?: CircleLayerSpecification['paint'] | FillLayerSpecification['paint'] | LineLayerSpecification['
|
|
46
|
+
paint?: CircleLayerSpecification['paint'] | FillLayerSpecification['paint'] | LineLayerSpecification['paint'];
|
|
47
47
|
/**
|
|
48
48
|
* Layout property object, that is passed to the addLayer call.
|
|
49
49
|
* Possible props depend on the layer type.
|
|
@@ -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,12 +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
|
-
const Template = (args) => <MlNavigationTools />;
|
|
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
|
+
),
|
|
59
|
+
};
|
|
@@ -8,13 +8,41 @@ import MlNavigationCompass from "../MlNavigationCompass/MlNavigationCompass";
|
|
|
8
8
|
import MlFollowGps from "../MlFollowGps/MlFollowGps";
|
|
9
9
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
10
10
|
import useMap from "../../hooks/useMap";
|
|
11
|
+
import MlCenterPosition from "../MlCenterPosition/MlCenterPosition";
|
|
11
12
|
|
|
12
13
|
interface MlNavigationToolsProps {
|
|
14
|
+
/**
|
|
15
|
+
* Id of the target MapLibre instance in mapContext
|
|
16
|
+
*/
|
|
13
17
|
mapId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The layerId of an existing layer this layer should be rendered visually beneath
|
|
20
|
+
* https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
|
|
21
|
+
*/
|
|
14
22
|
insertBeforeLayer?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Show 3D button
|
|
25
|
+
*/
|
|
26
|
+
show3DButton?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Show zoom button
|
|
29
|
+
*/
|
|
30
|
+
showZoomButtons?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Show follow GPS button
|
|
33
|
+
*/
|
|
34
|
+
showFollowGpsButton?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Show center on current position button
|
|
37
|
+
*/
|
|
38
|
+
showCenterLocationButton?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Additional JSX Elements to be rendered below MlNavigationTools buttons
|
|
41
|
+
*/
|
|
42
|
+
children?: JSX.Element;
|
|
15
43
|
}
|
|
16
44
|
|
|
17
|
-
|
|
45
|
+
/**
|
|
18
46
|
* @component
|
|
19
47
|
*/
|
|
20
48
|
const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
@@ -35,31 +63,35 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
35
63
|
//border: "1px solid #bbb",
|
|
36
64
|
//boxShadow: "0px 0px 4px rgba(0,0,0,.5)",
|
|
37
65
|
margin: 0.15,
|
|
38
|
-
fontSize: mediaIsMobile ? "1.
|
|
66
|
+
fontSize: mediaIsMobile ? "1.4em" : "1.2em",
|
|
39
67
|
":hover": {
|
|
40
68
|
backgroundColor: "#515151",
|
|
41
69
|
},
|
|
42
70
|
color: "#ececec",
|
|
43
71
|
};
|
|
72
|
+
const iconStyle = {
|
|
73
|
+
fontSize: buttonStyle.fontSize,
|
|
74
|
+
}
|
|
44
75
|
|
|
45
76
|
useEffect(() => {
|
|
46
77
|
if (!mapHook.map) return;
|
|
47
78
|
|
|
48
|
-
mapHook.map.on(
|
|
49
|
-
|
|
79
|
+
mapHook.map.on(
|
|
80
|
+
"pitchend",
|
|
81
|
+
() => {
|
|
82
|
+
if (!mapHook.map) return;
|
|
50
83
|
|
|
51
|
-
|
|
52
|
-
|
|
84
|
+
setPitch(mapHook.map.map.getPitch());
|
|
85
|
+
},
|
|
86
|
+
mapHook.componentId
|
|
87
|
+
);
|
|
53
88
|
setPitch(mapHook.map.map.getPitch());
|
|
54
89
|
}, [mapHook.map, props.mapId]);
|
|
55
90
|
|
|
56
91
|
const zoomIn = () => {
|
|
57
92
|
if (!mapHook.map) return;
|
|
58
93
|
|
|
59
|
-
if (
|
|
60
|
-
mapHook.map.map.transform._zoom + 0.5 <=
|
|
61
|
-
mapHook.map.map.transform._maxZoom
|
|
62
|
-
) {
|
|
94
|
+
if (mapHook.map.map.transform._zoom + 0.5 <= mapHook.map.map.transform._maxZoom) {
|
|
63
95
|
mapHook.map.map.easeTo({ zoom: mapHook.map.map.transform._zoom + 0.5 });
|
|
64
96
|
}
|
|
65
97
|
};
|
|
@@ -67,10 +99,7 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
67
99
|
const zoomOut = () => {
|
|
68
100
|
if (!mapHook.map) return;
|
|
69
101
|
|
|
70
|
-
if (
|
|
71
|
-
mapHook.map.map.transform._zoom - 0.5 >=
|
|
72
|
-
mapHook.map.map.transform._minZoom
|
|
73
|
-
) {
|
|
102
|
+
if (mapHook.map.map.transform._zoom - 0.5 >= mapHook.map.map.transform._minZoom) {
|
|
74
103
|
mapHook.map.map.easeTo({ zoom: mapHook.map.map.transform._zoom - 0.5 });
|
|
75
104
|
}
|
|
76
105
|
};
|
|
@@ -108,10 +137,20 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
108
137
|
boxShadow: "0px 0px 18px rgba(0,0,0,.5)",
|
|
109
138
|
}}
|
|
110
139
|
/>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
+
)}
|
|
115
154
|
<ButtonGroup
|
|
116
155
|
orientation="vertical"
|
|
117
156
|
sx={{
|
|
@@ -121,19 +160,31 @@ const MlNavigationTools = (props: MlNavigationToolsProps) => {
|
|
|
121
160
|
"Button:hover": { border: "none" },
|
|
122
161
|
}}
|
|
123
162
|
>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
sx={{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
+
)}
|
|
134
173
|
</ButtonGroup>
|
|
174
|
+
{props.children &&
|
|
175
|
+
React.cloneElement(props.children, {
|
|
176
|
+
sx: { ...buttonStyle },
|
|
177
|
+
})}
|
|
135
178
|
</div>
|
|
136
179
|
);
|
|
137
180
|
};
|
|
138
181
|
|
|
182
|
+
MlNavigationTools.defaultProps = {
|
|
183
|
+
mapId: undefined,
|
|
184
|
+
show3DButton: true,
|
|
185
|
+
showFollowGpsButton: true,
|
|
186
|
+
showCenterLocationButton: false,
|
|
187
|
+
showZoomButtons: true,
|
|
188
|
+
};
|
|
189
|
+
|
|
139
190
|
export default MlNavigationTools;
|
|
@@ -32,7 +32,7 @@ interface MlTransitionGeoJsonLayerProps {
|
|
|
32
32
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
|
|
33
33
|
* https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
|
|
34
34
|
*/
|
|
35
|
-
paint?: CircleLayerSpecification['paint'] | FillLayerSpecification['paint'] | LineLayerSpecification['
|
|
35
|
+
paint?: CircleLayerSpecification['paint'] | FillLayerSpecification['paint'] | LineLayerSpecification['paint'];
|
|
36
36
|
/**
|
|
37
37
|
* Layout property object, that is passed to the addLayer call.
|
|
38
38
|
* Possible props depend on the layer type.
|
|
@@ -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;
|