@mapcomponents/react-maplibre 1.3.1 → 1.3.3
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 +6 -0
- package/dist/index.cjs.js +79 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +83 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/MlComponentTemplate/MlComponentTemplate.stories_.d.ts +1 -1
- package/dist/src/components/MlGlobeButton/MlGlobeButton.d.ts +28 -0
- package/dist/src/components/MlNavigationTools/MlNavigationTools.d.ts +5 -0
- package/dist/src/decorators/EmptyMapDecorator.d.ts +1 -1
- package/dist/src/decorators/GeoJsonMapDecorator.d.ts +1 -1
- package/dist/src/decorators/LowZoomDecorator.d.ts +1 -1
- package/dist/src/decorators/MapContextDecorator.d.ts +1 -1
- package/dist/src/decorators/MapContextDecoratorHooks.d.ts +1 -1
- package/dist/src/decorators/MapContextReduxStoreDecorator.d.ts +1 -1
- package/dist/src/decorators/MultiMapContextDecorator.d.ts +1 -1
- package/dist/src/decorators/NoNavToolsDecorator.d.ts +1 -1
- package/dist/src/decorators/ThemeDecorator.d.ts +1 -1
- package/dist/src/ui_components/MapcomponentsTheme.d.ts +1 -0
- package/package.json +36 -43
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -37,9 +37,10 @@ var CloseIcon = require('@mui/icons-material/Close');
|
|
|
37
37
|
var useMediaQuery = require('@mui/material/useMediaQuery');
|
|
38
38
|
var react = require('@emotion/react');
|
|
39
39
|
var ButtonGroup = require('@mui/material/ButtonGroup');
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
40
|
+
var AddIcon = require('@mui/icons-material/Add');
|
|
41
|
+
var RemoveIcon = require('@mui/icons-material/Remove');
|
|
42
|
+
var MapIcon = require('@mui/icons-material/Map');
|
|
43
|
+
var PublicIcon = require('@mui/icons-material/Public');
|
|
43
44
|
var syncMove = require('@mapbox/mapbox-gl-sync-move');
|
|
44
45
|
var xmldom = require('@xmldom/xmldom');
|
|
45
46
|
var helpers = require('@turf/helpers');
|
|
@@ -769,7 +770,7 @@ var getDesignTokens = function (mode) { return (__assign(__assign({}, (mode ===
|
|
|
769
770
|
contrast: '#000',
|
|
770
771
|
},
|
|
771
772
|
topToolbar: { barColor: '#000' },
|
|
772
|
-
navigation: { navColor: '#313131', navHover: '#747577' },
|
|
773
|
+
navigation: { buttonColor: '#fff', navColor: '#313131', navHover: '#747577' },
|
|
773
774
|
GPS: {
|
|
774
775
|
GPSActiveColor: '#fff',
|
|
775
776
|
GPSInactiveColor: '#fff',
|
|
@@ -793,10 +794,10 @@ var getDesignTokens = function (mode) { return (__assign(__assign({}, (mode ===
|
|
|
793
794
|
contrast: '#fff',
|
|
794
795
|
},
|
|
795
796
|
topToolbar: { barColor: '#fff' },
|
|
796
|
-
navigation: { navColor: '#fff', navHover: '#f5f5f5' },
|
|
797
|
+
navigation: { buttonColor: '#747577', navColor: '#fff', navHover: '#f5f5f5' },
|
|
797
798
|
GPS: {
|
|
798
799
|
GPSActiveColor: '#009EE0',
|
|
799
|
-
GPSInactiveColor: '#
|
|
800
|
+
GPSInactiveColor: '#747577',
|
|
800
801
|
GPSActiveBackgroundColor: '#fff',
|
|
801
802
|
},
|
|
802
803
|
compass: {
|
|
@@ -1334,9 +1335,14 @@ var MlCenterPosition = function (props) {
|
|
|
1334
1335
|
setLocationAccessDenied(true);
|
|
1335
1336
|
};
|
|
1336
1337
|
return (React.createElement(React.Fragment, null,
|
|
1337
|
-
React.createElement(material.Button, { variant: "navtools", sx: {
|
|
1338
|
-
|
|
1339
|
-
|
|
1338
|
+
React.createElement(material.Button, { variant: "navtools", sx: function (theme) {
|
|
1339
|
+
var _a, _b;
|
|
1340
|
+
return ({
|
|
1341
|
+
zIndex: 1002,
|
|
1342
|
+
color: !locationAccessDenied
|
|
1343
|
+
? ((_a = props.onColor) !== null && _a !== void 0 ? _a : theme.palette.navigation.buttonColor)
|
|
1344
|
+
: ((_b = props.offColor) !== null && _b !== void 0 ? _b : theme.palette.navigation.buttonColor),
|
|
1345
|
+
});
|
|
1340
1346
|
}, onClick: centerCurrentLocation, disabled: locationAccessDenied },
|
|
1341
1347
|
React.createElement(FilterCenterFocusIcon, { sx: { fontSize: { xs: '1.4em', md: '1em' } } }))));
|
|
1342
1348
|
};
|
|
@@ -3968,6 +3974,46 @@ var MlNavigationCompass = function (props) {
|
|
|
3968
3974
|
} }))))));
|
|
3969
3975
|
};
|
|
3970
3976
|
|
|
3977
|
+
/**
|
|
3978
|
+
* Projection component that displays the map as a globe or as a mercator projection.
|
|
3979
|
+
* @component
|
|
3980
|
+
*/
|
|
3981
|
+
var GlobeButtonStyled = material.styled(material.Button)(function (_a) {
|
|
3982
|
+
var theme = _a.theme;
|
|
3983
|
+
return ({
|
|
3984
|
+
zIndex: 1000,
|
|
3985
|
+
color: theme.palette.navigation.buttonColor,
|
|
3986
|
+
transform: 'scale(1)',
|
|
3987
|
+
});
|
|
3988
|
+
});
|
|
3989
|
+
var MlGlobeButton = function (props) {
|
|
3990
|
+
var mapHook = useMap({
|
|
3991
|
+
mapId: props.mapId,
|
|
3992
|
+
waitForLayer: props.insertBeforeLayer,
|
|
3993
|
+
});
|
|
3994
|
+
var _a = React.useState(props.mode || 'mercator'), projection = _a[0], setProjection = _a[1];
|
|
3995
|
+
React.useEffect(function () {
|
|
3996
|
+
var _a, _b, _c, _d, _e;
|
|
3997
|
+
var current = (_d = (_c = (_a = mapHook.map) === null || _a === void 0 ? void 0 : (_b = _a.map).getProjection) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.type;
|
|
3998
|
+
if (current !== projection) {
|
|
3999
|
+
(_e = mapHook.map) === null || _e === void 0 ? void 0 : _e.setProjection({ type: projection });
|
|
4000
|
+
}
|
|
4001
|
+
}, [mapHook.map]);
|
|
4002
|
+
var handleClick = function () {
|
|
4003
|
+
if (!mapHook.map)
|
|
4004
|
+
return;
|
|
4005
|
+
var next = projection === 'globe' ? 'mercator' : 'globe';
|
|
4006
|
+
mapHook.map.setProjection({ type: next });
|
|
4007
|
+
setProjection(next);
|
|
4008
|
+
};
|
|
4009
|
+
return (React.createElement(React.Fragment, null,
|
|
4010
|
+
React.createElement(GlobeButtonStyled, { variant: "navtools", onClick: handleClick, style: props.style }, projection === 'globe' ? (React.createElement(PublicIcon, { "data-testid": "PublicIcon", sx: { fontSize: { xs: '1.4em', md: '1em' } } })) : (React.createElement(MapIcon, { "data-testid": "MapIcon", sx: { fontSize: { xs: '1.4em', md: '1em' } } })))));
|
|
4011
|
+
};
|
|
4012
|
+
MlGlobeButton.defaultProps = {
|
|
4013
|
+
mapId: undefined,
|
|
4014
|
+
mode: 'mercator',
|
|
4015
|
+
};
|
|
4016
|
+
|
|
3971
4017
|
/**
|
|
3972
4018
|
* @component
|
|
3973
4019
|
*/
|
|
@@ -3978,6 +4024,7 @@ var MlNavigationTools = function (props) {
|
|
|
3978
4024
|
});
|
|
3979
4025
|
var _a = React.useState(0), pitch = _a[0], setPitch = _a[1];
|
|
3980
4026
|
var mediaIsMobile = useMediaQuery(function (theme) { return theme.breakpoints.down('md'); });
|
|
4027
|
+
var theme = material.useTheme();
|
|
3981
4028
|
React.useEffect(function () {
|
|
3982
4029
|
if (!mapHook.map)
|
|
3983
4030
|
return;
|
|
@@ -4007,24 +4054,40 @@ var MlNavigationTools = function (props) {
|
|
|
4007
4054
|
}, [mapHook.map]);
|
|
4008
4055
|
return (React.createElement(Box, { sx: __assign(__assign({ zIndex: 501, position: 'absolute', display: 'flex', flexDirection: 'column', right: mediaIsMobile ? '15px' : '25px', bottom: mediaIsMobile ? '20px' : '40px' }, (mediaIsMobile ? { margin: '80px 10px 50px 10px' } : { marginTop: '50px' })), props.sx) },
|
|
4009
4056
|
React.createElement(MlNavigationCompass, null),
|
|
4010
|
-
props.show3DButton && (React.createElement(Button, { variant: "navtools", onClick: adjustPitch }, pitch < 29 ? '
|
|
4057
|
+
props.show3DButton && (React.createElement(Button, { variant: "navtools", onClick: adjustPitch, sx: { color: function (theme) { return theme.palette.navigation.buttonColor; } } }, pitch < 29 ? '2D' : '3D')),
|
|
4058
|
+
props.showGlobeButton && React.createElement(MlGlobeButton, null),
|
|
4011
4059
|
props.showFollowGpsButton && React.createElement(MlFollowGps, null),
|
|
4012
4060
|
props.showCenterLocationButton && React.createElement(MlCenterPosition, null),
|
|
4013
4061
|
React.createElement(ButtonGroup, { orientation: "vertical", sx: {
|
|
4014
4062
|
border: 'none',
|
|
4015
|
-
Button: { minWidth: '20px !important' },
|
|
4063
|
+
Button: { minWidth: '20px !important', color: theme.palette.navigation.buttonColor },
|
|
4016
4064
|
'Button:hover': { border: 'none' },
|
|
4017
4065
|
} }, props.showZoomButtons && (React.createElement(React.Fragment, null,
|
|
4018
|
-
React.createElement(Button, { variant: "navtools", onClick: zoomIn
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4066
|
+
React.createElement(Button, { variant: "navtools", onClick: zoomIn, sx: {
|
|
4067
|
+
borderBottomLeftRadius: 0,
|
|
4068
|
+
borderBottomRightRadius: 0,
|
|
4069
|
+
position: 'relative',
|
|
4070
|
+
} },
|
|
4071
|
+
React.createElement(AddIcon, { sx: { fontSize: { xs: '1.4em', md: '1em' } } })),
|
|
4072
|
+
React.createElement(material.Paper, { sx: {
|
|
4073
|
+
backgroundColor: '#fff',
|
|
4074
|
+
} },
|
|
4075
|
+
React.createElement(material.Divider, { sx: {
|
|
4076
|
+
marginLeft: '6px',
|
|
4077
|
+
marginRight: '6px',
|
|
4078
|
+
} })),
|
|
4079
|
+
React.createElement(Button, { variant: "navtools", onClick: zoomOut, sx: {
|
|
4080
|
+
margin: 0,
|
|
4081
|
+
borderTopLeftRadius: 0,
|
|
4082
|
+
borderTopRightRadius: 0,
|
|
4083
|
+
} },
|
|
4084
|
+
React.createElement(RemoveIcon, { sx: { fontSize: { xs: '1.4em', md: '1em' } } }))))),
|
|
4023
4085
|
props.children && React.cloneElement(props.children, {})));
|
|
4024
4086
|
};
|
|
4025
4087
|
MlNavigationTools.defaultProps = {
|
|
4026
4088
|
mapId: undefined,
|
|
4027
4089
|
show3DButton: true,
|
|
4090
|
+
showGlobeButton: false,
|
|
4028
4091
|
showFollowGpsButton: true,
|
|
4029
4092
|
showCenterLocationButton: false,
|
|
4030
4093
|
showZoomButtons: true,
|