@mapcomponents/react-maplibre 1.3.2 → 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.3.2]
4
+
5
+ ## Changed
6
+ - f2980b6: Design/navigation tool (#225)
7
+ - 570987e: Upgrade to maplibre to 5.6.0 (from 5.5.0)
8
+
3
9
  ## [v1.3.1]
4
10
 
5
11
  ## 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 ControlPointIcon = require('@mui/icons-material/ControlPoint');
41
- var RemoveCircleOutlineIcon = require('@mui/icons-material/RemoveCircleOutline');
42
- var Divider = require('@mui/material/Divider');
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: '#000',
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
- zIndex: 1002,
1339
- color: !locationAccessDenied ? props.onColor : props.offColor,
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 ? '3D' : '2D')),
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
- React.createElement(ControlPointIcon, { sx: { fontSize: { xs: '1.4em', md: '1em' } } })),
4020
- React.createElement(Divider, { sx: { zIndex: 500, marginLeft: '7px', marginRight: '7px' } }),
4021
- React.createElement(Button, { variant: "navtools", onClick: zoomOut },
4022
- React.createElement(RemoveCircleOutlineIcon, { sx: { fontSize: { xs: '1.4em', md: '1em' } } }))))),
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,