@mapcomponents/react-maplibre 0.1.54 → 0.1.57

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/coverage/clover.xml +89 -83
  3. package/coverage/coverage-final.json +3 -3
  4. package/coverage/lcov-report/index.html +22 -22
  5. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +1 -1
  6. package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
  7. package/coverage/lcov-report/src/components/MlCenterPosition/MlCenterPosition.tsx.html +1 -1
  8. package/coverage/lcov-report/src/components/MlCenterPosition/index.html +1 -1
  9. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +1 -1
  10. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +1 -1
  11. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +1 -1
  12. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
  13. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +1 -1
  14. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  15. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +123 -36
  16. package/coverage/lcov-report/src/components/MlFollowGps/index.html +15 -15
  17. package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.html +1 -1
  18. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +1 -1
  19. package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
  20. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +1 -1
  21. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  22. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +1 -1
  23. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
  24. package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +2 -2
  25. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  26. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +1 -1
  27. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
  28. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +1 -1
  29. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
  30. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
  31. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
  32. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  33. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  34. package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +1 -1
  35. package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
  36. package/coverage/lcov-report/src/components/MlMeasureTool/MlMeasureTool.tsx.html +1 -1
  37. package/coverage/lcov-report/src/components/MlMeasureTool/index.html +1 -1
  38. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +1 -1
  39. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  40. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +42 -12
  41. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +3 -3
  42. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +1 -1
  43. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.stories_.js.html +1 -1
  44. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  45. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +7 -7
  46. package/coverage/lcov-report/src/components/MlScaleReference/index.html +11 -11
  47. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
  48. package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
  49. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +1 -1
  50. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  51. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
  52. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
  53. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +1 -1
  54. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
  55. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  56. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  57. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +1 -1
  58. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
  59. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
  60. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
  61. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +1 -1
  62. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
  63. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +1 -1
  64. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
  65. package/coverage/lcov-report/src/contexts/MapContext.tsx.html +1 -1
  66. package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +1 -1
  67. package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +1 -1
  68. package/coverage/lcov-report/src/contexts/index.html +1 -1
  69. package/coverage/lcov-report/src/hooks/index.html +1 -1
  70. package/coverage/lcov-report/src/hooks/useLayer.ts.html +1 -1
  71. package/coverage/lcov-report/src/hooks/useMap.ts.html +1 -1
  72. package/coverage/lcov-report/src/hooks/useMapState.ts.html +1 -1
  73. package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
  74. package/coverage/lcov-report/src/index.html +1 -1
  75. package/coverage/lcov-report/src/index.ts.html +5 -2
  76. package/coverage/lcov.info +172 -161
  77. package/dist/components/MlFollowGps/MlFollowGps.d.ts +26 -6
  78. package/dist/components/MlLayer/MlLayer.d.ts +1 -1
  79. package/dist/components/MlNavigationTools/MlNavigationTools.d.ts +9 -0
  80. package/dist/components/MlNavigationTools/MlNavigationTools.stories.d.ts +1 -0
  81. package/dist/decorators/ThemeWrapper.d.ts +1 -0
  82. package/dist/index.d.ts +1 -0
  83. package/dist/index.esm.js +348 -173
  84. package/dist/index.esm.js.map +1 -1
  85. package/package.json +1 -1
  86. package/src/components/MlFollowGps/MlFollowGps.stories.js +4 -2
  87. package/src/components/MlFollowGps/MlFollowGps.tsx +53 -24
  88. package/src/components/MlLayer/MlLayer.tsx +1 -1
  89. package/src/components/MlNavigationTools/MlNavigationTools.stories.js +6 -0
  90. package/src/components/MlNavigationTools/MlNavigationTools.tsx +19 -9
  91. package/src/components/MlScaleReference/MlScaleReference.stories.js +22 -24
  92. package/src/decorators/MapContextDecorator.js +9 -10
  93. package/src/decorators/MultiMapContextDecorator.js +54 -55
  94. package/src/decorators/ThemeWrapper.jsx +9 -0
  95. package/src/index.ts +1 -0
package/dist/index.esm.js CHANGED
@@ -4414,7 +4414,7 @@ function getModalUtilityClass(slot) {
4414
4414
  }
4415
4415
  generateUtilityClasses('MuiModal', ['root', 'hidden']);
4416
4416
 
4417
- const _excluded$r = ["BackdropComponent", "BackdropProps", "children", "classes", "className", "closeAfterTransition", "component", "components", "componentsProps", "container", "disableAutoFocus", "disableEnforceFocus", "disableEscapeKeyDown", "disablePortal", "disableRestoreFocus", "disableScrollLock", "hideBackdrop", "keepMounted", "manager", "onBackdropClick", "onClose", "onKeyDown", "open", "theme", "onTransitionEnter", "onTransitionExited"];
4417
+ const _excluded$s = ["BackdropComponent", "BackdropProps", "children", "classes", "className", "closeAfterTransition", "component", "components", "componentsProps", "container", "disableAutoFocus", "disableEnforceFocus", "disableEscapeKeyDown", "disablePortal", "disableRestoreFocus", "disableScrollLock", "hideBackdrop", "keepMounted", "manager", "onBackdropClick", "onClose", "onKeyDown", "open", "theme", "onTransitionEnter", "onTransitionExited"];
4418
4418
 
4419
4419
  const useUtilityClasses$e = ownerState => {
4420
4420
  const {
@@ -4486,7 +4486,7 @@ const ModalUnstyled = /*#__PURE__*/React.forwardRef(function ModalUnstyled(props
4486
4486
  onTransitionEnter,
4487
4487
  onTransitionExited
4488
4488
  } = props,
4489
- other = _objectWithoutPropertiesLoose(props, _excluded$r);
4489
+ other = _objectWithoutPropertiesLoose(props, _excluded$s);
4490
4490
 
4491
4491
  const [exited, setExited] = React.useState(true);
4492
4492
  const modal = React.useRef({});
@@ -5688,7 +5688,7 @@ const styleFunctionSx = unstable_createStyleFunctionSx();
5688
5688
  styleFunctionSx.filterProps = ['sx'];
5689
5689
  var defaultStyleFunctionSx = styleFunctionSx;
5690
5690
 
5691
- const _excluded$q = ["sx"];
5691
+ const _excluded$r = ["sx"];
5692
5692
 
5693
5693
  const splitProps = props => {
5694
5694
  const result = {
@@ -5709,7 +5709,7 @@ function extendSxProp(props) {
5709
5709
  const {
5710
5710
  sx: inSx
5711
5711
  } = props,
5712
- other = _objectWithoutPropertiesLoose(props, _excluded$q);
5712
+ other = _objectWithoutPropertiesLoose(props, _excluded$r);
5713
5713
 
5714
5714
  const {
5715
5715
  systemProps,
@@ -5738,7 +5738,7 @@ function extendSxProp(props) {
5738
5738
  });
5739
5739
  }
5740
5740
 
5741
- const _excluded$p = ["values", "unit", "step"];
5741
+ const _excluded$q = ["values", "unit", "step"];
5742
5742
 
5743
5743
  const sortBreakpointsValues = values => {
5744
5744
  const breakpointsAsArray = Object.keys(values).map(key => ({
@@ -5774,7 +5774,7 @@ function createBreakpoints(breakpoints) {
5774
5774
  unit = 'px',
5775
5775
  step = 5
5776
5776
  } = breakpoints,
5777
- other = _objectWithoutPropertiesLoose(breakpoints, _excluded$p);
5777
+ other = _objectWithoutPropertiesLoose(breakpoints, _excluded$q);
5778
5778
 
5779
5779
  const sortedValues = sortBreakpointsValues(values);
5780
5780
  const keys = Object.keys(sortedValues);
@@ -5866,7 +5866,7 @@ function createSpacing(spacingInput = 8) {
5866
5866
  return spacing;
5867
5867
  }
5868
5868
 
5869
- const _excluded$o = ["breakpoints", "palette", "spacing", "shape"];
5869
+ const _excluded$p = ["breakpoints", "palette", "spacing", "shape"];
5870
5870
 
5871
5871
  function createTheme$1(options = {}, ...args) {
5872
5872
  const {
@@ -5875,7 +5875,7 @@ function createTheme$1(options = {}, ...args) {
5875
5875
  spacing: spacingInput,
5876
5876
  shape: shapeInput = {}
5877
5877
  } = options,
5878
- other = _objectWithoutPropertiesLoose(options, _excluded$o);
5878
+ other = _objectWithoutPropertiesLoose(options, _excluded$p);
5879
5879
 
5880
5880
  const breakpoints = createBreakpoints(breakpointsInput);
5881
5881
  const spacing = createSpacing(spacingInput);
@@ -5928,6 +5928,59 @@ function useTheme$1(defaultTheme = systemDefaultTheme$1) {
5928
5928
  return useTheme$2(defaultTheme);
5929
5929
  }
5930
5930
 
5931
+ const _excluded$o = ["className", "component"];
5932
+ function createBox(options = {}) {
5933
+ const {
5934
+ defaultTheme,
5935
+ defaultClassName = 'MuiBox-root',
5936
+ generateClassName,
5937
+ styleFunctionSx = defaultStyleFunctionSx
5938
+ } = options;
5939
+ const BoxRoot = styled$2('div')(styleFunctionSx);
5940
+ const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
5941
+ const theme = useTheme$1(defaultTheme);
5942
+
5943
+ const _extendSxProp = extendSxProp(inProps),
5944
+ {
5945
+ className,
5946
+ component = 'div'
5947
+ } = _extendSxProp,
5948
+ other = _objectWithoutPropertiesLoose(_extendSxProp, _excluded$o);
5949
+
5950
+ return /*#__PURE__*/jsxRuntime.exports.jsx(BoxRoot, _extends$3({
5951
+ as: component,
5952
+ ref: ref,
5953
+ className: clsx(className, generateClassName ? generateClassName(defaultClassName) : defaultClassName),
5954
+ theme: theme
5955
+ }, other));
5956
+ });
5957
+ process.env.NODE_ENV !== "production" ? Box.propTypes
5958
+ /* remove-proptypes */
5959
+ = {
5960
+ // ----------------------------- Warning --------------------------------
5961
+ // | These PropTypes are generated from the TypeScript type definitions |
5962
+ // | To update them edit the d.ts file and run "yarn proptypes" |
5963
+ // ----------------------------------------------------------------------
5964
+
5965
+ /**
5966
+ * @ignore
5967
+ */
5968
+ children: PropTypes.node,
5969
+
5970
+ /**
5971
+ * The component used for the root node.
5972
+ * Either a string to use a HTML element or a component.
5973
+ */
5974
+ component: PropTypes.elementType,
5975
+
5976
+ /**
5977
+ * @ignore
5978
+ */
5979
+ sx: PropTypes.oneOfType([PropTypes.object, PropTypes.array, PropTypes.func])
5980
+ } : void 0;
5981
+ return Box;
5982
+ }
5983
+
5931
5984
  const _excluded$n = ["variant"];
5932
5985
 
5933
5986
  function isEmpty$1(string) {
@@ -7199,8 +7252,8 @@ function createTheme(options = {}, ...args) {
7199
7252
  return muiTheme;
7200
7253
  }
7201
7254
 
7202
- const defaultTheme = createTheme();
7203
- var defaultTheme$1 = defaultTheme;
7255
+ const defaultTheme$1 = createTheme();
7256
+ var defaultTheme$2 = defaultTheme$1;
7204
7257
 
7205
7258
  function useThemeProps({
7206
7259
  props,
@@ -7209,13 +7262,13 @@ function useThemeProps({
7209
7262
  return useThemeProps$1({
7210
7263
  props,
7211
7264
  name,
7212
- defaultTheme: defaultTheme$1
7265
+ defaultTheme: defaultTheme$2
7213
7266
  });
7214
7267
  }
7215
7268
 
7216
7269
  const rootShouldForwardProp = prop => shouldForwardProp(prop) && prop !== 'classes';
7217
7270
  const styled = createStyled({
7218
- defaultTheme: defaultTheme$1,
7271
+ defaultTheme: defaultTheme$2,
7219
7272
  rootShouldForwardProp
7220
7273
  });
7221
7274
  var styled$1 = styled;
@@ -12492,15 +12545,24 @@ var MlFollowGps = function (props) {
12492
12545
  var _e = useState(false), locationAccessDenied = _e[0], setLocationAccessDenied = _e[1];
12493
12546
  var _f = useState(), accuracyGeoJson = _f[0], setAccuracyGeoJson = _f[1];
12494
12547
  var _g = useState(0), deviceOrientation = _g[0], setDeviceOrientation = _g[1];
12548
+ var initiallyCentered = useRef(false);
12495
12549
  var getLocationSuccess = useCallback(function (pos) {
12496
12550
  if (!mapHook.map)
12497
12551
  return;
12498
- mapHook.map.map.flyTo({
12499
- center: [pos.coords.longitude, pos.coords.latitude],
12500
- zoom: 18,
12501
- speed: 1,
12502
- curve: 1,
12503
- });
12552
+ if ((!props.centerUserPosition && !initiallyCentered.current) || props.centerUserPosition) {
12553
+ if (props.useFlyTo) {
12554
+ mapHook.map.map.flyTo({
12555
+ center: [pos.coords.longitude, pos.coords.latitude],
12556
+ zoom: 18,
12557
+ speed: 1,
12558
+ curve: 1,
12559
+ });
12560
+ }
12561
+ else {
12562
+ mapHook.map.map.setCenter([pos.coords.longitude, pos.coords.latitude]);
12563
+ }
12564
+ initiallyCentered.current = true;
12565
+ }
12504
12566
  if (!props.showUserLocation)
12505
12567
  return;
12506
12568
  var geoJsonPoint = point([pos.coords.longitude, pos.coords.latitude]);
@@ -12536,6 +12598,9 @@ var MlFollowGps = function (props) {
12536
12598
  window.removeEventListener("deviceorientation", _handleOrientation_1);
12537
12599
  };
12538
12600
  }
12601
+ else {
12602
+ initiallyCentered.current = false;
12603
+ }
12539
12604
  return;
12540
12605
  }, [isFollowed]);
12541
12606
  useEffect(function () {
@@ -12551,22 +12616,18 @@ var MlFollowGps = function (props) {
12551
12616
  }, [mapHook.map, isFollowed, getLocationSuccess]);
12552
12617
  return (React__default.createElement(React__default.Fragment, null,
12553
12618
  isFollowed && userLocationGeoJson && (React__default.createElement(MlGeoJsonLayer, { geojson: accuracyGeoJson, type: "fill", paint: __assign({ "fill-color": "#cbd300", "fill-opacity": 0.3 }, props.accuracyPaint), insertBeforeLayer: props.insertBeforeLayer })),
12554
- isFollowed && orientationCone && (React__default.createElement(MlGeoJsonLayer, { geojson: orientationCone, type: "fill", paint: {
12555
- "fill-color": "#0000ff",
12556
- "fill-antialias": false,
12557
- "fill-opacity": 0.3,
12558
- }, insertBeforeLayer: props.insertBeforeLayer })),
12619
+ isFollowed && orientationCone && (React__default.createElement(MlGeoJsonLayer, { geojson: orientationCone, type: "fill", paint: __assign({ "fill-color": "#0000ff", "fill-antialias": false, "fill-opacity": 0.3 }, props.orientationConePaint), insertBeforeLayer: props.insertBeforeLayer })),
12559
12620
  isFollowed && userLocationGeoJson && (React__default.createElement(MlGeoJsonLayer, { geojson: userLocationGeoJson, type: "circle", paint: __assign({ "circle-color": "#009ee0", "circle-radius": 5, "circle-stroke-color": "#fafaff", "circle-stroke-width": 1 }, props.circlePaint), insertBeforeLayer: props.insertBeforeLayer })),
12560
- React__default.createElement(Button$2, { sx: __assign({ zIndex: 1002, color: isFollowed ? props.onColor : props.offColor }, props.style), disabled: locationAccessDenied, onClick: function () {
12621
+ React__default.createElement(Button$2, { sx: __assign({ zIndex: 1002, color: isFollowed ? props.onColor : props.offColor }, props.buttonSx), disabled: locationAccessDenied, onClick: function () {
12561
12622
  setIsFollowed(!isFollowed);
12562
12623
  } },
12563
12624
  " ",
12564
- React__default.createElement(default_1$4, { sx: __assign({}, (((_a = props.style) === null || _a === void 0 ? void 0 : _a.fontSize) ? { fontSize: (_b = props.style) === null || _b === void 0 ? void 0 : _b.fontSize } : {})) }),
12625
+ React__default.createElement(default_1$4, { sx: __assign({}, (((_a = props.buttonSx) === null || _a === void 0 ? void 0 : _a.fontSize) ? { fontSize: (_b = props.buttonSx) === null || _b === void 0 ? void 0 : _b.fontSize } : {})) }),
12565
12626
  " ")));
12566
12627
  };
12567
12628
  MlFollowGps.defaultProps = {
12568
12629
  mapId: undefined,
12569
- style: {
12630
+ buttonSx: {
12570
12631
  minWidth: "30px",
12571
12632
  minHeight: "30px",
12572
12633
  width: "30px",
@@ -12585,6 +12646,8 @@ MlFollowGps.defaultProps = {
12585
12646
  showAccuracyCircle: true,
12586
12647
  showUserLocation: true,
12587
12648
  showOrientation: true,
12649
+ centerUserPosition: true,
12650
+ useFlyTo: false,
12588
12651
  };
12589
12652
 
12590
12653
  var MlImageMarkerLayer = function (props) {
@@ -13041,6 +13104,29 @@ var _default$2 = (0, _createSvgIcon$2.default)( /*#__PURE__*/(0, _jsxRuntime$2.j
13041
13104
 
13042
13105
  default_1$2 = RemoveCircleOutline.default = _default$2;
13043
13106
 
13107
+ function useTheme() {
13108
+ const theme = useTheme$1(defaultTheme$2);
13109
+
13110
+ if (process.env.NODE_ENV !== 'production') {
13111
+ // eslint-disable-next-line react-hooks/rules-of-hooks
13112
+ React.useDebugValue(theme);
13113
+ }
13114
+
13115
+ return theme;
13116
+ }
13117
+
13118
+ const defaultTheme = createTheme();
13119
+ /**
13120
+ * @ignore - do not document.
13121
+ */
13122
+
13123
+ const Box = createBox({
13124
+ defaultTheme,
13125
+ defaultClassName: 'MuiBox-root',
13126
+ generateClassName: ClassNameGenerator$1.generate
13127
+ });
13128
+ var Box$1 = Box;
13129
+
13044
13130
  function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
13045
13131
 
13046
13132
  var SvgRotateRight = function SvgRotateRight(props) {
@@ -13424,14 +13510,7 @@ var MlNavigationTools = function (props) {
13424
13510
  }
13425
13511
  mapHook.map.map.easeTo({ pitch: targetPitch });
13426
13512
  };
13427
- return (React__default.createElement("div", { style: {
13428
- zIndex: 501,
13429
- position: "absolute",
13430
- right: mediaIsMobile ? "15px" : "5px",
13431
- bottom: mediaIsMobile ? "40px" : "20px",
13432
- display: "flex",
13433
- flexDirection: "column",
13434
- } },
13513
+ return (React__default.createElement(Box$1, { sx: __assign(__assign({ zIndex: 501, position: "absolute", display: "flex", flexDirection: "column" }, (mediaIsMobile ? { margin: "20px 10px 20px 10px" } : {})), props.sx) },
13435
13514
  React__default.createElement(MlNavigationCompass, { style: {
13436
13515
  width: "31px",
13437
13516
  position: "relative",
@@ -13442,7 +13521,7 @@ var MlNavigationTools = function (props) {
13442
13521
  boxShadow: "0px 0px 18px rgba(0,0,0,.5)",
13443
13522
  } }),
13444
13523
  props.show3DButton && (React__default.createElement(Button$1, { sx: __assign(__assign({}, buttonStyle), { fontSize: mediaIsMobile ? "1.4em" : "1em", fontWeight: 600 }), onClick: adjustPitch }, pitch ? "2D" : "3D")),
13445
- props.showFollowGpsButton && (React__default.createElement(MlFollowGps, { style: __assign({}, (function (_a) {
13524
+ props.showFollowGpsButton && (React__default.createElement(MlFollowGps, { buttonSx: __assign({}, (function (_a) {
13446
13525
  _a.color; var rest = __rest(_a, ["color"]);
13447
13526
  return rest;
13448
13527
  })(buttonStyle)) })),
@@ -13471,6 +13550,10 @@ MlNavigationTools.defaultProps = {
13471
13550
  showFollowGpsButton: true,
13472
13551
  showCenterLocationButton: false,
13473
13552
  showZoomButtons: true,
13553
+ sx: {
13554
+ right: "5px",
13555
+ bottom: "20px",
13556
+ },
13474
13557
  };
13475
13558
 
13476
13559
  /**
@@ -13731,6 +13814,235 @@ MlWmsLayer.propTypes = {
13731
13814
  visible: PropTypes.bool,
13732
13815
  };
13733
13816
 
13817
+ function ownKeys(object, enumerableOnly) {
13818
+ var keys = Object.keys(object);
13819
+
13820
+ if (Object.getOwnPropertySymbols) {
13821
+ var symbols = Object.getOwnPropertySymbols(object);
13822
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
13823
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
13824
+ })), keys.push.apply(keys, symbols);
13825
+ }
13826
+
13827
+ return keys;
13828
+ }
13829
+
13830
+ function _objectSpread2(target) {
13831
+ for (var i = 1; i < arguments.length; i++) {
13832
+ var source = null != arguments[i] ? arguments[i] : {};
13833
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
13834
+ _defineProperty(target, key, source[key]);
13835
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
13836
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
13837
+ });
13838
+ }
13839
+
13840
+ return target;
13841
+ }
13842
+
13843
+ function _typeof(obj) {
13844
+ "@babel/helpers - typeof";
13845
+
13846
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
13847
+ return typeof obj;
13848
+ } : function (obj) {
13849
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
13850
+ }, _typeof(obj);
13851
+ }
13852
+
13853
+ function _defineProperty(obj, key, value) {
13854
+ if (key in obj) {
13855
+ Object.defineProperty(obj, key, {
13856
+ value: value,
13857
+ enumerable: true,
13858
+ configurable: true,
13859
+ writable: true
13860
+ });
13861
+ } else {
13862
+ obj[key] = value;
13863
+ }
13864
+
13865
+ return obj;
13866
+ }
13867
+
13868
+ function _slicedToArray(arr, i) {
13869
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
13870
+ }
13871
+
13872
+ function _toConsumableArray(arr) {
13873
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
13874
+ }
13875
+
13876
+ function _arrayWithoutHoles(arr) {
13877
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
13878
+ }
13879
+
13880
+ function _arrayWithHoles(arr) {
13881
+ if (Array.isArray(arr)) return arr;
13882
+ }
13883
+
13884
+ function _iterableToArray(iter) {
13885
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
13886
+ }
13887
+
13888
+ function _iterableToArrayLimit(arr, i) {
13889
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
13890
+
13891
+ if (_i == null) return;
13892
+ var _arr = [];
13893
+ var _n = true;
13894
+ var _d = false;
13895
+
13896
+ var _s, _e;
13897
+
13898
+ try {
13899
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
13900
+ _arr.push(_s.value);
13901
+
13902
+ if (i && _arr.length === i) break;
13903
+ }
13904
+ } catch (err) {
13905
+ _d = true;
13906
+ _e = err;
13907
+ } finally {
13908
+ try {
13909
+ if (!_n && _i["return"] != null) _i["return"]();
13910
+ } finally {
13911
+ if (_d) throw _e;
13912
+ }
13913
+ }
13914
+
13915
+ return _arr;
13916
+ }
13917
+
13918
+ function _unsupportedIterableToArray(o, minLen) {
13919
+ if (!o) return;
13920
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
13921
+ var n = Object.prototype.toString.call(o).slice(8, -1);
13922
+ if (n === "Object" && o.constructor) n = o.constructor.name;
13923
+ if (n === "Map" || n === "Set") return Array.from(o);
13924
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
13925
+ }
13926
+
13927
+ function _arrayLikeToArray(arr, len) {
13928
+ if (len == null || len > arr.length) len = arr.length;
13929
+
13930
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
13931
+
13932
+ return arr2;
13933
+ }
13934
+
13935
+ function _nonIterableSpread() {
13936
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
13937
+ }
13938
+
13939
+ function _nonIterableRest() {
13940
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
13941
+ }
13942
+
13943
+ var MlScaleReference = function MlScaleReference(props) {
13944
+ var zoomRef = useRef(0);
13945
+ var mapHook = useMap({
13946
+ mapId: props.mapId,
13947
+ waitForLayer: props.insertBeforeLayer
13948
+ });
13949
+
13950
+ var _useState = useState(0),
13951
+ _useState2 = _slicedToArray(_useState, 2),
13952
+ pxWidth = _useState2[0],
13953
+ setPxWidth = _useState2[1];
13954
+
13955
+ var _useState3 = useState(""),
13956
+ _useState4 = _slicedToArray(_useState3, 2),
13957
+ text = _useState4[0],
13958
+ setText = _useState4[1];
13959
+
13960
+ var updateScale = useCallback(function () {
13961
+ var _mapHook$map, _mapHook$map2;
13962
+
13963
+ if (((_mapHook$map = mapHook.map) === null || _mapHook$map === void 0 ? void 0 : _mapHook$map.map.getZoom()) === zoomRef.current) {
13964
+ return;
13965
+ }
13966
+
13967
+ if (!mapHook.map) return;
13968
+ zoomRef.current = (_mapHook$map2 = mapHook.map) === null || _mapHook$map2 === void 0 ? void 0 : _mapHook$map2.map.getZoom(); // Calculation from MapLibre
13969
+ // A horizontal scale is imagined to be present at center of the map
13970
+ // Using spherical law of cosines approximation, the real distance is
13971
+ // found between the two coordinates.
13972
+
13973
+ var maxWidth = props.maxWidth || 100;
13974
+ var y = mapHook.map._container.clientHeight / 2;
13975
+ var left = mapHook.map.unproject([0, y]);
13976
+ var right = mapHook.map.unproject([maxWidth, y]);
13977
+ var maxMeters = left.distanceTo(right); // The real distance corresponding to 100px scale length is rounded off to
13978
+ // near pretty number and the scale length for the same is found out.
13979
+ // Default unit of the scale is based on User's locale.
13980
+
13981
+ if (props.unit === "imperial") {
13982
+ var maxFeet = 3.2808 * maxMeters;
13983
+
13984
+ if (maxFeet > 5280) {
13985
+ var maxMiles = maxFeet / 5280;
13986
+ setScale(maxWidth, maxMiles, mapHook.map._getUIString("ScaleControl.Miles"));
13987
+ } else {
13988
+ setScale(maxWidth, maxFeet, mapHook.map._getUIString("ScaleControl.Feet"));
13989
+ }
13990
+ } else if (props.unit === "nautical") {
13991
+ var maxNauticals = maxMeters / 1852;
13992
+ setScale(maxWidth, maxNauticals, mapHook.map._getUIString("ScaleControl.NauticalMiles"));
13993
+ } else if (maxMeters >= 1000) {
13994
+ setScale(maxWidth, maxMeters / 1000, mapHook.map._getUIString("ScaleControl.Kilometers"));
13995
+ } else {
13996
+ setScale(maxWidth, maxMeters, mapHook.map._getUIString("ScaleControl.Meters"));
13997
+ }
13998
+ }, [mapHook.map, props.unit, props.maxWidth]);
13999
+ useEffect(function () {
14000
+ if (!mapHook.map) return;
14001
+ var _updateScale = updateScale;
14002
+ mapHook.map.on("move", _updateScale, mapHook.componentId);
14003
+ updateScale();
14004
+ return function () {
14005
+ mapHook.map.off("move", _updateScale);
14006
+ };
14007
+ }, [mapHook.map, updateScale]);
14008
+
14009
+ var setScale = function setScale(maxWidth, maxDistance, unit) {
14010
+ var distance = getRoundNum(maxDistance);
14011
+ var ratio = distance / maxDistance;
14012
+ setPxWidth(maxWidth * ratio);
14013
+ setText(distance + "&nbsp;" + unit);
14014
+ };
14015
+
14016
+ var getDecimalRoundNum = function getDecimalRoundNum(d) {
14017
+ var multiplier = Math.pow(10, Math.ceil(-Math.log(d) / Math.LN10));
14018
+ return Math.round(d * multiplier) / multiplier;
14019
+ };
14020
+
14021
+ var getRoundNum = function getRoundNum(num) {
14022
+ var pow10 = Math.pow(10, "".concat(Math.floor(num)).length - 1);
14023
+ var d = num / pow10;
14024
+ d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : d >= 1 ? 1 : getDecimalRoundNum(d);
14025
+ return pow10 * d;
14026
+ };
14027
+
14028
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
14029
+ style: {
14030
+ backgroundColor: "hsla(0,0%,100%,.75)",
14031
+ fontSize: "10px",
14032
+ border: "2px solid #333",
14033
+ borderTop: "#333",
14034
+ padding: "0 5px",
14035
+ color: "#333",
14036
+ boxSizing: "border-box",
14037
+ width: pxWidth + "px",
14038
+ fontFamily: "sans-serif"
14039
+ },
14040
+ dangerouslySetInnerHTML: {
14041
+ __html: text
14042
+ }
14043
+ }));
14044
+ };
14045
+
13734
14046
  /**
13735
14047
  *
13736
14048
  * Hides the MapLibreMap referenced by props.map2Id except for the "magnifier"-circle that reveals
@@ -13980,132 +14292,6 @@ var MlLayerSwipe = function (props) {
13980
14292
  }, onTouchStart: onDown, onMouseDown: onDown }));
13981
14293
  };
13982
14294
 
13983
- function ownKeys(object, enumerableOnly) {
13984
- var keys = Object.keys(object);
13985
-
13986
- if (Object.getOwnPropertySymbols) {
13987
- var symbols = Object.getOwnPropertySymbols(object);
13988
- enumerableOnly && (symbols = symbols.filter(function (sym) {
13989
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
13990
- })), keys.push.apply(keys, symbols);
13991
- }
13992
-
13993
- return keys;
13994
- }
13995
-
13996
- function _objectSpread2(target) {
13997
- for (var i = 1; i < arguments.length; i++) {
13998
- var source = null != arguments[i] ? arguments[i] : {};
13999
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
14000
- _defineProperty(target, key, source[key]);
14001
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
14002
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
14003
- });
14004
- }
14005
-
14006
- return target;
14007
- }
14008
-
14009
- function _typeof(obj) {
14010
- "@babel/helpers - typeof";
14011
-
14012
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
14013
- return typeof obj;
14014
- } : function (obj) {
14015
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
14016
- }, _typeof(obj);
14017
- }
14018
-
14019
- function _defineProperty(obj, key, value) {
14020
- if (key in obj) {
14021
- Object.defineProperty(obj, key, {
14022
- value: value,
14023
- enumerable: true,
14024
- configurable: true,
14025
- writable: true
14026
- });
14027
- } else {
14028
- obj[key] = value;
14029
- }
14030
-
14031
- return obj;
14032
- }
14033
-
14034
- function _slicedToArray(arr, i) {
14035
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
14036
- }
14037
-
14038
- function _toConsumableArray(arr) {
14039
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
14040
- }
14041
-
14042
- function _arrayWithoutHoles(arr) {
14043
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
14044
- }
14045
-
14046
- function _arrayWithHoles(arr) {
14047
- if (Array.isArray(arr)) return arr;
14048
- }
14049
-
14050
- function _iterableToArray(iter) {
14051
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
14052
- }
14053
-
14054
- function _iterableToArrayLimit(arr, i) {
14055
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
14056
-
14057
- if (_i == null) return;
14058
- var _arr = [];
14059
- var _n = true;
14060
- var _d = false;
14061
-
14062
- var _s, _e;
14063
-
14064
- try {
14065
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
14066
- _arr.push(_s.value);
14067
-
14068
- if (i && _arr.length === i) break;
14069
- }
14070
- } catch (err) {
14071
- _d = true;
14072
- _e = err;
14073
- } finally {
14074
- try {
14075
- if (!_n && _i["return"] != null) _i["return"]();
14076
- } finally {
14077
- if (_d) throw _e;
14078
- }
14079
- }
14080
-
14081
- return _arr;
14082
- }
14083
-
14084
- function _unsupportedIterableToArray(o, minLen) {
14085
- if (!o) return;
14086
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
14087
- var n = Object.prototype.toString.call(o).slice(8, -1);
14088
- if (n === "Object" && o.constructor) n = o.constructor.name;
14089
- if (n === "Map" || n === "Set") return Array.from(o);
14090
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
14091
- }
14092
-
14093
- function _arrayLikeToArray(arr, len) {
14094
- if (len == null || len > arr.length) len = arr.length;
14095
-
14096
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
14097
-
14098
- return arr2;
14099
- }
14100
-
14101
- function _nonIterableSpread() {
14102
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14103
- }
14104
-
14105
- function _nonIterableRest() {
14106
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14107
- }
14108
-
14109
14295
  var _showNextTransitionSegment = function _showNextTransitionSegment(props, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef, setDisplayGeojson) {
14110
14296
  var _arguments = arguments;
14111
14297
 
@@ -14308,17 +14494,6 @@ var MlTransitionGeoJsonLayer = function (props) {
14308
14494
  React__default.createElement(MlGeoJsonLayer, __assign({}, restProps, { geojson: displayGeojson }))));
14309
14495
  };
14310
14496
 
14311
- function useTheme() {
14312
- const theme = useTheme$1(defaultTheme$1);
14313
-
14314
- if (process.env.NODE_ENV !== 'production') {
14315
- // eslint-disable-next-line react-hooks/rules-of-hooks
14316
- React.useDebugValue(theme);
14317
- }
14318
-
14319
- return theme;
14320
- }
14321
-
14322
14497
  function getPaperUtilityClass(slot) {
14323
14498
  return generateUtilityClass('MuiPaper', slot);
14324
14499
  }
@@ -18830,5 +19005,5 @@ SimpleDataProvider.propTypes = {
18830
19005
  children: PropTypes.node.isRequired
18831
19006
  };
18832
19007
 
18833
- export { GeoJsonContext, GeoJsonProvider, MapComponentsProvider, MapContext, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlFollowGps, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlMarker, MlMeasureTool, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlSpatialElevationProfile, MlTransitionGeoJsonLayer, MlVectorTileLayer, MlWmsLayer, SimpleDataContext, SimpleDataProvider, useLayer, useMap, useMapState, useWms };
19008
+ export { GeoJsonContext, GeoJsonProvider, MapComponentsProvider, MapContext, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlFollowGps, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlMarker, MlMeasureTool, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlScaleReference, MlSpatialElevationProfile, MlTransitionGeoJsonLayer, MlVectorTileLayer, MlWmsLayer, SimpleDataContext, SimpleDataProvider, useLayer, useMap, useMapState, useWms };
18834
19009
  //# sourceMappingURL=index.esm.js.map