@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/dist/index.esm.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import maplibregl, { Map, Popup } from 'maplibre-gl';
2
2
  import * as React from 'react';
3
3
  import React__default, { useMemo, useEffect, useCallback, useState, useRef, useContext, Fragment } from 'react';
4
- import { createTheme, ThemeProvider, styled as styled$2, useTheme } from '@mui/material/styles';
4
+ import { createTheme, ThemeProvider, styled as styled$2, useTheme as useTheme$1 } from '@mui/material/styles';
5
5
  import { v4 } from 'uuid';
6
6
  import 'maplibre-gl/dist/maplibre-gl.css';
7
- import { Button, CircularProgress, useMediaQuery, FormControl, InputLabel, Select, MenuItem, FormLabel, RadioGroup, FormControlLabel, Radio, styled, List, ListItem, ListItemIcon, IconButton, Checkbox, ListItemText, Grid, Paper, Box as Box$1, Typography, TextField, Slider, Drawer, SwipeableDrawer, Tooltip, Snackbar, FormGroup, DialogTitle as DialogTitle$1, DialogActions as DialogActions$1, ListItemButton, ListItemAvatar, Avatar, DialogContent as DialogContent$1, OutlinedInput, Accordion, AccordionSummary, Dialog as Dialog$1 } from '@mui/material';
7
+ import { Button, CircularProgress, useMediaQuery, FormControl, InputLabel, Select, MenuItem, FormLabel, RadioGroup, FormControlLabel, Radio, styled, List, ListItem, ListItemIcon, IconButton, Checkbox, ListItemText, Grid, Paper, Box as Box$1, Typography, TextField, Slider, Drawer, SwipeableDrawer, Tooltip, useTheme, Divider, Snackbar, FormGroup, DialogTitle as DialogTitle$1, DialogActions as DialogActions$1, ListItemButton, ListItemAvatar, Avatar, DialogContent as DialogContent$1, OutlinedInput, Accordion, AccordionSummary, Dialog as Dialog$1 } from '@mui/material';
8
8
  import FilterCenterFocusIcon from '@mui/icons-material/FilterCenterFocus';
9
9
  import PrinterIcon from '@mui/icons-material/Print';
10
10
  import Button$1 from '@mui/material/Button';
@@ -37,9 +37,10 @@ import CloseIcon from '@mui/icons-material/Close';
37
37
  import useMediaQuery$1 from '@mui/material/useMediaQuery';
38
38
  import { Global } from '@emotion/react';
39
39
  import ButtonGroup from '@mui/material/ButtonGroup';
40
- import ControlPointIcon from '@mui/icons-material/ControlPoint';
41
- import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline';
42
- import Divider from '@mui/material/Divider';
40
+ import AddIcon from '@mui/icons-material/Add';
41
+ import RemoveIcon from '@mui/icons-material/Remove';
42
+ import MapIcon from '@mui/icons-material/Map';
43
+ import PublicIcon from '@mui/icons-material/Public';
43
44
  import syncMove from '@mapbox/mapbox-gl-sync-move';
44
45
  import * as xmldom from '@xmldom/xmldom';
45
46
  import { featureCollection as featureCollection$1, lineString, polygon } from '@turf/helpers';
@@ -745,7 +746,7 @@ var getDesignTokens = function (mode) { return (__assign(__assign({}, (mode ===
745
746
  contrast: '#000',
746
747
  },
747
748
  topToolbar: { barColor: '#000' },
748
- navigation: { navColor: '#313131', navHover: '#747577' },
749
+ navigation: { buttonColor: '#fff', navColor: '#313131', navHover: '#747577' },
749
750
  GPS: {
750
751
  GPSActiveColor: '#fff',
751
752
  GPSInactiveColor: '#fff',
@@ -769,10 +770,10 @@ var getDesignTokens = function (mode) { return (__assign(__assign({}, (mode ===
769
770
  contrast: '#fff',
770
771
  },
771
772
  topToolbar: { barColor: '#fff' },
772
- navigation: { navColor: '#fff', navHover: '#f5f5f5' },
773
+ navigation: { buttonColor: '#747577', navColor: '#fff', navHover: '#f5f5f5' },
773
774
  GPS: {
774
775
  GPSActiveColor: '#009EE0',
775
- GPSInactiveColor: '#000',
776
+ GPSInactiveColor: '#747577',
776
777
  GPSActiveBackgroundColor: '#fff',
777
778
  },
778
779
  compass: {
@@ -1310,9 +1311,14 @@ var MlCenterPosition = function (props) {
1310
1311
  setLocationAccessDenied(true);
1311
1312
  };
1312
1313
  return (React__default.createElement(React__default.Fragment, null,
1313
- React__default.createElement(Button, { variant: "navtools", sx: {
1314
- zIndex: 1002,
1315
- color: !locationAccessDenied ? props.onColor : props.offColor,
1314
+ React__default.createElement(Button, { variant: "navtools", sx: function (theme) {
1315
+ var _a, _b;
1316
+ return ({
1317
+ zIndex: 1002,
1318
+ color: !locationAccessDenied
1319
+ ? ((_a = props.onColor) !== null && _a !== void 0 ? _a : theme.palette.navigation.buttonColor)
1320
+ : ((_b = props.offColor) !== null && _b !== void 0 ? _b : theme.palette.navigation.buttonColor),
1321
+ });
1316
1322
  }, onClick: centerCurrentLocation, disabled: locationAccessDenied },
1317
1323
  React__default.createElement(FilterCenterFocusIcon, { sx: { fontSize: { xs: '1.4em', md: '1em' } } }))));
1318
1324
  };
@@ -3944,6 +3950,46 @@ var MlNavigationCompass = function (props) {
3944
3950
  } }))))));
3945
3951
  };
3946
3952
 
3953
+ /**
3954
+ * Projection component that displays the map as a globe or as a mercator projection.
3955
+ * @component
3956
+ */
3957
+ var GlobeButtonStyled = styled(Button)(function (_a) {
3958
+ var theme = _a.theme;
3959
+ return ({
3960
+ zIndex: 1000,
3961
+ color: theme.palette.navigation.buttonColor,
3962
+ transform: 'scale(1)',
3963
+ });
3964
+ });
3965
+ var MlGlobeButton = function (props) {
3966
+ var mapHook = useMap({
3967
+ mapId: props.mapId,
3968
+ waitForLayer: props.insertBeforeLayer,
3969
+ });
3970
+ var _a = useState(props.mode || 'mercator'), projection = _a[0], setProjection = _a[1];
3971
+ useEffect(function () {
3972
+ var _a, _b, _c, _d, _e;
3973
+ 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;
3974
+ if (current !== projection) {
3975
+ (_e = mapHook.map) === null || _e === void 0 ? void 0 : _e.setProjection({ type: projection });
3976
+ }
3977
+ }, [mapHook.map]);
3978
+ var handleClick = function () {
3979
+ if (!mapHook.map)
3980
+ return;
3981
+ var next = projection === 'globe' ? 'mercator' : 'globe';
3982
+ mapHook.map.setProjection({ type: next });
3983
+ setProjection(next);
3984
+ };
3985
+ return (React__default.createElement(React__default.Fragment, null,
3986
+ React__default.createElement(GlobeButtonStyled, { variant: "navtools", onClick: handleClick, style: props.style }, projection === 'globe' ? (React__default.createElement(PublicIcon, { "data-testid": "PublicIcon", sx: { fontSize: { xs: '1.4em', md: '1em' } } })) : (React__default.createElement(MapIcon, { "data-testid": "MapIcon", sx: { fontSize: { xs: '1.4em', md: '1em' } } })))));
3987
+ };
3988
+ MlGlobeButton.defaultProps = {
3989
+ mapId: undefined,
3990
+ mode: 'mercator',
3991
+ };
3992
+
3947
3993
  /**
3948
3994
  * @component
3949
3995
  */
@@ -3954,6 +4000,7 @@ var MlNavigationTools = function (props) {
3954
4000
  });
3955
4001
  var _a = useState(0), pitch = _a[0], setPitch = _a[1];
3956
4002
  var mediaIsMobile = useMediaQuery$1(function (theme) { return theme.breakpoints.down('md'); });
4003
+ var theme = useTheme();
3957
4004
  useEffect(function () {
3958
4005
  if (!mapHook.map)
3959
4006
  return;
@@ -3983,24 +4030,40 @@ var MlNavigationTools = function (props) {
3983
4030
  }, [mapHook.map]);
3984
4031
  return (React__default.createElement(Box$2, { 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) },
3985
4032
  React__default.createElement(MlNavigationCompass, null),
3986
- props.show3DButton && (React__default.createElement(Button$1, { variant: "navtools", onClick: adjustPitch }, pitch < 29 ? '3D' : '2D')),
4033
+ props.show3DButton && (React__default.createElement(Button$1, { variant: "navtools", onClick: adjustPitch, sx: { color: function (theme) { return theme.palette.navigation.buttonColor; } } }, pitch < 29 ? '2D' : '3D')),
4034
+ props.showGlobeButton && React__default.createElement(MlGlobeButton, null),
3987
4035
  props.showFollowGpsButton && React__default.createElement(MlFollowGps, null),
3988
4036
  props.showCenterLocationButton && React__default.createElement(MlCenterPosition, null),
3989
4037
  React__default.createElement(ButtonGroup, { orientation: "vertical", sx: {
3990
4038
  border: 'none',
3991
- Button: { minWidth: '20px !important' },
4039
+ Button: { minWidth: '20px !important', color: theme.palette.navigation.buttonColor },
3992
4040
  'Button:hover': { border: 'none' },
3993
4041
  } }, props.showZoomButtons && (React__default.createElement(React__default.Fragment, null,
3994
- React__default.createElement(Button$1, { variant: "navtools", onClick: zoomIn },
3995
- React__default.createElement(ControlPointIcon, { sx: { fontSize: { xs: '1.4em', md: '1em' } } })),
3996
- React__default.createElement(Divider, { sx: { zIndex: 500, marginLeft: '7px', marginRight: '7px' } }),
3997
- React__default.createElement(Button$1, { variant: "navtools", onClick: zoomOut },
3998
- React__default.createElement(RemoveCircleOutlineIcon, { sx: { fontSize: { xs: '1.4em', md: '1em' } } }))))),
4042
+ React__default.createElement(Button$1, { variant: "navtools", onClick: zoomIn, sx: {
4043
+ borderBottomLeftRadius: 0,
4044
+ borderBottomRightRadius: 0,
4045
+ position: 'relative',
4046
+ } },
4047
+ React__default.createElement(AddIcon, { sx: { fontSize: { xs: '1.4em', md: '1em' } } })),
4048
+ React__default.createElement(Paper, { sx: {
4049
+ backgroundColor: '#fff',
4050
+ } },
4051
+ React__default.createElement(Divider, { sx: {
4052
+ marginLeft: '6px',
4053
+ marginRight: '6px',
4054
+ } })),
4055
+ React__default.createElement(Button$1, { variant: "navtools", onClick: zoomOut, sx: {
4056
+ margin: 0,
4057
+ borderTopLeftRadius: 0,
4058
+ borderTopRightRadius: 0,
4059
+ } },
4060
+ React__default.createElement(RemoveIcon, { sx: { fontSize: { xs: '1.4em', md: '1em' } } }))))),
3999
4061
  props.children && React__default.cloneElement(props.children, {})));
4000
4062
  };
4001
4063
  MlNavigationTools.defaultProps = {
4002
4064
  mapId: undefined,
4003
4065
  show3DButton: true,
4066
+ showGlobeButton: false,
4004
4067
  showFollowGpsButton: true,
4005
4068
  showCenterLocationButton: false,
4006
4069
  showZoomButtons: true,
@@ -6812,7 +6875,7 @@ var MlTemporalController = function (props) {
6812
6875
  initialVal: props.initialVal,
6813
6876
  mapId: props.mapId,
6814
6877
  }), filteredData = _d.filteredData, minVal = _d.minVal, maxVal = _d.maxVal;
6815
- var theme = useTheme();
6878
+ var theme = useTheme$1();
6816
6879
  var _e = useState(props.initialVal || minVal), currentVal = _e[0], setCurrentVal = _e[1];
6817
6880
  var featuresColor = props.featuresColor || theme.palette.primary.main;
6818
6881
  var labelColor = props.labelColor || theme.palette.text.primary;
@@ -8440,7 +8503,7 @@ var logoUrl = ghPagesUrl + 'assets/WG-MapComponents-Logo_rgb.svg';
8440
8503
  var logoUrl_dark = ghPagesUrl + 'assets/WG-MapComponents-Logo_rgb-weisse-schrift.svg';
8441
8504
  var logoUrl_mobile = ghPagesUrl + 'assets/mapcomponents_logo.png';
8442
8505
  function TopToolbar(props) {
8443
- var theme = useTheme();
8506
+ var theme = useTheme$1();
8444
8507
  var _a = useState(null), anchorElNav = _a[0], setAnchorElNav = _a[1];
8445
8508
  var handleOpenNavMenu = function (event) {
8446
8509
  setAnchorElNav(event.currentTarget);