@mapcomponents/react-maplibre 0.1.13 → 0.1.17

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 (100) hide show
  1. package/.github/workflows/storybook.yml +4 -2
  2. package/CHANGELOG.md +33 -0
  3. package/README.md +22 -6
  4. package/coverage/clover.xml +447 -460
  5. package/coverage/coverage-final.json +14 -14
  6. package/coverage/lcov-report/index.html +77 -78
  7. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.js.html +2 -3
  8. package/coverage/lcov-report/src/components/MapLibreMap/index.html +2 -3
  9. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.js.html +2 -3
  10. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +2 -3
  11. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.js.html +2 -3
  12. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +2 -3
  13. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +2 -3
  14. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +2 -3
  15. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.js.html +112 -107
  16. package/coverage/lcov-report/src/components/MlFollowGps/index.html +16 -17
  17. package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.js.html +2 -3
  18. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +2 -3
  19. package/coverage/lcov-report/src/components/MlGPXViewer/index.html +2 -3
  20. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js.html +142 -134
  21. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +20 -21
  22. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +46 -152
  23. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +20 -21
  24. package/coverage/lcov-report/src/components/MlLayer/MlLayer.js.html +92 -30
  25. package/coverage/lcov-report/src/components/MlLayer/index.html +20 -21
  26. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.js.html +2 -3
  27. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +2 -3
  28. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.js.html +2 -3
  29. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +2 -3
  30. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +3 -10
  31. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +9 -82
  32. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +10 -11
  33. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +2 -3
  34. package/coverage/lcov-report/src/components/MlMarker/MlMarker.js.html +6 -7
  35. package/coverage/lcov-report/src/components/MlMarker/index.html +6 -7
  36. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.js.html +2 -3
  37. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +2 -3
  38. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.js.html +11 -15
  39. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +8 -9
  40. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +2 -3
  41. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +2 -3
  42. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +2 -3
  43. package/coverage/lcov-report/src/components/MlScaleReference/index.html +2 -3
  44. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +209 -18
  45. package/coverage/lcov-report/src/components/MlShareMapState/index.html +10 -11
  46. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +2 -3
  47. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +2 -3
  48. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +2 -3
  49. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +2 -3
  50. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +6 -25
  51. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +6 -7
  52. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.js.html +2 -3
  53. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +2 -3
  54. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +2 -3
  55. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +2 -3
  56. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.js.html +2 -3
  57. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +2 -3
  58. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.js.html +6 -19
  59. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +8 -9
  60. package/coverage/lcov-report/src/hooks/index.html +35 -36
  61. package/coverage/lcov-report/src/hooks/useMap.js.html +81 -169
  62. package/coverage/lcov-report/src/hooks/useMapState.js.html +82 -125
  63. package/coverage/lcov-report/src/hooks/useWms.js.html +9 -22
  64. package/coverage/lcov-report/src/i18n.js.html +2 -3
  65. package/coverage/lcov-report/src/index.html +2 -3
  66. package/coverage/lcov-report/src/translations/english.js.html +2 -3
  67. package/coverage/lcov-report/src/translations/german.js.html +2 -3
  68. package/coverage/lcov-report/src/translations/index.html +2 -3
  69. package/coverage/lcov.info +891 -896
  70. package/dist/index.esm.js +941 -717
  71. package/dist/index.esm.js.map +1 -1
  72. package/package.json +2 -2
  73. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +16 -14
  74. package/src/components/MlComponentTemplate/MlComponentTemplate.js +7 -32
  75. package/src/components/MlFollowGps/MlFollowGps.js +67 -65
  76. package/src/components/MlFollowGps/MlFollowGps.test.js +3 -5
  77. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js +91 -88
  78. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.stories.js +20 -6
  79. package/src/components/MlGeoJsonLayer/assets/sample_polygon_1.json +33 -0
  80. package/src/components/MlGeoJsonLayer/util/getDefaultLayerTypeByGeometry.js +25 -0
  81. package/src/components/MlGeoJsonLayer/util/getDefaultPaintPropsByType.js +22 -0
  82. package/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js +21 -56
  83. package/src/components/MlLayer/MlLayer.js +26 -5
  84. package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +0 -2
  85. package/src/components/MlLayerSwitcher/MlLayerSwitcher.stories.js +3 -6
  86. package/src/components/MlLayerSwitcher/components/LayerBox.js +2 -26
  87. package/src/components/MlMarker/MlMarker.js +1 -1
  88. package/src/components/MlNavigationTools/MlNavigationTools.js +4 -5
  89. package/src/components/MlShareMapState/MlShareMapState.js +73 -9
  90. package/src/components/MlShareMapState/MlShareMapState.stories.js +22 -2
  91. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.stories.js +1 -3
  92. package/src/components/MlUseMapDebugger/MlUseMapDebugger.js +1 -7
  93. package/src/components/MlWmsLoader/MlWmsLoader.js +0 -4
  94. package/src/hooks/useMap.js +33 -62
  95. package/src/hooks/useMapState.js +3 -17
  96. package/src/hooks/useWms.js +2 -7
  97. package/src/index.js +3 -0
  98. package/src/ui_components/ImageLoader.js +8 -3
  99. package/src/ui_components/Sidebar.js +1 -1
  100. package/src/ui_components/TopToolbar.js +0 -2
package/dist/index.esm.js CHANGED
@@ -5,17 +5,17 @@ import maplibregl from 'maplibre-gl/dist/maplibre-gl';
5
5
  import 'maplibre-gl/dist/maplibre-gl.css';
6
6
  import { v4 } from 'uuid';
7
7
  import Button from '@mui/material/Button';
8
+ import RoomIcon from '@mui/icons-material/Room';
9
+ import { lineString, length, lineChunk, point, circle, bbox, lineOffset, distance } from '@turf/turf';
8
10
  import maplibregl$1, { Popup } from 'maplibre-gl';
9
11
  import jsPDF from 'jspdf';
10
12
  import PrinterIcon from '@mui/icons-material/Print';
11
- import { lineString, length, lineChunk, point, bbox } from '@turf/turf';
12
13
  import ButtonGroup from '@mui/material/ButtonGroup';
13
14
  import ControlPointIcon from '@mui/icons-material/ControlPoint';
14
15
  import RemoveCircleOutlineIcon from '@mui/icons-material/RemoveCircleOutline';
15
16
  import GpsFixedIcon from '@mui/icons-material/GpsFixed';
16
17
  import _styled from '@emotion/styled/base';
17
18
  import { css } from '@emotion/css';
18
- import RoomIcon from '@mui/icons-material/Room';
19
19
  import useMediaQuery from '@mui/material/useMediaQuery';
20
20
  import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
21
21
  import MapboxDraw from '@mapbox/mapbox-gl-draw';
@@ -31,20 +31,16 @@ import FileCopy from '@mui/icons-material/FileCopy';
31
31
  import List from '@mui/material/List';
32
32
  import ListItem from '@mui/material/ListItem';
33
33
  import ListItemText from '@mui/material/ListItemText';
34
+ import { lineString as lineString$1, polygon } from '@turf/helpers';
34
35
 
35
36
  function ownKeys(object, enumerableOnly) {
36
37
  var keys = Object.keys(object);
37
38
 
38
39
  if (Object.getOwnPropertySymbols) {
39
40
  var symbols = Object.getOwnPropertySymbols(object);
40
-
41
- if (enumerableOnly) {
42
- symbols = symbols.filter(function (sym) {
43
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
44
- });
45
- }
46
-
47
- keys.push.apply(keys, symbols);
41
+ enumerableOnly && (symbols = symbols.filter(function (sym) {
42
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
43
+ })), keys.push.apply(keys, symbols);
48
44
  }
49
45
 
50
46
  return keys;
@@ -52,19 +48,12 @@ function ownKeys(object, enumerableOnly) {
52
48
 
53
49
  function _objectSpread2(target) {
54
50
  for (var i = 1; i < arguments.length; i++) {
55
- var source = arguments[i] != null ? arguments[i] : {};
56
-
57
- if (i % 2) {
58
- ownKeys(Object(source), true).forEach(function (key) {
59
- _defineProperty(target, key, source[key]);
60
- });
61
- } else if (Object.getOwnPropertyDescriptors) {
62
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
63
- } else {
64
- ownKeys(Object(source)).forEach(function (key) {
65
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
66
- });
67
- }
51
+ var source = null != arguments[i] ? arguments[i] : {};
52
+ i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
53
+ _defineProperty(target, key, source[key]);
54
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
55
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
56
+ });
68
57
  }
69
58
 
70
59
  return target;
@@ -73,17 +62,11 @@ function _objectSpread2(target) {
73
62
  function _typeof(obj) {
74
63
  "@babel/helpers - typeof";
75
64
 
76
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
77
- _typeof = function (obj) {
78
- return typeof obj;
79
- };
80
- } else {
81
- _typeof = function (obj) {
82
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
83
- };
84
- }
85
-
86
- return _typeof(obj);
65
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
66
+ return typeof obj;
67
+ } : function (obj) {
68
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
69
+ }, _typeof(obj);
87
70
  }
88
71
 
89
72
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -318,6 +301,8 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
318
301
  if (!Object.is(item.handler, handler)) {
319
302
  return item;
320
303
  }
304
+
305
+ return false;
321
306
  });
322
307
  },
323
308
 
@@ -341,7 +326,7 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
341
326
  /**
342
327
  * Array containing an object for each layer in the MapLibre instance providing information on visibility, loading state, order, paint & layout properties
343
328
  */
344
- layerState: {},
329
+ layerState: [],
345
330
 
346
331
  /**
347
332
  * Maps layerIds to layerState in JSON string form for quick deep comparisons
@@ -365,12 +350,12 @@ var MapLibreGlWrapper = function MapLibreGlWrapper(props) {
365
350
  //if (self.baseLayers.indexOf(layer.id) === -1) {
366
351
  var paint = {};
367
352
  var values = (_layer$paint = layer.paint) === null || _layer$paint === void 0 ? void 0 : _layer$paint._values;
368
- Object.keys(values || {}).map(function (propName) {
353
+ Object.keys(values || {}).forEach(function (propName) {
369
354
  paint[propName] = typeof values[propName].value !== "undefined" ? values[propName].value.value : values[propName];
370
355
  });
371
356
  var layout = {};
372
357
  values = (_layer$layout = layer.layout) === null || _layer$layout === void 0 ? void 0 : _layer$layout._values;
373
- Object.keys(values || {}).map(function (propName) {
358
+ Object.keys(values || {}).forEach(function (propName) {
374
359
  layout[propName] = typeof values[propName].value !== "undefined" ? values[propName].value.value : values[propName];
375
360
  });
376
361
  return {
@@ -854,28 +839,69 @@ MapLibreMap.propTypes = {
854
839
  };
855
840
 
856
841
  /**
857
- * TODO: Add short & useful description
858
- *
859
- * @param {object} props
860
- * @param {string} props.mapId Id of the target MapLibre instance in mapContext
842
+ * React hook that allows subscribing to map state changes
861
843
  *
862
844
  * @component
863
845
  */
864
846
 
865
- var MlComponentTemplate = function MlComponentTemplate(props) {
847
+ function useMapState(props) {
866
848
  // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
867
849
  var mapContext = useContext(MapContext);
868
850
  var initializedRef = useRef(false);
869
851
  var mapRef = useRef(undefined);
870
- var componentId = useRef((props.idPrefix ? props.idPrefix : "MlComponentTemplate-") + v4());
852
+
853
+ var _useState = useState(undefined),
854
+ _useState2 = _slicedToArray(_useState, 2),
855
+ viewport = _useState2[0],
856
+ setViewport = _useState2[1];
857
+
858
+ var viewportRef = useRef(undefined);
859
+
860
+ var _useState3 = useState(undefined),
861
+ _useState4 = _slicedToArray(_useState3, 2),
862
+ layers = _useState4[0],
863
+ setLayers = _useState4[1];
864
+
865
+ var layersRef = useRef(undefined); //const mapRef = useRef(props.map);
866
+
867
+ var componentId = useRef(v4());
868
+ /**
869
+ * returns the element if it matches the defined filter criteria
870
+ * to be used as filter function on the layers array
871
+ *
872
+ * @param {object} layer
873
+ */
874
+
875
+ var layerIdFilter = useCallback(function (layer) {
876
+ var _props$filter, _props$filter2;
877
+
878
+ if (!(props !== null && props !== void 0 && (_props$filter = props.filter) !== null && _props$filter !== void 0 && _props$filter.includeBaseLayers) && layer.baseLayer) {
879
+ return false;
880
+ }
881
+
882
+ if (typeof ((_props$filter2 = props.filter) === null || _props$filter2 === void 0 ? void 0 : _props$filter2.matchLayerIds) !== "undefined") {
883
+ if (props.filter.matchLayerIds instanceof RegExp) {
884
+ return props.filter.matchLayerIds.test(layer.id);
885
+ } else {
886
+ return layer.id.includes(props.filter.matchLayerIds);
887
+ }
888
+ }
889
+
890
+ return true;
891
+ }, [props.filter]);
892
+ var refreshLayerState = useCallback(function () {
893
+ var _layerState = mapRef.current.wrapper.layerState.filter(layerIdFilter);
894
+
895
+ var _layerStateString = JSON.stringify(_layerState);
896
+
897
+ if (layersRef.current !== _layerStateString) {
898
+ layersRef.current = _layerStateString;
899
+ setLayers(_layerState);
900
+ }
901
+ }, [layerIdFilter]);
871
902
  useEffect(function () {
872
903
  var _componentId = componentId.current;
873
904
  return function () {
874
- // This is the cleanup function, it is called when this react component is removed from react-dom
875
- // try to remove anything this component has added to the MapLibre-gl instance
876
- // e.g.: remove the layer
877
- // mapContext.getMap(props.mapId).removeLayer(layerRef.current);
878
- // check for the existence of map.style before calling getLayer or getSource
879
905
  if (mapRef.current) {
880
906
  mapRef.current.cleanup(_componentId);
881
907
  mapRef.current = undefined;
@@ -885,13 +911,167 @@ var MlComponentTemplate = function MlComponentTemplate(props) {
885
911
  };
886
912
  }, []);
887
913
  useEffect(function () {
914
+ var _props$watch, _props$watch2;
915
+
888
916
  if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
889
917
  // initialize the layer and add it to the MapLibre-gl instance or do something else with it
890
918
 
891
919
  initializedRef.current = true;
892
920
  mapRef.current = mapContext.getMap(props.mapId);
893
- mapRef.current.setCenter([7.132122000552613, 50.716405378037706]);
894
- }, [mapContext.mapIds, mapContext, props.mapId]);
921
+
922
+ if (props !== null && props !== void 0 && (_props$watch = props.watch) !== null && _props$watch !== void 0 && _props$watch.viewport) {
923
+ setViewport(mapRef.current.wrapper.viewportState);
924
+ mapRef.current.wrapper.on("viewportchange", function () {
925
+ var _mapRef$current;
926
+
927
+ if (viewportRef.current !== ((_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : _mapRef$current.wrapper.viewportStateString)) {
928
+ var _mapRef$current2;
929
+
930
+ setViewport((_mapRef$current2 = mapRef.current) === null || _mapRef$current2 === void 0 ? void 0 : _mapRef$current2.wrapper.viewportState);
931
+ }
932
+ }, componentId.current);
933
+ }
934
+
935
+ if (props !== null && props !== void 0 && (_props$watch2 = props.watch) !== null && _props$watch2 !== void 0 && _props$watch2.layers) {
936
+ var _props$filter3, _props$filter4;
937
+
938
+ refreshLayerState();
939
+ mapRef.current.wrapper.on("layerchange", refreshLayerState, {
940
+ includeBaseLayers: props === null || props === void 0 ? void 0 : (_props$filter3 = props.filter) === null || _props$filter3 === void 0 ? void 0 : _props$filter3.includeBaseLayers,
941
+ matchLayerIds: props === null || props === void 0 ? void 0 : (_props$filter4 = props.filter) === null || _props$filter4 === void 0 ? void 0 : _props$filter4.matchLayerIds
942
+ }, componentId.current);
943
+ }
944
+ }, [mapContext.mapIds, mapContext, props.mapId, refreshLayerState]);
945
+ return {
946
+ layers: layers,
947
+ viewport: viewport
948
+ };
949
+ }
950
+
951
+ useMapState.defaultProps = {
952
+ mapId: undefined,
953
+ watch: {
954
+ layers: true,
955
+ sources: false,
956
+ viewport: false
957
+ },
958
+ filter: {
959
+ includeBaseLayers: false
960
+ }
961
+ };
962
+ useMapState.propTypes = {
963
+ /**
964
+ * Id of the target MapLibre instance in mapContext
965
+ */
966
+ mapId: PropTypes.string,
967
+
968
+ /**
969
+ * Defines map Resources to watch
970
+ */
971
+ watch: PropTypes.shape({
972
+ layers: PropTypes.bool,
973
+ sources: PropTypes.bool,
974
+ viewport: PropTypes.bool
975
+ }),
976
+
977
+ /**
978
+ * Filter string or RegExp to more explicitly define the elements watched and increase performance
979
+ * strings will be matched using layerId.includes(matchString)
980
+ * RegExps will be matched using matchRegExp.test(layerId)
981
+ */
982
+ filter: PropTypes.shape({
983
+ includeBaseLayers: PropTypes.bool,
984
+ matchLayerIds: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(RegExp)]),
985
+ matchSourceIds: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(RegExp)])
986
+ })
987
+ };
988
+
989
+ function useMap(props) {
990
+ // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
991
+ var mapContext = useContext(MapContext);
992
+ var mapState = useMapState({
993
+ mapId: props.mapId,
994
+ watch: {
995
+ viewport: false,
996
+ layers: true,
997
+ sources: false
998
+ }
999
+ });
1000
+ var initializedRef = useRef(false);
1001
+ var mapRef = useRef(undefined);
1002
+ var componentId = useRef(v4());
1003
+
1004
+ var _useState = useState(undefined),
1005
+ _useState2 = _slicedToArray(_useState, 2),
1006
+ mapIsReady = _useState2[0],
1007
+ setMapIsReady = _useState2[1];
1008
+
1009
+ useEffect(function () {
1010
+ var _componentId = componentId.current;
1011
+ return function () {
1012
+ if (mapRef.current) {
1013
+ mapRef.current.cleanup(_componentId);
1014
+ mapRef.current = undefined;
1015
+ }
1016
+
1017
+ initializedRef.current = false;
1018
+ setMapIsReady(false);
1019
+ };
1020
+ }, []);
1021
+ useEffect(function () {
1022
+ if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; //check if insertBeforeLayer exists
1023
+
1024
+ if (props.waitForLayer) {
1025
+ var _mapState$layers;
1026
+
1027
+ var layerFound = false;
1028
+ mapState === null || mapState === void 0 ? void 0 : (_mapState$layers = mapState.layers) === null || _mapState$layers === void 0 ? void 0 : _mapState$layers.forEach(function (layer) {
1029
+ if (layer.id === props.waitForLayer) {
1030
+ layerFound = true;
1031
+ }
1032
+ });
1033
+
1034
+ if (!layerFound) {
1035
+ return;
1036
+ }
1037
+ } // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
1038
+ // initialize the layer and add it to the MapLibre-gl instance or do something else with it
1039
+
1040
+
1041
+ initializedRef.current = true;
1042
+ mapRef.current = mapContext.getMap(props.mapId);
1043
+ setMapIsReady(true);
1044
+ }, [mapContext.mapIds, mapState.layers, mapContext, props.mapId]);
1045
+ return {
1046
+ map: mapRef.current,
1047
+ mapIsReady: mapIsReady,
1048
+ componentId: componentId.current,
1049
+ layers: mapState.layers
1050
+ };
1051
+ }
1052
+
1053
+ /**
1054
+ * TODO: Add short & useful description
1055
+ *
1056
+ * @param {object} props
1057
+ * @param {string} props.mapId Id of the target MapLibre instance in mapContext
1058
+ *
1059
+ * @component
1060
+ */
1061
+
1062
+ var MlComponentTemplate = function MlComponentTemplate(props) {
1063
+ var mapHook = useMap({
1064
+ mapId: props.mapId,
1065
+ waitForLayer: props.insertBeforeLayer
1066
+ });
1067
+ var initializedRef = useRef(false);
1068
+ useEffect(function () {
1069
+ if (!mapHook.mapIsReady || initializedRef.current) return; // the MapLibre-gl instance (mapHook.map) is accessible here
1070
+ // initialize the layer and add it to the MapLibre-gl instance or do something else with it
1071
+
1072
+ initializedRef.current = true;
1073
+ mapHook.map.setCenter([7.132122000552613, 50.716405378037706]);
1074
+ }, [mapHook.map, mapHook.mapIsReady, props.mapId]);
895
1075
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
896
1076
  };
897
1077
 
@@ -1038,217 +1218,30 @@ MlFillExtrusionLayer.propTypes = {
1038
1218
  insertBeforeLayer: PropTypes.string
1039
1219
  };
1040
1220
 
1041
- var nmMap = {
1042
- street: ["footway", "street", "road", "street_name", "residential", "path", "pedestrian", "road_reference", "road_reference_intl", "square", "place"],
1043
- number: ["house_number", "street_number"],
1044
- place: ["city", "village", "hamlet", "locality", "croft", "neighbourhood", "suburb", "city_district", "district", "quarter", "borough", "city_block", "residential", "commercial", "industrial", "houses", "subdivision", "allotments", "postal_city", "town", "municipality", "local_administrative_area"],
1045
- zip: ["postcode", "partial_postcode"],
1046
- state: ["state", "province", "state_code"]
1047
- };
1048
-
1049
- var nmConverter = function nmConverter(nmAddress) {
1050
- var addressArr = [];
1051
-
1052
- for (var key in nmMap) {
1053
- nmMap[key].some(function (element) {
1054
- if (nmAddress.hasOwnProperty(element)) {
1055
- addressArr.push(nmAddress[element]);
1056
- return true;
1057
- }
1221
+ var _showNextTransitionSegment = function _showNextTransitionSegment(props, layerId, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef) {
1222
+ var _arguments = arguments;
1058
1223
 
1059
- return false;
1060
- });
1224
+ if (typeof map.getSource(layerId) === "undefined" || !transitionInProgressRef.current) {
1225
+ transitionTimeoutRef.current = setTimeout(function () {
1226
+ return _showNextTransitionSegment.apply(void 0, _toConsumableArray(_arguments));
1227
+ }, msPerStep);
1228
+ return;
1061
1229
  }
1062
1230
 
1063
- return addressArr.join(", ");
1064
- };
1231
+ if (typeof transitionGeojsonDataRef.current[currentTransitionStepRef.current] !== "undefined") {
1232
+ var _map$getSource;
1065
1233
 
1066
- var toPixels = function toPixels(length) {
1067
- var conversionFactor = 96;
1068
- conversionFactor /= 25.4;
1069
- return conversionFactor * length + "px";
1070
- };
1234
+ var newData = currentTransitionStepRef.current + 1 === transitionGeojsonDataRef.current.length ? props.geojson : lineString([].concat(_toConsumableArray(transitionGeojsonCommonDataRef.current), _toConsumableArray(transitionGeojsonDataRef.current[currentTransitionStepRef.current].geometry.coordinates)));
1071
1235
 
1072
- var createPdf = function createPdf(map, locationValue, setLoading) {
1073
- setLoading(true);
1074
- var width = 210;
1075
- var height = 297; // Calculate pixel ratio
1236
+ if (!(map !== null && map !== void 0 && (_map$getSource = map.getSource) !== null && _map$getSource !== void 0 && _map$getSource.call(map, layerId))) {
1237
+ return;
1238
+ }
1076
1239
 
1077
- var actualPixelRatio = window.devicePixelRatio; // Create map container
1240
+ map.getSource(layerId).setData(newData);
1078
1241
 
1079
- var hidden = document.createElement("div");
1080
- hidden.className = "hidden-map";
1081
- document.body.appendChild(hidden);
1082
- var container = document.createElement("div");
1083
- container.style.width = toPixels(width);
1084
- container.style.height = toPixels(height);
1085
- hidden.appendChild(container); //Render map
1086
-
1087
- var renderMap = new maplibregl$1.Map({
1088
- container: container,
1089
- center: map.getCenter(),
1090
- zoom: map.getZoom(),
1091
- bearing: map.getBearing(),
1092
- pitch: map.getPitch(),
1093
- interactive: false,
1094
- preserveDrawingBuffer: true,
1095
- fadeDuration: 0,
1096
- attributionControl: false
1097
- });
1098
- var style = map.getStyle();
1099
-
1100
- var _loop = function _loop(name) {
1101
- var src = style.sources[name];
1102
- Object.keys(src).forEach(function (key) {
1103
- //delete properties if value is undefined.
1104
- // for instance, raster-dem might has undefined value in "url" and "bounds"
1105
- if (!src[key]) {
1106
- delete src[key];
1107
- }
1108
- });
1109
- };
1110
-
1111
- for (var name in style.sources) {
1112
- _loop(name);
1113
- }
1114
-
1115
- renderMap.setStyle(style);
1116
- renderMap.once("idle", function () {
1117
- var _hidden$parentNode;
1118
-
1119
- // TO DO: It is still under development
1120
- var pdf = new jsPDF({
1121
- orientation: "p",
1122
- unit: "mm",
1123
- compress: true
1124
- });
1125
- Object.defineProperty(window, "devicePixelRatio", {
1126
- get: function get() {
1127
- return 300 / 96;
1128
- }
1129
- });
1130
- var offsetX = 2.5;
1131
- var offsetY = 2.5;
1132
- var marginTop = 3;
1133
- var marginBottom = 3;
1134
- var innerMargin = 2;
1135
- var logo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKgAAACxCAMAAABnTAbVAAAC8VBMVEUAAAD/AACAAACqAFW/AECZMzOqK1W2JEm/IECqHDmzGk25F0aqFUCxJzu2JEmq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UqqaB7stYr1MaJNQRDV3wG7v8DdrJGjU7SBVXA+7fcELPgyFZh2+oL/+sJmjjOd9HAYdWuXQzxWwWS+e92EodJEWeagQA5tNJ7khFHrdUk65cNgsh8wOhX4991GmFewVVs7nHTAiYil9tYO9Uuruh1F3n2GTONjr6dEwrnMevfrBXrEwwzGvig3GomXrvoP1HkQLJ6WV8II30OJ1XO0huQu/AwN3k5Vh+B1wpP3EIfhdCE2fhv+X/wF/AO+L9vuzfwAAAABJRU5ErkJggg==";
1136
- var textBuffer = 1;
1137
- var lineHeight = 3.25;
1138
- var text = locationValue ? nmConverter(locationValue.address) : "";
1139
- var textChunksSeperator = text.split(",");
1140
- var textChunks = [];
1141
-
1142
- if (textChunks.length) {
1143
- textChunksSeperator.forEach(function (chunk) {
1144
- var limitChunks = chunk.match(/.{1,34}/g);
1145
- textChunks.push.apply(textChunks, _toConsumableArray(limitChunks));
1146
- });
1147
- } //Render map image
1148
-
1149
-
1150
- pdf.addImage(renderMap.getCanvas().toDataURL("image/png"), "png", 0, 0, 210, 297, null, "FAST"); //Render lower left Copyright box
1151
-
1152
- pdf.setFillColor("white");
1153
- pdf.rect(138, 287, 297, 10, "F");
1154
- pdf.setFontSize(10); // optional
1155
-
1156
- pdf.text("Datenquelle: © OpenStreetMap-Mitwirkende", 140, pdf.internal.pageSize.height - 3); //Render infobox
1157
-
1158
- pdf.setFillColor("white");
1159
- var infoBoxSize = textChunks.length * lineHeight + marginTop + marginBottom + lineHeight * 2 + innerMargin * 2 + textBuffer;
1160
- pdf.rect(offsetX, 2, 66.5, infoBoxSize, "F");
1161
- pdf.setFontSize(10);
1162
- pdf.text("Karten PDF:", 6, offsetY + marginTop); //Render inner infobox
1163
-
1164
- pdf.rect(6, 7, 60, textChunks.length * lineHeight + innerMargin * 2 + textBuffer);
1165
- pdf.setFontSize(10); //Write out address
1166
-
1167
- textChunks.forEach(function (text, i) {
1168
- pdf.text(text.trim(), 8, 10 + i * 3.5 + innerMargin);
1169
- }); //Add WG Logo
1170
-
1171
- pdf.addImage(logo, "png", 5, offsetY + marginTop + lineHeight * 2 + textChunks.length * 3 + innerMargin * 2, 3, 3, null, "FAST"); //Add WG Url
1172
-
1173
- pdf.setFontSize(10);
1174
- pdf.text("wheregroup.com", 40, offsetY + marginTop + lineHeight * 2 + textChunks.length * lineHeight + innerMargin * 2 + textBuffer); //Set pdfs props
1175
-
1176
- pdf.setProperties({
1177
- title: "Map export",
1178
- subject: "Map export",
1179
- creator: "WhereGroup GmbH",
1180
- author: "(c)WhereGroup GmbH, (c)OpenStreetMap"
1181
- });
1182
- pdf.save("Map.pdf");
1183
- renderMap.remove();
1184
- (_hidden$parentNode = hidden.parentNode) === null || _hidden$parentNode === void 0 ? void 0 : _hidden$parentNode.removeChild(hidden);
1185
- Object.defineProperty(window, "devicePixelRatio", {
1186
- get: function get() {
1187
- return actualPixelRatio;
1188
- }
1189
- });
1190
- setLoading(false);
1191
- });
1192
- };
1193
-
1194
- /**
1195
- * Renders a button that will create a PDF version of the current map view (dimensions adjusted to fit Din A4 Paper).
1196
- *
1197
- * @component
1198
- */
1199
-
1200
- var MlCreatePdfButton = function MlCreatePdfButton(props) {
1201
- var mapContext = useContext(MapContext);
1202
- var initializedRef = useRef(false);
1203
- var mapRef = useRef(undefined);
1204
- useEffect(function () {
1205
- if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
1206
- initializedRef.current = true;
1207
- mapRef.current = mapContext.getMap(props.mapId);
1208
- }, [mapContext.mapIds, mapContext, props.mapId]);
1209
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button, {
1210
- color: "primary",
1211
- variant: "contained",
1212
- onClick: function onClick() {
1213
- createPdf(mapRef.current, null, function () {});
1214
- }
1215
- }, /*#__PURE__*/React__default.createElement(PrinterIcon, null)));
1216
- };
1217
-
1218
- MlCreatePdfButton.defaultProps = {
1219
- mapId: undefined
1220
- };
1221
- MlCreatePdfButton.propTypes = {
1222
- /**
1223
- * Id of the target MapLibre instance in mapContext
1224
- */
1225
- mapId: PropTypes.string
1226
- };
1227
-
1228
- var _showNextTransitionSegment = function _showNextTransitionSegment(props, layerId, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef) {
1229
- var _arguments = arguments;
1230
-
1231
- if (typeof map.getSource(layerId) === "undefined" || !transitionInProgressRef.current) {
1232
- transitionTimeoutRef.current = setTimeout(function () {
1233
- return _showNextTransitionSegment.apply(void 0, _toConsumableArray(_arguments));
1234
- }, msPerStep);
1235
- return;
1236
- }
1237
-
1238
- if (typeof transitionGeojsonDataRef.current[currentTransitionStepRef.current] !== "undefined") {
1239
- var _map$getSource;
1240
-
1241
- var newData = currentTransitionStepRef.current + 1 === transitionGeojsonDataRef.current.length ? props.geojson : lineString([].concat(_toConsumableArray(transitionGeojsonCommonDataRef.current), _toConsumableArray(transitionGeojsonDataRef.current[currentTransitionStepRef.current].geometry.coordinates)));
1242
-
1243
- if (!(map !== null && map !== void 0 && (_map$getSource = map.getSource) !== null && _map$getSource !== void 0 && _map$getSource.call(map, layerId))) {
1244
- return;
1245
- }
1246
-
1247
- map.getSource(layerId).setData(newData);
1248
-
1249
- if (typeof props.onTransitionFrame === "function") {
1250
- props.onTransitionFrame(newData);
1251
- }
1242
+ if (typeof props.onTransitionFrame === "function") {
1243
+ props.onTransitionFrame(newData);
1244
+ }
1252
1245
 
1253
1246
  currentTransitionStepRef.current++;
1254
1247
 
@@ -1388,7 +1381,58 @@ var _transitionToGeojson = function _transitionToGeojson(newGeojson, props, tran
1388
1381
  }, msPerStep);
1389
1382
  };
1390
1383
 
1384
+ var getDefaultPaintPropsByType = function getDefaultPaintPropsByType(type) {
1385
+ switch (type) {
1386
+ case "fill":
1387
+ return {
1388
+ "fill-color": "rgba(10,240,256,0.6)"
1389
+ };
1390
+
1391
+ case "line":
1392
+ return {
1393
+ "line-color": "rgb(100,200,100)",
1394
+ "line-width": 5
1395
+ };
1396
+
1397
+ case "circle":
1398
+ default:
1399
+ return {
1400
+ "circle-color": "#44aaaa",
1401
+ "circle-stroke-color": "#fff",
1402
+ "circle-stroke-width": 2
1403
+ };
1404
+ }
1405
+ };
1406
+
1407
+ var mapGeometryTypesToLayerTypes = {
1408
+ Position: "circle",
1409
+ Point: "circle",
1410
+ MultiPoint: "circle",
1411
+ LineString: "line",
1412
+ MultiLineString: "line",
1413
+ Polygon: "fill",
1414
+ MultiPolygon: "fill",
1415
+ GeometryCollection: "circle"
1416
+ };
1417
+
1418
+ var getDefaulLayerTypeByGeometry = function getDefaulLayerTypeByGeometry(geojson) {
1419
+ if ((geojson === null || geojson === void 0 ? void 0 : geojson.type) === "Feature") {
1420
+ var _geojson$geometry;
1421
+
1422
+ return mapGeometryTypesToLayerTypes !== null && mapGeometryTypesToLayerTypes !== void 0 && mapGeometryTypesToLayerTypes[geojson === null || geojson === void 0 ? void 0 : (_geojson$geometry = geojson.geometry) === null || _geojson$geometry === void 0 ? void 0 : _geojson$geometry.type] ? mapGeometryTypesToLayerTypes[geojson.geometry.type] : "circle";
1423
+ }
1424
+
1425
+ if ((geojson === null || geojson === void 0 ? void 0 : geojson.type) === "FeatureCollection") {
1426
+ if (geojson.features.length) {
1427
+ return getDefaulLayerTypeByGeometry(geojson.features[0]);
1428
+ }
1429
+
1430
+ return "circle";
1431
+ }
1432
+ };
1433
+
1391
1434
  var msPerStep = 50;
1435
+ var legalLayerTypes = ["circle", "fill", "line"];
1392
1436
  /**
1393
1437
  * Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
1394
1438
  *
@@ -1397,53 +1441,49 @@ var msPerStep = 50;
1397
1441
 
1398
1442
  var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
1399
1443
  // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
1400
- var mapContext = useContext(MapContext);
1401
- var oldGeojsonRef = useRef(null);
1402
- var mapRef = useRef(null);
1444
+ var mapHook = useMap({
1445
+ mapId: props.mapId,
1446
+ waitForLayer: props.insertBeforeLayer
1447
+ });
1403
1448
  var initializedRef = useRef(false);
1449
+ var layerId = useRef(props.layerId || "MlGeoJsonLayer-" + mapHook.componentId);
1450
+ var layerTypeRef = useRef(undefined); // transition effect variables
1451
+
1452
+ var oldGeojsonRef = useRef(null);
1404
1453
  var transitionInProgressRef = useRef(false);
1405
1454
  var transitionTimeoutRef = useRef(undefined);
1406
1455
  var currentTransitionStepRef = useRef(false);
1407
1456
  var transitionGeojsonDataRef = useRef([]);
1408
1457
  var transitionGeojsonCommonDataRef = useRef([]);
1409
- var componentId = useRef((props.layerId ? props.layerId : "MlGeoJsonLayer-") + (props.idSuffix || v4()));
1410
- var layerId = useRef(props.layerId || componentId.current);
1411
1458
  useEffect(function () {
1412
- var _componentId = componentId.current;
1413
1459
  return function () {
1414
1460
  // This is the cleanup function, it is called when this react component is removed from react-dom
1415
1461
  if (transitionTimeoutRef.current) {
1416
1462
  clearTimeout(transitionTimeoutRef.current);
1417
1463
  }
1418
-
1419
- if (mapRef.current) {
1420
- mapRef.current.cleanup(_componentId);
1421
- mapRef.current = null;
1422
- }
1423
1464
  };
1424
1465
  }, []);
1425
1466
  useEffect(function () {
1426
- if (!mapRef.current || !initializedRef.current) return;
1467
+ if (!mapHook.map || !initializedRef.current) return;
1427
1468
 
1428
1469
  for (var key in props.layout) {
1429
- mapContext.getMap(props.mapId).setLayoutProperty(layerId.current, key, props.layout[key]);
1470
+ mapHook.map.setLayoutProperty(layerId.current, key, props.layout[key]);
1430
1471
  }
1431
- }, [props.layout, mapContext, props.mapId]);
1472
+ }, [props.layout, mapHook.map, props.mapId]);
1432
1473
  useEffect(function () {
1433
- if (!mapRef.current || !initializedRef.current) return;
1474
+ if (!mapHook.map || !initializedRef.current) return;
1434
1475
 
1435
1476
  for (var key in props.paint) {
1436
- mapContext.getMap(props.mapId).setPaintProperty(layerId.current, key, props.paint[key]);
1477
+ mapHook.map.setPaintProperty(layerId.current, key, props.paint[key]);
1437
1478
  }
1438
- }, [props.paint, mapContext, props.mapId]);
1479
+ }, [props.paint, mapHook.map, props.mapId]);
1439
1480
  var transitionToGeojson = useCallback(function (newGeojson) {
1440
- _transitionToGeojson(newGeojson, props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, mapRef.current, componentId.current, transitionTimeoutRef);
1441
- }, [props]);
1481
+ _transitionToGeojson(newGeojson, props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, mapHook.map, layerId.current, transitionTimeoutRef);
1482
+ }, [props, mapHook.map]);
1442
1483
  useEffect(function () {
1443
- var _mapRef$current, _mapRef$current$getSo;
1484
+ var _mapHook$map;
1444
1485
 
1445
- if (!((_mapRef$current = mapRef.current) !== null && _mapRef$current !== void 0 && (_mapRef$current$getSo = _mapRef$current.getSource) !== null && _mapRef$current$getSo !== void 0 && _mapRef$current$getSo.call(_mapRef$current, componentId.current)) || !initializedRef.current) return; // the MapLibre-gl instance (mapContext.map) is accessible here
1446
- // initialize the layer and add it to the MapLibre-gl instance or do something else with it
1486
+ if (!(mapHook !== null && mapHook !== void 0 && (_mapHook$map = mapHook.map) !== null && _mapHook$map !== void 0 && _mapHook$map.getSource(layerId.current)) || !initializedRef.current) return;
1447
1487
 
1448
1488
  if (typeof props.transitionTime !== "undefined" && props.type === "line" && oldGeojsonRef.current) {
1449
1489
  transitionInProgressRef.current = false;
@@ -1452,57 +1492,61 @@ var MlGeoJsonLayer = function MlGeoJsonLayer(props) {
1452
1492
  transitionGeojsonCommonDataRef.current = [];
1453
1493
  transitionToGeojson(props.geojson);
1454
1494
  } else {
1455
- mapRef.current.getSource(componentId.current).setData(props.geojson);
1495
+ mapHook.map.getSource(layerId.current).setData(props.geojson);
1456
1496
  }
1457
1497
 
1458
1498
  oldGeojsonRef.current = props.geojson;
1459
- }, [props.geojson, props.mapId, mapContext, props.type, transitionToGeojson, props.transitionTime]);
1460
- useEffect(function () {
1461
- if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.map) is accessible here
1462
- // initialize the layer and add it to the MapLibre-gl instance or do something else with it
1499
+ }, [props.geojson, props.mapId, mapHook.map, props.type, transitionToGeojson, props.transitionTime]);
1500
+ var createLayer = useCallback(function () {
1501
+ var geojson = props.geojson;
1463
1502
 
1464
- if (props.geojson) {
1465
- initializedRef.current = true;
1466
- var geojson = props.geojson;
1503
+ if (props.type === "line" && typeof props.transitionTime !== "undefined" && props.transitionTime && typeof props.geojson.geometry !== "undefined") {
1504
+ var tmpChunks = lineChunk(props.geojson, 0.01);
1505
+ geojson = tmpChunks.features[0];
1506
+ }
1467
1507
 
1468
- if (props.type === "line" && typeof props.transitionTime !== "undefined" && props.transitionTime && typeof props.geojson.geometry !== "undefined") {
1469
- var tmpChunks = lineChunk(props.geojson, 0.01);
1470
- geojson = tmpChunks.features[0];
1471
- }
1508
+ layerTypeRef.current = props.type || getDefaulLayerTypeByGeometry(props.geojson);
1509
+ mapHook.map.addLayer({
1510
+ id: layerId.current,
1511
+ source: {
1512
+ type: "geojson",
1513
+ data: geojson
1514
+ },
1515
+ type: layerTypeRef.current,
1516
+ paint: props.paint || getDefaultPaintPropsByType(layerTypeRef.current),
1517
+ layout: props.layout || {}
1518
+ }, props.insertBeforeLayer, mapHook.componentId);
1472
1519
 
1473
- mapRef.current = mapContext.getMap(props.mapId);
1474
- mapRef.current.addLayer({
1475
- id: layerId.current,
1476
- source: {
1477
- type: "geojson",
1478
- data: geojson
1479
- },
1480
- type: props.type || "line",
1481
- paint: props.paint || {
1482
- "line-color": "rgb(100,200,100)",
1483
- "line-width": 10
1484
- },
1485
- layout: props.layout || {}
1486
- }, props.insertBeforeLayer, componentId.current);
1487
-
1488
- if (typeof props.onHover !== "undefined") {
1489
- mapRef.current.on("mousemove", componentId.current, props.onHover, componentId.current);
1490
- }
1520
+ if (typeof props.onHover !== "undefined") {
1521
+ mapHook.map.on("mousemove", mapHook.componentId, props.onHover, mapHook.componentId);
1522
+ }
1491
1523
 
1492
- if (typeof props.onClick !== "undefined") {
1493
- mapRef.current.on("click", componentId.current, props.onClick, componentId.current);
1494
- }
1524
+ if (typeof props.onClick !== "undefined") {
1525
+ mapHook.map.on("click", mapHook.componentId, props.onClick, mapHook.componentId);
1526
+ }
1495
1527
 
1496
- if (typeof props.onLeave !== "undefined") {
1497
- mapRef.current.on("mouseleave", componentId.current, props.onLeave, componentId.current);
1498
- }
1528
+ if (typeof props.onLeave !== "undefined") {
1529
+ mapHook.map.on("mouseleave", mapHook.componentId, props.onLeave, mapHook.componentId);
1530
+ }
1499
1531
 
1500
- if (props.type === "line" && typeof props.transitionTime !== "undefined" && typeof props.geojson.geometry !== "undefined") {
1501
- transitionToGeojson(props.geojson);
1502
- oldGeojsonRef.current = props.geojson;
1503
- }
1532
+ if (props.type === "line" && typeof props.transitionTime !== "undefined" && typeof props.geojson.geometry !== "undefined") {
1533
+ transitionToGeojson(props.geojson);
1534
+ oldGeojsonRef.current = props.geojson;
1504
1535
  }
1505
- }, [mapContext.mapIds, mapContext, props, transitionToGeojson]);
1536
+ }, [mapHook.map, props, transitionToGeojson]);
1537
+ useEffect(function () {
1538
+ if (!mapHook.mapIsReady || !props.geojson) return;
1539
+
1540
+ if (initializedRef.current && legalLayerTypes.indexOf(props.type) !== -1 && layerTypeRef.current && props.type !== layerTypeRef.current) {
1541
+ mapHook.map.cleanup(mapHook.componentId);
1542
+ } else if (initializedRef.current && (legalLayerTypes.indexOf(props.type) === -1 || legalLayerTypes.indexOf(props.type) !== -1 && props.type === layerTypeRef.current)) {
1543
+ return;
1544
+ } // initialize the layer and add it to the MapLibre-gl instance or do something else with it
1545
+
1546
+
1547
+ initializedRef.current = true;
1548
+ createLayer();
1549
+ }, [mapHook.mapIsReady, createLayer, props]);
1506
1550
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
1507
1551
  };
1508
1552
 
@@ -1572,52 +1616,35 @@ MlGeoJsonLayer.propTypes = {
1572
1616
  * Creates transition animation whenever the geojson prop changes.
1573
1617
  * Only works with layer type "line" and LineString GeoJSON data.
1574
1618
  */
1575
- transitionTime: PropTypes.number,
1576
-
1577
- /**
1578
- * Id suffix string that is appended to the componentId.
1579
- * Probably removed soon.
1580
- */
1581
- idSuffix: PropTypes.string
1619
+ transitionTime: PropTypes.number
1582
1620
  };
1583
1621
 
1584
1622
  var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
1585
- // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
1586
- var mapRef = useRef(null);
1587
- var componentId = useRef((props.idPrefix ? props.idPrefix : "MlImageMarkerLayer-") + v4());
1588
- var mapContext = useContext(MapContext);
1623
+ var mapHook = useMap({
1624
+ mapId: props.mapId,
1625
+ waitForLayer: props.insertBeforeLayer
1626
+ });
1589
1627
  var layerInitializedRef = useRef(false);
1590
- var idSuffixRef = useRef(props.idSuffix || new Date().getTime());
1591
1628
  var imageIdRef = useRef(props.imageId || "img_" + new Date().getTime());
1592
- var layerId = useRef(props.layerId || componentId.current);
1593
- useEffect(function () {
1594
- var _componentId = componentId.current;
1595
- return function () {
1596
- // This is the cleanup function, it is called when this react component is removed from react-dom
1597
- if (mapRef.current) {
1598
- mapRef.current.cleanup(_componentId);
1599
- mapRef.current = null;
1600
- }
1601
- };
1602
- }, []);
1629
+ var layerId = useRef(props.layerId || "MlImageMarkerLayer-" + mapHook.componentId);
1603
1630
  useEffect(function () {
1604
- if (!mapRef.current || mapRef.current && !mapContext.getMap(props.mapId).getLayer(layerId.current) || !props.options) return; // the MapLibre-gl instance (mapContext.map) is accessible here
1631
+ if (!mapHook.mapIsReady || mapHook.map && !mapHook.map.getLayer(layerId.current) || !props.options) return; // the MapLibre-gl instance (mapContext.map) is accessible here
1605
1632
  // initialize the layer and add it to the MapLibre-gl instance or do something else with it
1606
1633
 
1607
1634
  var key;
1608
1635
 
1609
1636
  if (props.options.layout) {
1610
1637
  for (key in props.options.layout) {
1611
- mapContext.getMap(props.mapId).setLayoutProperty(layerId.current, key, props.options.layout[key]);
1638
+ mapHook.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);
1612
1639
  }
1613
1640
  }
1614
1641
 
1615
1642
  if (props.options.paint) {
1616
1643
  for (key in props.options.paint) {
1617
- mapContext.getMap(props.mapId).setPaintProperty(layerId.current, key, props.options.paint[key]);
1644
+ mapHook.map.setPaintProperty(layerId.current, key, props.options.paint[key]);
1618
1645
  }
1619
1646
  }
1620
- }, [props.options, layerId.current, mapContext, props.mapId]);
1647
+ }, [props.options, layerId.current, props.mapId]);
1621
1648
  var addLayer = useCallback(function () {
1622
1649
  var tmpOptions = _objectSpread2({
1623
1650
  id: layerId.current,
@@ -1625,49 +1652,398 @@ var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
1625
1652
  }, props.options);
1626
1653
 
1627
1654
  tmpOptions.layout["icon-image"] = imageIdRef.current;
1628
- mapRef.current.addLayer(tmpOptions, props.insertBeforeLayer, componentId.current);
1629
- }, [props]);
1655
+ mapHook.map.addLayer(tmpOptions, props.insertBeforeLayer, mapHook.componentId);
1656
+ }, [props, mapHook.mapIsReady, mapHook.map]);
1630
1657
  useEffect(function () {
1631
- if (!props.options || !mapContext.mapExists(props.mapId) || layerInitializedRef.current) return; // the MapLibre-gl instance (mapContext.map) is accessible here
1632
- // initialize the layer and add it to the MapLibre-gl instance or do something else with it
1633
-
1634
- mapRef.current = mapContext.getMap(props.mapId);
1658
+ if (!props.options || !mapHook.mapIsReady || layerInitializedRef.current) return;
1635
1659
  layerInitializedRef.current = true;
1636
- console.log(props.imgSrc);
1637
1660
 
1638
1661
  if (props.imgSrc) {
1639
- mapRef.current.loadImage(props.imgSrc, function (error, image) {
1662
+ mapHook.map.loadImage(props.imgSrc, function (error, image) {
1640
1663
  if (error) throw error;
1641
- mapRef.current.addImage(imageIdRef.current, image, componentId.current);
1664
+ mapHook.map.addImage(imageIdRef.current, image, mapHook.componentId);
1642
1665
  });
1643
1666
  }
1644
1667
 
1645
1668
  addLayer();
1646
- }, [mapContext.mapIds, mapContext, props, addLayer]);
1669
+ }, [mapHook.mapIsReady, mapHook.map, addLayer, props]);
1647
1670
  useEffect(function () {
1648
- if (!mapRef.current || mapRef.current && !mapContext.getMap(props.mapId).getLayer(layerId.current) || !props.options) {
1671
+ if (!mapHook.mapIsReady || mapHook.map && !mapHook.map.getLayer(layerId.current) || !props.options) {
1649
1672
  return;
1650
- } // the MapLibre-gl instance (mapContext.map) is accessible here
1651
- // initialize the layer and add it to the MapLibre-gl instance or do something else with it
1652
-
1673
+ }
1653
1674
 
1654
- mapRef.current.getSource(layerId.current).setData(props.options.source.data);
1655
- }, [props.options.source.data, mapContext, props]);
1675
+ mapHook.map.getSource(layerId.current).setData(props.options.source.data);
1676
+ }, [props.options.source.data, props]);
1656
1677
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
1657
1678
  };
1658
1679
 
1659
- function _extends() { _extends = 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.apply(this, arguments); }
1680
+ var marker = "b556faa3bc6829d2.png";
1660
1681
 
1661
- function SvgRotateRight(props) {
1662
- return /*#__PURE__*/createElement("svg", _extends({
1663
- width: "39.675098mm",
1664
- height: "104.27064mm",
1665
- viewBox: "0 0 39.675098 104.27064"
1666
- }, props), /*#__PURE__*/createElement("g", {
1667
- transform: "translate(-86.019554,-58.032633)"
1668
- }, /*#__PURE__*/createElement("path", {
1669
- style: {
1670
- strokeWidth: 0.744756
1682
+ /**
1683
+ * Adds a button that makes the map follow the users GPS position using
1684
+ * navigator.geolocation.watchPosition if activated
1685
+ *
1686
+ * @param {object} props
1687
+ * @param {string} props.mapId Id of the target MapLibre instance in mapContext
1688
+ *
1689
+ * @component
1690
+ */
1691
+
1692
+ var MlFollowGps = function MlFollowGps(props) {
1693
+ var mapHook = useMap({
1694
+ mapId: props.mapId,
1695
+ waitForLayer: props.insertBeforeLayer
1696
+ });
1697
+
1698
+ var _useState = useState(false),
1699
+ _useState2 = _slicedToArray(_useState, 2),
1700
+ isFollowed = _useState2[0],
1701
+ setIsFollowed = _useState2[1];
1702
+
1703
+ var _useState3 = useState(undefined),
1704
+ _useState4 = _slicedToArray(_useState3, 2),
1705
+ geoJson = _useState4[0],
1706
+ setGeoJson = _useState4[1];
1707
+
1708
+ var watchIdRef = useRef(undefined);
1709
+
1710
+ var _useState5 = useState(false),
1711
+ _useState6 = _slicedToArray(_useState5, 2),
1712
+ locationAccessDenied = _useState6[0],
1713
+ setLocationAccessDenied = _useState6[1];
1714
+
1715
+ var _useState7 = useState(),
1716
+ _useState8 = _slicedToArray(_useState7, 2),
1717
+ accuracyGeoJson = _useState8[0],
1718
+ setAccuracyGeoJson = _useState8[1];
1719
+
1720
+ useEffect(function () {
1721
+ return function () {
1722
+ if (watchIdRef.current) {
1723
+ navigator.geolocation.clearWatch(watchIdRef.current);
1724
+ watchIdRef.current = undefined;
1725
+ }
1726
+ };
1727
+ }, []);
1728
+ var getLocationSuccess = useCallback(function (pos) {
1729
+ if (!mapHook.map) return;
1730
+ mapHook.map.setCenter([pos.coords.longitude, pos.coords.latitude]);
1731
+ var geoJsonPoint = point([pos.coords.longitude, pos.coords.latitude]);
1732
+ setGeoJson(geoJsonPoint);
1733
+ setAccuracyGeoJson(circle(geoJsonPoint, pos.coords.accuracy / 1000));
1734
+ }, [mapHook.map]);
1735
+
1736
+ var getLocationError = function getLocationError(err) {
1737
+ console.log("Access of user location denied");
1738
+ setLocationAccessDenied(true);
1739
+ };
1740
+
1741
+ useEffect(function () {
1742
+ if (!mapHook.map) return;
1743
+
1744
+ if (isFollowed) {
1745
+ watchIdRef.current = navigator.geolocation.watchPosition(getLocationSuccess, getLocationError);
1746
+ } else {
1747
+ navigator.geolocation.clearWatch(watchIdRef.current);
1748
+ }
1749
+ }, [isFollowed, getLocationSuccess]);
1750
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, isFollowed && geoJson && /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
1751
+ geojson: accuracyGeoJson,
1752
+ type: "fill",
1753
+ paint: _objectSpread2({
1754
+ "fill-color": "#ee7700",
1755
+ "fill-opacity": 0.5
1756
+ }, props.accuracyPaint),
1757
+ insertBeforeLayer: "MlFollowGpsMarker"
1758
+ }), isFollowed && geoJson && /*#__PURE__*/React__default.createElement(MlImageMarkerLayer, {
1759
+ layerId: "MlFollowGpsMarker",
1760
+ options: {
1761
+ type: "symbol",
1762
+ source: {
1763
+ type: "geojson",
1764
+ data: geoJson
1765
+ },
1766
+ layout: _objectSpread2({
1767
+ "icon-size": 0.1,
1768
+ "icon-offset": [0, -340]
1769
+ }, props.markerLayout)
1770
+ },
1771
+ imgSrc: props.markerImage || marker
1772
+ }), /*#__PURE__*/React__default.createElement(Button, {
1773
+ sx: _objectSpread2({
1774
+ zIndex: 1002,
1775
+ color: isFollowed ? props.onColor : props.offColor
1776
+ }, props.style),
1777
+ disabled: locationAccessDenied,
1778
+ onClick: function onClick() {
1779
+ setIsFollowed(!isFollowed);
1780
+ }
1781
+ }, " ", /*#__PURE__*/React__default.createElement(RoomIcon, {
1782
+ sx: {
1783
+ fontSize: props.style.fontSize
1784
+ }
1785
+ }), " "));
1786
+ };
1787
+
1788
+ MlFollowGps.defaultProps = {
1789
+ mapId: undefined,
1790
+ style: {
1791
+ minWidth: "30px",
1792
+ minHeight: "30px",
1793
+ width: "30px",
1794
+ height: "30px",
1795
+ backgroundColor: "#414141",
1796
+ borderRadius: "23%",
1797
+ margin: 0.15,
1798
+ fontSize: "1.3em",
1799
+ ":hover": {
1800
+ backgroundColor: "#515151",
1801
+ color: "#ececec"
1802
+ }
1803
+ },
1804
+ onColor: "#ececec",
1805
+ offColor: "#666"
1806
+ };
1807
+ MlFollowGps.propTypes = {
1808
+ /**
1809
+ * Id of the target MapLibre instance in mapContext
1810
+ */
1811
+ mapId: PropTypes.string,
1812
+
1813
+ /**
1814
+ * CSS style object that is applied to the button component
1815
+ */
1816
+ style: PropTypes.object,
1817
+
1818
+ /**
1819
+ * Active button font color
1820
+ */
1821
+ onColor: PropTypes.string,
1822
+
1823
+ /**
1824
+ * Inactive button font color
1825
+ */
1826
+ offColor: PropTypes.string,
1827
+
1828
+ /**
1829
+ * Accuracy paint property object, that is passed to the MlGeoJsonLayer responsible for drawing the accuracy circle.
1830
+ * Use any available paint prop from layer type "fill".
1831
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
1832
+ */
1833
+ accuracyPaint: PropTypes.object,
1834
+
1835
+ /**
1836
+ * Marker layout property object, that is passed to the MlImageMarkerLayer responsible for drawing the position marker.
1837
+ * Use any available layout property from layer type "symbol".
1838
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#symbol
1839
+ */
1840
+ markerLayout: PropTypes.object,
1841
+
1842
+ /**
1843
+ * Replace the default marker image with a custom one.
1844
+ */
1845
+ markerImage: PropTypes.string
1846
+ };
1847
+
1848
+ var nmMap = {
1849
+ street: ["footway", "street", "road", "street_name", "residential", "path", "pedestrian", "road_reference", "road_reference_intl", "square", "place"],
1850
+ number: ["house_number", "street_number"],
1851
+ place: ["city", "village", "hamlet", "locality", "croft", "neighbourhood", "suburb", "city_district", "district", "quarter", "borough", "city_block", "residential", "commercial", "industrial", "houses", "subdivision", "allotments", "postal_city", "town", "municipality", "local_administrative_area"],
1852
+ zip: ["postcode", "partial_postcode"],
1853
+ state: ["state", "province", "state_code"]
1854
+ };
1855
+
1856
+ var nmConverter = function nmConverter(nmAddress) {
1857
+ var addressArr = [];
1858
+
1859
+ for (var key in nmMap) {
1860
+ nmMap[key].some(function (element) {
1861
+ if (nmAddress.hasOwnProperty(element)) {
1862
+ addressArr.push(nmAddress[element]);
1863
+ return true;
1864
+ }
1865
+
1866
+ return false;
1867
+ });
1868
+ }
1869
+
1870
+ return addressArr.join(", ");
1871
+ };
1872
+
1873
+ var toPixels = function toPixels(length) {
1874
+ var conversionFactor = 96;
1875
+ conversionFactor /= 25.4;
1876
+ return conversionFactor * length + "px";
1877
+ };
1878
+
1879
+ var createPdf = function createPdf(map, locationValue, setLoading) {
1880
+ setLoading(true);
1881
+ var width = 210;
1882
+ var height = 297; // Calculate pixel ratio
1883
+
1884
+ var actualPixelRatio = window.devicePixelRatio; // Create map container
1885
+
1886
+ var hidden = document.createElement("div");
1887
+ hidden.className = "hidden-map";
1888
+ document.body.appendChild(hidden);
1889
+ var container = document.createElement("div");
1890
+ container.style.width = toPixels(width);
1891
+ container.style.height = toPixels(height);
1892
+ hidden.appendChild(container); //Render map
1893
+
1894
+ var renderMap = new maplibregl$1.Map({
1895
+ container: container,
1896
+ center: map.getCenter(),
1897
+ zoom: map.getZoom(),
1898
+ bearing: map.getBearing(),
1899
+ pitch: map.getPitch(),
1900
+ interactive: false,
1901
+ preserveDrawingBuffer: true,
1902
+ fadeDuration: 0,
1903
+ attributionControl: false
1904
+ });
1905
+ var style = map.getStyle();
1906
+
1907
+ var _loop = function _loop(name) {
1908
+ var src = style.sources[name];
1909
+ Object.keys(src).forEach(function (key) {
1910
+ //delete properties if value is undefined.
1911
+ // for instance, raster-dem might has undefined value in "url" and "bounds"
1912
+ if (!src[key]) {
1913
+ delete src[key];
1914
+ }
1915
+ });
1916
+ };
1917
+
1918
+ for (var name in style.sources) {
1919
+ _loop(name);
1920
+ }
1921
+
1922
+ renderMap.setStyle(style);
1923
+ renderMap.once("idle", function () {
1924
+ var _hidden$parentNode;
1925
+
1926
+ // TO DO: It is still under development
1927
+ var pdf = new jsPDF({
1928
+ orientation: "p",
1929
+ unit: "mm",
1930
+ compress: true
1931
+ });
1932
+ Object.defineProperty(window, "devicePixelRatio", {
1933
+ get: function get() {
1934
+ return 300 / 96;
1935
+ }
1936
+ });
1937
+ var offsetX = 2.5;
1938
+ var offsetY = 2.5;
1939
+ var marginTop = 3;
1940
+ var marginBottom = 3;
1941
+ var innerMargin =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K+YjO6wF430te3IQgg9hCDOgCbJdNH+RUIqMtxBvMybDaAPiYhiH5lDOJW2Kwfm7yBoJIqGFhX2CyJXgURCG74OQZS4YDNxrJR6RVozohKBrAHdpvEBjUj0LyUCqpbDbvdzwaTocWQUqqaB7stYr1MaJNQRDV3wG7v8DdrJGjU7SBVXA+7fcELPgyFZh2+oL/+sJmjjOd9HAYdWuXQzxWwWS+e92EodJEWeagQA5tNJ7khFHrdUk65cNgsh8wOhX4991GmFewVVs7nHTAiYil9tYO9Uuruh1F3n2GTONjr6dEwrnMevfrBXrEwwzGvig3GomXrvoP1HkQLJ6WV8II30OJ1XO0huQu/AwN3k5Vh+B1wpP3EIfhdCE2fhv+X/wF/AO+L9vuzfwAAAABJRU5ErkJggg==";
1943
+ var textBuffer = 1;
1944
+ var lineHeight = 3.25;
1945
+ var text = locationValue ? nmConverter(locationValue.address) : "";
1946
+ var textChunksSeperator = text.split(",");
1947
+ var textChunks = [];
1948
+
1949
+ if (textChunks.length) {
1950
+ textChunksSeperator.forEach(function (chunk) {
1951
+ var limitChunks = chunk.match(/.{1,34}/g);
1952
+ textChunks.push.apply(textChunks, _toConsumableArray(limitChunks));
1953
+ });
1954
+ } //Render map image
1955
+
1956
+
1957
+ pdf.addImage(renderMap.getCanvas().toDataURL("image/png"), "png", 0, 0, 210, 297, null, "FAST"); //Render lower left Copyright box
1958
+
1959
+ pdf.setFillColor("white");
1960
+ pdf.rect(138, 287, 297, 10, "F");
1961
+ pdf.setFontSize(10); // optional
1962
+
1963
+ pdf.text("Datenquelle: © OpenStreetMap-Mitwirkende", 140, pdf.internal.pageSize.height - 3); //Render infobox
1964
+
1965
+ pdf.setFillColor("white");
1966
+ var infoBoxSize = textChunks.length * lineHeight + marginTop + marginBottom + lineHeight * 2 + innerMargin * 2 + textBuffer;
1967
+ pdf.rect(offsetX, 2, 66.5, infoBoxSize, "F");
1968
+ pdf.setFontSize(10);
1969
+ pdf.text("Karten PDF:", 6, offsetY + marginTop); //Render inner infobox
1970
+
1971
+ pdf.rect(6, 7, 60, textChunks.length * lineHeight + innerMargin * 2 + textBuffer);
1972
+ pdf.setFontSize(10); //Write out address
1973
+
1974
+ textChunks.forEach(function (text, i) {
1975
+ pdf.text(text.trim(), 8, 10 + i * 3.5 + innerMargin);
1976
+ }); //Add WG Logo
1977
+
1978
+ pdf.addImage(logo, "png", 5, offsetY + marginTop + lineHeight * 2 + textChunks.length * 3 + innerMargin * 2, 3, 3, null, "FAST"); //Add WG Url
1979
+
1980
+ pdf.setFontSize(10);
1981
+ pdf.text("wheregroup.com", 40, offsetY + marginTop + lineHeight * 2 + textChunks.length * lineHeight + innerMargin * 2 + textBuffer); //Set pdfs props
1982
+
1983
+ pdf.setProperties({
1984
+ title: "Map export",
1985
+ subject: "Map export",
1986
+ creator: "WhereGroup GmbH",
1987
+ author: "(c)WhereGroup GmbH, (c)OpenStreetMap"
1988
+ });
1989
+ pdf.save("Map.pdf");
1990
+ renderMap.remove();
1991
+ (_hidden$parentNode = hidden.parentNode) === null || _hidden$parentNode === void 0 ? void 0 : _hidden$parentNode.removeChild(hidden);
1992
+ Object.defineProperty(window, "devicePixelRatio", {
1993
+ get: function get() {
1994
+ return actualPixelRatio;
1995
+ }
1996
+ });
1997
+ setLoading(false);
1998
+ });
1999
+ };
2000
+
2001
+ /**
2002
+ * Renders a button that will create a PDF version of the current map view (dimensions adjusted to fit Din A4 Paper).
2003
+ *
2004
+ * @component
2005
+ */
2006
+
2007
+ var MlCreatePdfButton = function MlCreatePdfButton(props) {
2008
+ var mapContext = useContext(MapContext);
2009
+ var initializedRef = useRef(false);
2010
+ var mapRef = useRef(undefined);
2011
+ useEffect(function () {
2012
+ if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
2013
+ initializedRef.current = true;
2014
+ mapRef.current = mapContext.getMap(props.mapId);
2015
+ }, [mapContext.mapIds, mapContext, props.mapId]);
2016
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(Button, {
2017
+ color: "primary",
2018
+ variant: "contained",
2019
+ onClick: function onClick() {
2020
+ createPdf(mapRef.current, null, function () {});
2021
+ }
2022
+ }, /*#__PURE__*/React__default.createElement(PrinterIcon, null)));
2023
+ };
2024
+
2025
+ MlCreatePdfButton.defaultProps = {
2026
+ mapId: undefined
2027
+ };
2028
+ MlCreatePdfButton.propTypes = {
2029
+ /**
2030
+ * Id of the target MapLibre instance in mapContext
2031
+ */
2032
+ mapId: PropTypes.string
2033
+ };
2034
+
2035
+ function _extends() { _extends = 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.apply(this, arguments); }
2036
+
2037
+ function SvgRotateRight(props) {
2038
+ return /*#__PURE__*/createElement("svg", _extends({
2039
+ width: "39.675098mm",
2040
+ height: "104.27064mm",
2041
+ viewBox: "0 0 39.675098 104.27064"
2042
+ }, props), /*#__PURE__*/createElement("g", {
2043
+ transform: "translate(-86.019554,-58.032633)"
2044
+ }, /*#__PURE__*/createElement("path", {
2045
+ style: {
2046
+ strokeWidth: 0.744756
1671
2047
  },
1672
2048
  d: "m 442.74023,219.33594 -117.62695,32.32422 54.71094,31.12304 c -21.99397,41.5931 -32.8507,84.88283 -38.33008,127.89649 -6.86182,50.94051 -5.95715,103.99765 20.23828,155.46484 5.97246,11.72776 13.65817,23.59773 24.38867,35.06641 2.6597,2.84073 5.65602,5.75455 9.12891,8.68164 0.87557,0.7378 1.85363,1.52609 2.95117,2.35547 0.29669,0.22563 0.63616,0.47742 1.02149,0.75586 l 0.58203,0.42578 34.57812,-15.12305 -0.33789,-0.2207 c -0.0265,-0.0151 -0.0842,-0.0587 -0.18359,-0.13086 -0.46723,-0.34885 -0.9819,-0.76796 -1.56055,-1.25 -2.29757,-1.91343 -4.46539,-4.04643 -6.64062,-6.33985 -8.80052,-9.27114 -15.30333,-19.4993 -20.83985,-30.13867 -24.42289,-46.90715 -24.77465,-97.03535 -18.58008,-146.68164 4.94388,-37.37493 13.65299,-74.4847 30.20508,-109.92969 l 58.6211,33.34766 z",
1673
2049
  transform: "scale(0.26458333)"
@@ -1830,233 +2206,77 @@ var MlNavigationCompass = function MlNavigationCompass(props) {
1830
2206
 
1831
2207
  if (rest === 0) {
1832
2208
  rest = 90;
1833
- }
1834
-
1835
- (_mapRef$current2 = mapRef.current) === null || _mapRef$current2 === void 0 ? void 0 : _mapRef$current2.setBearing(Math.round(bearing + Math.abs(rest)));
1836
- }
1837
- })), /*#__PURE__*/React__default.createElement(NeedleButton, {
1838
- className: /*#__PURE__*/css(_objectSpread2({}, props.needleStyle), process.env.NODE_ENV === "production" ? "" : ";label:MlNavigationCompass;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBeUt1QiIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IHVzZVN0YXRlLCB1c2VSZWYsIHVzZUVmZmVjdCwgdXNlQ29udGV4dCB9IGZyb20gXCJyZWFjdFwiO1xuaW1wb3J0IFByb3BUeXBlcyBmcm9tIFwicHJvcC10eXBlc1wiO1xuXG5pbXBvcnQgeyBNYXBDb250ZXh0IH0gZnJvbSBcIkBtYXBjb21wb25lbnRzL3JlYWN0LWNvcmVcIjtcbmltcG9ydCB7IHY0IGFzIHV1aWR2NCB9IGZyb20gXCJ1dWlkXCI7XG5cbmltcG9ydCB7IFJlYWN0Q29tcG9uZW50IGFzIFJvdGF0ZVJpZ2h0SWNvbiB9IGZyb20gXCIuL2Fzc2V0cy9yb3RhdGVfcmlnaHQuc3ZnXCI7XG5pbXBvcnQgeyBSZWFjdENvbXBvbmVudCBhcyBS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ZGl2XG4gICAgICAgICAgY2xhc3NOYW1lPXtjc3Moe1xuICAgICAgICAgICAgcG9zaXRpb246IFwiYWJzb2x1dGVcIixcbiAgICAgICAgICAgIGJvcmRlcjogXCIxMHB4IHNvbGlkICNiY2JjYmNcIixcbiAgICAgICAgICAgIGJhY2tncm91bmRDb2xvcjogXCIjNzE3MTcxXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kOiBcInJhZGlhbC1ncmFkaWVudCgjNzE3MTcxLCAjNDE0MTQxKVwiLFxuICAgICAgICAgICAgaGVpZ2h0OiBcIjIwMHB4XCIsXG4gICAgICAgICAgICB3aWR0aDogXCIyMDBweFwiLFxuICAgICAgICAgICAgYm9yZGVyUmFkaXVzOiBcIjUwJVwiLFxuICAgICAgICAgICAgZGlzcGxheTogXCJmbGV4XCIsXG4gICAgICAgICAgICBqdXN0aWZ5Q29udGVudDogXCJjZW50ZXJcIixcbiAgICAgICAgICAgIHRyYW5zZm9ybTogXCJzY2FsZSgwLjIpIHRyYW5zbGF0ZVgoLTQ0OHB4KSB0cmFuc2xhdGVZKC00NDhweClcIixcbiAgICAgICAgICAgIC4uLnByb3BzLmJhY2tncm91bmRTdHlsZSxcbiAgICAgICAgICB9KX1cbiAgICAgICAgPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVSaWdodFN0eWxlIH0pfT5cbiAgICAgICAgICAgIDxSb3RhdGVSaWdodEljb25cbiAgICAgICAgICAgICAgb25DbGljaz17KCkgPT4ge1xuICAgICAgICAgICAgICAgIGxldCBiZWFyaW5nID0gTWF0aC5yb3VuZChtYXBSZWYuY3VycmVudD8uZ2V0QmVhcmluZygpKTtcbiAgICAgICAgICAgICAgICBsZXQgcmVzdCA9IE1hdGgucm91bmQoYmVhcmluZyAlIDkwKTtcbiAgICAgICAgICAgICAgICBpZiAoYmVhcmluZyA+IDApIHtcbiAgICAgICAgICAgICAgICAgIHJlc3QgPSA5MCAtIHJlc3Q7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChyZXN0ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIG1hcFJlZi5jdXJyZW50Py5zZXRCZWFyaW5nKE1hdGgucm91bmQoYmVhcmluZyArIE1hdGguYWJzKHJlc3QpKSk7XG4gICAgICAgICAgICAgIH19XG4gICAgICAgICAgICA+PC9Sb3RhdGVSaWdodEljb24+XG4gICAgICAgICAgPC9Sb3RhdGVCdXR0b24+XG4gICAgICAgICAgPE5lZWRsZUJ1dHRvblxuICAgICAgICAgICAgY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5uZWVkbGVTdHlsZSB9KX1cbiAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgbWFwUmVmLmN1cnJlbnQ/LnNldEJlYXJpbmcoMCk7XG4gICAgICAgICAgICB9fVxuICAgICAgICAgID5cbiAgICAgICAgICAgIDxOZWVkbGVDb250YWluZXJcbiAgICAgICAgICAgICAgc3R5bGU9e3tcbiAgICAgICAgICAgICAgICB0cmFuc2Zvcm06IFwicm90YXRlKFwiICsgYmVhcmluZyArIFwiZGVnKVwiLFxuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPlxuICAgICAgICAgICAgICA8TmVlZGxlSWNvbiAvPlxuICAgICAgICAgICAgPC9OZWVkbGVDb250YWluZXI+XG4gICAgICAgICAgPC9OZWVkbGVCdXR0b24+XG4gICAgICAgICAgPFJvdGF0ZUJ1dHRvbiBjbGFzc05hbWU9e2Nzcyh7IC4uLnByb3BzLnJvdGF0ZUxlZnRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlTGVmdEljb25cbiAgICAgICAgICAgICAgb25DbGljaz17KCkgPT4ge1xuICAgICAgICAgICAgICAgIGxldCBiZWFyaW5nID0gTWF0aC5y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GRlZmluaXRpb25zIG9mIHRoZSBjb21wYXNzIG5lZWRsZS5cbiAgICovXG4gIG5lZWRsZVN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIHJvdGF0ZSByaWdodCBidXR0b24uXG4gICAqL1xuICByb3RhdGVSaWdodFN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIHJvdGF0ZSBsZWZ0IGJ1dHRvbi5cbiAgICovXG4gIHJvdGF0ZUxlZnRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbn07XG5cbmV4cG9ydCBkZWZhdWx0IE1sTmF2aWdhdGlvbkNvbXBhc3M7XG4iXX0= */"),
1839
- onClick: function onClick() {
1840
- var _mapRef$current3;
1841
-
1842
- (_mapRef$current3 = mapRef.current) === null || _mapRef$current3 === void 0 ? void 0 : _mapRef$current3.setBearing(0);
1843
- }
1844
- }, /*#__PURE__*/React__default.createElement(NeedleContainer, {
1845
- style: {
1846
- transform: "rotate(" + bearing + "deg)"
1847
- }
1848
- }, /*#__PURE__*/React__default.createElement(SvgNeedle, null))), /*#__PURE__*/React__default.createElement(RotateButton, {
1849
- className: /*#__PURE__*/css(_objectSpread2({}, props.rotateLeftStyle), process.env.NODE_ENV === "production" ? "" : ";label:MlNavigationCompass;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBc0xtQyIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0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AgICBjb21wb25lbnRJZC5jdXJyZW50XG4gICAgKTtcbiAgICBzZXRCZWFyaW5nKE1hdGgucm91bmQobWFwUmVmLmN1cnJlbnQuZ2V0QmVhcmluZygpKSk7XG4gIH0sIFttYXBDb250ZXh0Lm1hcElkcywgbWFwQ29udGV4dCwgcHJvcHMubWFwSWRdKTtcblxuICByZXR1cm4gKFxuICAgIDw+XG4gICAgICA8ZGl2XG4gICAgICAgIGNsYXNzTmFtZT17Y3NzKHtcbiAgICAgICAgICB6SW5kZXg6IDEwMDAsXG4gICAgICAgICAgdG9wOiAwLFxuICAgICAgICAgIHBvc2l0aW9uOiBcImFic29sdXRlXCIsXG4gICAgICAgICAgLi4ucHJvcHMuc3R5bGUsXG4gICAgICAgIH0pfVxuICAgICAgPlxuICAgICAgICA8ZGl2XG4gICAgICAgICAgY2xhc3NOYW1lPXtjc3Moe1xuICAgICAgICAgICAgcG9zaXRpb246IFwiYWJzb2x1dGVcIixcbiAgICAgICAgICAgIGJvcmRlcjogXCIxMHB4IHNvbGlkICNiY2JjYmNcIixcbiAgICAgICAgICAgIGJhY2tncm91bmRDb2xvcjogXCIjNzE3MTcxXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kOiBcInJhZGlhbC1ncmFkaWVudCgjNzE3MTcxLCAjNDE0MTQxKVwiLFxuICAgICAgICAgICAgaGVpZ2h0OiBcIjIwMHB4XCIsXG4gICAgICAgICAgICB3aWR0aDogXCIyMDBweFwiLFxuICAgICAgICAgICAgYm9yZGVyUmFkaXVzOiBcIjUwJVwiLFxuICAgICAgICAgICAgZGlzcGxheTogXCJmbGV4XCIsXG4gICAgICAgICAgICBqdXN0aWZ5Q29udGVudDogXCJjZW50ZXJcIixcbiAgICAgICAgICAgIHRyYW5zZm9ybTogXCJzY2FsZSgwLjIpIHRyYW5zbGF0ZVgoLTQ0OHB4KSB0cmFuc2xhdGVZKC00NDhweClcIixcbiAgICAgICAgICAgIC4uLnByb3BzLmJhY2tncm91bmRTdHlsZSxcbiAgICAgICAgICB9KX1cbiAgICAgICAgPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVSaWdodFN0eWxlIH0pfT5cbiAgICAgICAgICAgIDxSb3RhdGVSaWdodEljb25cbiAgICAgICAgICAgICAgb25DbGljaz17KCkgPT4ge1xuICAgICAgICAgICAgICAgIGxldCBiZWFyaW5nID0gTWF0aC5yb3VuZChtYXBSZWYuY3VycmVudD8uZ2V0QmVhcmluZygpKTtcbiAgICAgICAgICAgICAgICBsZXQgcmVzdCA9IE1hdGgucm91bmQoYmVhcmluZyAlIDkwKTtcbiAgICAgICAgICAgICAgICBpZiAoYmVhcmluZyA+IDApIHtcbiAgICAgICAgICAgICAgICAgIHJlc3QgPSA5MCAtIHJlc3Q7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChyZXN0ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIG1hcFJlZi5jdXJyZW50Py5zZXRCZWFyaW5nKE1hdGgucm91bmQoYmVhcmluZyArIE1hdGguYWJzKHJlc3QpKSk7XG4gICAgICAgICAgICAgIH19XG4gICAgICAgICAgICA+PC9Sb3RhdGVSaWdodEljb24+XG4gICAgICAgICAgPC9Sb3RhdGVCdXR0b24+XG4gICAgICAgICAgPE5lZWRsZUJ1dHRvblxuICAgICAgICAgICAgY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5uZWVkbGVTdHlsZSB9KX1cbiAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgbWFwUmVmLmN1cnJlbnQ/LnNldEJlYXJpbmcoMCk7XG4gICAgICAgICAgICB9fVxuICAgICAgICAgID5cbiAgICAgICAgICAgIDxOZWVkbGVDb250YWluZXJcbiAgICAgICAgICAgICAgc3R5bGU9e3tcbiAgICAgICAgICAgICAgICB0cmFuc2Zvcm06IFwicm90YXRlKFwiICsgYmVhcmluZyArIFwiZGVnKVwiLFxuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPlxuICAgICAgICAgICAgICA8TmVlZGxlSWNvbiAvPlxuICAgICAgICAgICAgPC9OZWVkbGVDb250YWluZXI+XG4gICAgICAgICAgPC9OZWVkbGVCdXR0b24+XG4gICAgICAgICAgPFJvdGF0ZUJ1dHRvbiBjbGFzc05hbWU9e2Nzcyh7IC4uLnByb3BzLnJvdGF0ZUxlZnRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlTGVmdEljb25cbiAgICAgICAgICAgICAgb25DbGljaz17KCkgPT4ge1xuICAgICAgICAgICAgICAgIGxldCBiZWFyaW5nID0gTWF0aC5yb3VuZChtYXBSZWYuY3VycmVudD8uZ2V0QmVhcmluZygpKTtcbiAgICAgICAgICAgICAgICBsZXQgcmVzdCA9IE1hdGgucm91bmQoYmVhcmluZyAlIDkwKTtcbiAgICAgICAgICAgICAgICBpZiAoYmVhcmluZyA8IDApIHtcbiAgICAgICAgICAgICAgICAgIHJlc3QgPSA5MCArIHJlc3Q7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChyZXN0ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIG1hcFJlZi5jdXJyZW50Py5zZXRCZWFyaW5nKE1hdGgucm91bmQoYmVhcmluZyAtIE1hdGguYWJzKHJlc3QpKSk7XG4gICAgICAgICAgICAgIH19XG4gICAgICAgICAgICA+PC9Sb3RhdGVMZWZ0SWNvbj5cbiAgICAgICAgICA8L1JvdGF0ZUJ1dHRvbj5cbiAgICAgICAgPC9kaXY+XG4gICAgICA8L2Rpdj5cbiAgICA8Lz5cbiAgKTtcbn07XG5cbk1sTmF2aWdhdGlvbkNvbXBhc3MucHJvcFR5cGVzID0ge1xuICAvKipcbiAgICogQ29tcG9uZW50IGlkIHByZWZpeFxuICAgKi9cbiAgaWRQcmVmaXg6IFByb3BUeXBlcy5zdHJpbmcsXG4gIC8qKlxuICAgKiBTdHlsZSBvYmplY3QgdG8gYWRqdXN0IGNzcyBkZWZpbml0aW9ucyBvZiB0aGUgY29tcG9uZW50LlxuICAgKi9cbiAgc3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG4gIC8qKlxuICAgKiBTdHlsZSBvYmplY3QgdG8gYWRqdXN0IGNzcyBkZWZpbml0aW9ucyBvZiB0aGUgYmFja2dyb3VuZC5cbiAgICovXG4gIGJhY2tncm91bmRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSBjb21wYXNzIG5lZWRsZS5cbiAgICovXG4gIG5lZWRsZVN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIHJvdGF0ZSByaWdodCBidXR0b24uXG4gICAqL1xuICByb3RhdGVSaWdodFN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIHJvdGF0ZSBsZWZ0IGJ1dHRvbi5cbiAgICovXG4gIHJvdGF0ZUxlZnRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbn07XG5cbmV4cG9ydCBkZWZhdWx0IE1sTmF2aWdhdGlvbkNvbXBhc3M7XG4iXX0= */")
1850
- }, /*#__PURE__*/React__default.createElement(SvgRotateLeft, {
1851
- onClick: function onClick() {
1852
- var _mapRef$current4, _mapRef$current5;
1853
-
1854
- var bearing = Math.round((_mapRef$current4 = mapRef.current) === null || _mapRef$current4 === void 0 ? void 0 : _mapRef$current4.getBearing());
1855
- var rest = Math.round(bearing % 90);
1856
-
1857
- if (bearing < 0) {
1858
- rest = 90 + rest;
1859
- }
1860
-
1861
- if (rest === 0) {
1862
- rest = 90;
1863
- }
1864
-
1865
- (_mapRef$current5 = mapRef.current) === null || _mapRef$current5 === void 0 ? void 0 : _mapRef$current5.setBearing(Math.round(bearing - Math.abs(rest)));
1866
- }
1867
- })))));
1868
- };
1869
-
1870
- MlNavigationCompass.propTypes = {
1871
- /**
1872
- * Component id prefix
1873
- */
1874
- idPrefix: PropTypes.string,
1875
-
1876
- /**
1877
- * Style object to adjust css definitions of the component.
1878
- */
1879
- style: PropTypes.object,
1880
-
1881
- /**
1882
- * Style object to adjust css definitions of the background.
1883
- */
1884
- backgroundStyle: PropTypes.object,
1885
-
1886
- /**
1887
- * Style object to adjust css definitions of the compass needle.
1888
- */
1889
- needleStyle: PropTypes.object,
1890
-
1891
- /**
1892
- * Style object to adjust css definitions of the rotate right button.
1893
- */
1894
- rotateRightStyle: PropTypes.object,
1895
-
1896
- /**
1897
- * Style object to adjust css definitions of the rotate left button.
1898
- */
1899
- rotateLeftStyle: PropTypes.object
1900
- };
1901
-
1902
- var marker = "b556faa3bc6829d2.png";
1903
-
1904
- /**
1905
- * Adds a button that makes the map follow the users GPS position using
1906
- * navigator.geolocation.watchPosition if activated
1907
- *
1908
- * @param {object} props
1909
- * @param {string} props.mapId Id of the target MapLibre instance in mapContext
1910
- *
1911
- * @component
1912
- */
1913
-
1914
- var MlFollowGps = function MlFollowGps(props) {
1915
- // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
1916
- var mapContext = useContext(MapContext);
1917
-
1918
- var _useState = useState(false),
1919
- _useState2 = _slicedToArray(_useState, 2),
1920
- isFollowed = _useState2[0],
1921
- setIsFollowed = _useState2[1];
1922
-
1923
- var _useState3 = useState(undefined),
1924
- _useState4 = _slicedToArray(_useState3, 2),
1925
- geoJson = _useState4[0],
1926
- setGeoJson = _useState4[1];
1927
-
1928
- var watchIdRef = useRef(undefined);
1929
-
1930
- var _useState5 = useState(false),
1931
- _useState6 = _slicedToArray(_useState5, 2),
1932
- locationAccessDenied = _useState6[0],
1933
- setLocationAccessDenied = _useState6[1];
1934
-
1935
- var initializedRef = useRef(false);
1936
- var mapRef = useRef(undefined);
1937
- var componentId = useRef((props.idPrefix ? props.idPrefix : "MlFollowGps-") + v4());
1938
-
1939
- var _useState7 = useState(30),
1940
- _useState8 = _slicedToArray(_useState7, 2),
1941
- accuracyRadius = _useState8[0],
1942
- setAccuracyRadius = _useState8[1];
1943
-
1944
- useEffect(function () {
1945
- var _componentId = componentId.current;
1946
- return function () {
1947
- // This is the cleanup function, it is called when this react component is removed from react-dom
1948
- // try to remove anything this component has added to the MapLibre-gl instance
1949
- // e.g.: remove the layer
1950
- // mapContext.getMap(props.mapId).removeLayer(layerRef.current);
1951
- // check for the existence of map.style before calling getLayer or getSource
1952
- if (mapRef.current) {
1953
- mapRef.current.cleanup(_componentId);
1954
- mapRef.current = undefined;
1955
- }
1956
-
1957
- if (watchIdRef.current) {
1958
- initializedRef.current = false;
1959
- navigator.geolocation.clearWatch(watchIdRef.current);
1960
- watchIdRef.current = undefined;
1961
- }
1962
- };
1963
- }, []);
1964
- useEffect(function () {
1965
- if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
1966
- // initialize the layer and add it to the MapLibre-gl instance or do something else with it
1967
-
1968
- initializedRef.current = true;
1969
- mapRef.current = mapContext.getMap(props.mapId);
1970
- mapRef.current.setCenter([7.132122000552613, 50.716405378037706]);
1971
- }, [mapContext.mapIds, mapContext, props.mapId]);
1972
-
1973
- var getLocationSuccess = function getLocationSuccess(pos) {
1974
- if (!mapRef.current) return;
1975
- mapRef.current.setCenter([pos.coords.longitude, pos.coords.latitude]);
1976
- setAccuracyRadius(pos.coords.accuracy);
1977
- setGeoJson(point([pos.coords.longitude, pos.coords.latitude]));
1978
- };
1979
-
1980
- var getLocationError = function getLocationError(err) {
1981
- console.log("Access of user location denied");
1982
- setLocationAccessDenied(true);
1983
- };
2209
+ }
1984
2210
 
1985
- return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, isFollowed && geoJson && /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
1986
- geojson: geoJson,
1987
- type: "circle",
1988
- paint: {
1989
- "circle-radius": {
1990
- stops: [[0, 0], [20, accuracyRadius / 0.075 / Math.cos(geoJson.geometry.coordinates[1] * Math.PI / 180)]],
1991
- base: 2
1992
- },
1993
- "circle-color": "#ee7700",
1994
- "circle-opacity": 0.5
2211
+ (_mapRef$current2 = mapRef.current) === null || _mapRef$current2 === void 0 ? void 0 : _mapRef$current2.setBearing(Math.round(bearing + Math.abs(rest)));
1995
2212
  }
1996
- }), isFollowed && geoJson && /*#__PURE__*/React__default.createElement(MlImageMarkerLayer, {
1997
- options: {
1998
- type: "symbol",
1999
- source: {
2000
- type: "geojson",
2001
- data: geoJson
2002
- },
2003
- layout: {
2004
- "icon-size": 0.1,
2005
- "icon-offset": [0, -340]
2006
- }
2007
- },
2008
- imgSrc: marker
2009
- }), /*#__PURE__*/React__default.createElement(Button, {
2010
- sx: _objectSpread2({
2011
- zIndex: 1002,
2012
- color: isFollowed ? "#bbb" : "#666"
2013
- }, props.style),
2014
- disabled: locationAccessDenied,
2213
+ })), /*#__PURE__*/React__default.createElement(NeedleButton, {
2214
+ className: /*#__PURE__*/css(_objectSpread2({}, props.needleStyle), process.env.NODE_ENV === "production" ? "" : ";label:MlNavigationCompass;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBeUt1QiIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IF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sXG4gICAgICBjb21wb25lbnRJZC5jdXJyZW50XG4gICAgKTtcbiAgICBzZXRCZWFyaW5nKE1hdGgucm91bmQobWFwUmVmLmN1cnJlbnQuZ2V0QmVhcmluZygpKSk7XG4gIH0sIFttYXBDb250ZXh0Lm1hcElkcywgbWFwQ29udGV4dCwgcHJvcHMubWFwSWRdKTtcblxuICByZXR1cm4gKFxuICAgIDw+XG4gICAgICA8ZGl2XG4gICAgICAgIGNsYXNzTmFtZT17Y3NzKHtcbiAgICAgICAgICB6SW5kZXg6IDEwMDAsXG4gICAgICAgICAgdG9wOiAwLFxuICAgICAgICAgIHBvc2l0aW9uOiBcImFic29sdXRlXCIsXG4gICAgICAgICAgLi4ucHJvcHMuc3R5bGUsXG4gICAgICAgIH0pfVxuICAgICAgPlxuICAgICAgICA8ZGl2XG4gICAgICAgICAgY2xhc3NOYW1lPXtjc3Moe1xuICAgICAgICAgICAgcG9zaXRpb246IFwiYWJzb2x1dGVcIixcbiAgICAgICAgICAgIGJvcmRlcjogXCIxMHB4IHNvbGlkICNiY2JjYmNcIixcbiAgICAgICAgICAgIGJhY2tncm91bmRDb2xvcjogXCIjNzE3MTcxXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kOiBcInJhZGlhbC1ncmFkaWVudCgjNzE3MTcxLCAjNDE0MTQxKVwiLFxuICAgICAgICAgICAgaGVpZ2h0OiBcIjIwMHB4XCIsXG4gICAgICAgICAgICB3aWR0aDogXCIyMDBweFwiLFxuICAgICAgICAgICAgYm9yZGVyUmFkaXVzOiBcIjUwJVwiLFxuICAgICAgICAgICAgZGlzcGxheTogXCJmbGV4XCIsXG4gICAgICAgICAgICBqdXN0aWZ5Q29udGVudDogXCJjZW50ZXJcIixcbiAgICAgICAgICAgIHRyYW5zZm9ybTogXCJzY2FsZSgwLjIpIHRyYW5zbGF0ZVgoLTQ0OHB4KSB0cmFuc2xhdGVZKC00NDhweClcIixcbiAgICAgICAgICAgIC4uLnByb3BzLmJhY2tncm91bmRTdHlsZSxcbiAgICAgICAgICB9KX1cbiAgICAgICAgPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVSaWdodFN0eWxlIH0pfT5cbiAgICAgICAgICAgIDxSb3RhdGVSaWdodEljb25cbiAgICAgICAgICAgICAgb25DbGljaz17KCkgPT4ge1xuICAgICAgICAgICAgICAgIGxldCBiZWFyaW5nID0gTWF0aC5yb3VuZChtYXBSZWYuY3VycmVudD8uZ2V0QmVhcmluZygpKTtcbiAgICAgICAgICAgICAgICBsZXQgcmVzdCA9IE1hdGgucm91bmQoYmVhcmluZyAlIDkwKTtcbiAgICAgICAgICAgICAgICBpZiAoYmVhcmluZyA+IDApIHtcbiAgICAgICAgICAgICAgICAgIHJlc3QgPSA5MCAtIHJlc3Q7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChyZXN0ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIG1hcFJlZi5jdXJyZW50Py5zZXRCZWFyaW5nKE1hdGgucm91bmQoYmVhcmluZyArIE1hdGguYWJzKHJlc3QpKSk7XG4gICAgICAgICAgICAgIH19XG4gICAgICAgICAgICA+PC9Sb3RhdGVSaWdodEljb24+XG4gICAgICAgICAgPC9Sb3RhdGVCdXR0b24+XG4gICAgICAgICAgPE5lZWRsZUJ1dHRvblxuICAgICAgICAgICAgY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5uZWVkbGVTdHlsZSB9KX1cbiAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgbWFwUmVmLmN1cnJlbnQ/LnNldEJlYXJpbmcoMCk7XG4gICAgICAgICAgICB9fVxuICAgICAgICAgID5cbiAgICAgICAgICAgIDxOZWVkbGVDb250YWluZXJcbiAgICAgICAgICAgICAgc3R5bGU9e3tcbiAgICAgICAgICAgICAgICB0cmFuc2Zvcm06IFwicm90YXRlKFwiICsgYmVhcmluZyArIFwiZGVnKVwiLFxuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPlxuICAgICAgICAgICAgICA8TmVlZGxlSWNvbiAvPlxuICAgICAgICAgICAgPC9OZWVkbGVDb250YWluZXI+XG4gICAgICAgICAgPC9OZWVkbGVCdXR0b24+XG4gICAgICAgICAgPFJvdGF0ZUJ1dHRvbiBjbGFzc05hbWU9e2Nzcyh7IC4uLnByb3BzLnJvdGF0ZUxlZnRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlTGVmdEljb25cbiAgICAgICAgICAgICAgb25DbGljaz17KCkgPT4ge1xuICAgICAgICAgICAgICAgIGxldCBiZWFyaW5nID0gTWF0aC5yb3VuZChtYXBSZWYuY3VycmVudD8uZ2V0QmVhcmluZygpKTtcbiAgICAgICAgICAgICAgICBsZXQgcmVzdCA9IE1hdGgucm91bmQoYmVhcmluZyAlIDkwKTtcbiAgICAgICAgICAgICAgICBpZiAoYmVhcmluZyA8IDApIHtcbiAgICAgICAgICAgICAgICAgIHJlc3QgPSA5MCArIHJlc3Q7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChyZXN0ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIG1hcFJlZi5jdXJyZW50Py5zZXRCZWFyaW5nKE1hdGgucm91bmQoYmVhcmluZyAtIE1hdGguYWJzKHJlc3QpKSk7XG4gICAgICAgICAgICAgIH19XG4gICAgICAgICAgICA+PC9Sb3RhdGVMZWZ0SWNvbj5cbiAgICAgICAgICA8L1JvdGF0ZUJ1dHRvbj5cbiAgICAgICAgPC9kaXY+XG4gICAgICA8L2Rpdj5cbiAgICA8Lz5cbiAgKTtcbn07XG5cbk1sTmF2aWdhdGlvbkNvbXBhc3MucHJvcFR5cGVzID0ge1xuICAvKipcbiAgICogQ29tcG9uZW50IGlkIHByZWZpeFxuICAgKi9cbiAgaWRQcmVmaXg6IFByb3BUeXBlcy5zdHJpbmcsXG4gIC8qKlxuICAgKiBTdHlsZSBvYmplY3QgdG8gYWRqdXN0IGNzcyBkZWZpbml0aW9ucyBvZiB0aGUgY29tcG9uZW50LlxuICAgKi9cbiAgc3R5bGU6IFByb3BUeXBlcy5vYmplY3QsXG4gIC8qKlxuICAgKiBTdHlsZSBvYmplY3QgdG8gYWRqdXN0IGNzcyBkZWZpbml0aW9ucyBvZiB0aGUgYmFja2dyb3VuZC5cbiAgICovXG4gIGJhY2tncm91bmRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbiAgLyoqXG4gICAqIFN0eWxlIG9iamVjdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSBjb21wYXNzIG5lZWRsZS5cbiAgICovXG4gIG5lZWRsZVN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIHJvdGF0ZSByaWdodCBidXR0b24uXG4gICAqL1xuICByb3RhdGVSaWdodFN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIHJvdGF0ZSBsZWZ0IGJ1dHRvbi5cbiAgICovXG4gIHJvdGF0ZUxlZnRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbn07XG5cbmV4cG9ydCBkZWZhdWx0IE1sTmF2aWdhdGlvbkNvbXBhc3M7XG4iXX0= */"),
2015
2215
  onClick: function onClick() {
2016
- if (isFollowed) {
2017
- navigator.geolocation.clearWatch(watchIdRef.current);
2018
- } else {
2019
- watchIdRef.current = navigator.geolocation.watchPosition(getLocationSuccess, getLocationError);
2020
- }
2216
+ var _mapRef$current3;
2021
2217
 
2022
- setIsFollowed(!isFollowed);
2218
+ (_mapRef$current3 = mapRef.current) === null || _mapRef$current3 === void 0 ? void 0 : _mapRef$current3.setBearing(0);
2023
2219
  }
2024
- }, " ", /*#__PURE__*/React__default.createElement(RoomIcon, {
2025
- sx: {
2026
- fontSize: props.style.fontSize
2220
+ }, /*#__PURE__*/React__default.createElement(NeedleContainer, {
2221
+ style: {
2222
+ transform: "rotate(" + bearing + "deg)"
2027
2223
  }
2028
- }), " "));
2029
- };
2224
+ }, /*#__PURE__*/React__default.createElement(SvgNeedle, null))), /*#__PURE__*/React__default.createElement(RotateButton, {
2225
+ className: /*#__PURE__*/css(_objectSpread2({}, props.rotateLeftStyle), process.env.NODE_ENV === "production" ? "" : ";label:MlNavigationCompass;", process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIk1sTmF2aWdhdGlvbkNvbXBhc3MuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBc0xtQyIsImZpbGUiOiJNbE5hdmlnYXRpb25Db21wYXNzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFJlYWN0LCB7IHVzZVN0YXRlLCB1c2VSZWYsIHVzZUVmZmVjdCwgdXNlQ29udGV4dCB9IGZyb20gXCJyZWFjdFwiO1xuaW1wb3J0IFByb3BUeXBlcyBmcm9tIFwicHJvcC10eXBlc1wiO1xuXG5pbXBvcnQgeyBNYXBDb250ZXh0IH0gZnJvbSBcIkBtYXBjb21wb25lbnRzL3JlYWN0LWNvcmVcIjtcbmltcG9ydCB7IHY0IGFzIHV1aWR2NCB9IGZyb20gXCJ1dWlkXCI7XG5cbmltcG9ydCB7IFJlYWN0Q29tcG9uZW50IGFzIFJvdGF0ZVJpZ2h0SWNvbiB9IGZyb20gXCIuL2Fzc2V0cy9yb3RhdGVfcmlnaHQuc3ZnXCI7XG5pbXBvcnQgeyBSZ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xuICAgICAgPlxuICAgICAgICA8ZGl2XG4gICAgICAgICAgY2xhc3NOYW1lPXtjc3Moe1xuICAgICAgICAgICAgcG9zaXRpb246IFwiYWJzb2x1dGVcIixcbiAgICAgICAgICAgIGJvcmRlcjogXCIxMHB4IHNvbGlkICNiY2JjYmNcIixcbiAgICAgICAgICAgIGJhY2tncm91bmRDb2xvcjogXCIjNzE3MTcxXCIsXG4gICAgICAgICAgICBiYWNrZ3JvdW5kOiBcInJhZGlhbC1ncmFkaWVudCgjNzE3MTcxLCAjNDE0MTQxKVwiLFxuICAgICAgICAgICAgaGVpZ2h0OiBcIjIwMHB4XCIsXG4gICAgICAgICAgICB3aWR0aDogXCIyMDBweFwiLFxuICAgICAgICAgICAgYm9yZGVyUmFkaXVzOiBcIjUwJVwiLFxuICAgICAgICAgICAgZGlzcGxheTogXCJmbGV4XCIsXG4gICAgICAgICAgICBqdXN0aWZ5Q29udGVudDogXCJjZW50ZXJcIixcbiAgICAgICAgICAgIHRyYW5zZm9ybTogXCJzY2FsZSgwLjIpIHRyYW5zbGF0ZVgoLTQ0OHB4KSB0cmFuc2xhdGVZKC00NDhweClcIixcbiAgICAgICAgICAgIC4uLnByb3BzLmJhY2tncm91bmRTdHlsZSxcbiAgICAgICAgICB9KX1cbiAgICAgICAgPlxuICAgICAgICAgIDxSb3RhdGVCdXR0b24gY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5yb3RhdGVSaWdodFN0eWxlIH0pfT5cbiAgICAgICAgICAgIDxSb3RhdGVSaWdodEljb25cbiAgICAgICAgICAgICAgb25DbGljaz17KCkgPT4ge1xuICAgICAgICAgICAgICAgIGxldCBiZWFyaW5nID0gTWF0aC5yb3VuZChtYXBSZWYuY3VycmVudD8uZ2V0QmVhcmluZygpKTtcbiAgICAgICAgICAgICAgICBsZXQgcmVzdCA9IE1hdGgucm91bmQoYmVhcmluZyAlIDkwKTtcbiAgICAgICAgICAgICAgICBpZiAoYmVhcmluZyA+IDApIHtcbiAgICAgICAgICAgICAgICAgIHJlc3QgPSA5MCAtIHJlc3Q7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChyZXN0ID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICByZXN0ID0gOTA7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIG1hcFJlZi5jdXJyZW50Py5zZXRCZWFyaW5nKE1hdGgucm91bmQoYmVhcmluZyArIE1hdGguYWJzKHJlc3QpKSk7XG4gICAgICAgICAgICAgIH19XG4gICAgICAgICAgICA+PC9Sb3RhdGVSaWdodEljb24+XG4gICAgICAgICAgPC9Sb3RhdGVCdXR0b24+XG4gICAgICAgICAgPE5lZWRsZUJ1dHRvblxuICAgICAgICAgICAgY2xhc3NOYW1lPXtjc3MoeyAuLi5wcm9wcy5uZWVkbGVTdHlsZSB9KX1cbiAgICAgICAgICAgIG9uQ2xpY2s9eygpID0+IHtcbiAgICAgICAgICAgICAgbWFwUmVmLmN1cnJlbnQ/LnNldEJlYXJpbmcoMCk7XG4gICAgICAgICAgICB9fVxuICAgICAgICAgID5cbiAgICAgICAgICAgIDxOZWVkbGVDb250YWluZXJcbiAgICAgICAgICAgICAgc3R5bGU9e3tcbiAgICAgICAgICAgICAgICB0cmFuc2Zvcm06IFwicm90YXRlKFwiICsgYmVhcmluZyArIFwiZGVnKVwiLFxuICAgICAgICAgICAgICB9fVxuICAgICAgICAgICAgPlxuICAgICAgICAgICAgICA8TmVlZGxlSWNvbiAvPlxuICAgICAgICAgICAgPC9OZWVkbGVDb250YWluZXI+XG4gICAgICAgICAgPC9OZWVkbGVCdXR0b24+XG4gICAgICAgICAgPFJvdGF0ZUJ1dHRvbiBjbGFzc05hbWU9e2Nzcyh7IC4uLnByb3BzLnJvdGF0ZUxlZnRTdHlsZSB9KX0+XG4gICAgICAgICAgICA8Um90YXRlTGVmdEljb25cbiAgICAgICAgICAgICAgb25DbGljaz17KCkgPT4ge1xuICAgICAgICAgICAgICAgIGxldC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jdCB0byBhZGp1c3QgY3NzIGRlZmluaXRpb25zIG9mIHRoZSBjb21wYXNzIG5lZWRsZS5cbiAgICovXG4gIG5lZWRsZVN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIHJvdGF0ZSByaWdodCBidXR0b24uXG4gICAqL1xuICByb3RhdGVSaWdodFN0eWxlOiBQcm9wVHlwZXMub2JqZWN0LFxuICAvKipcbiAgICogU3R5bGUgb2JqZWN0IHRvIGFkanVzdCBjc3MgZGVmaW5pdGlvbnMgb2YgdGhlIHJvdGF0ZSBsZWZ0IGJ1dHRvbi5cbiAgICovXG4gIHJvdGF0ZUxlZnRTdHlsZTogUHJvcFR5cGVzLm9iamVjdCxcbn07XG5cbmV4cG9ydCBkZWZhdWx0IE1sTmF2aWdhdGlvbkNvbXBhc3M7XG4iXX0= */")
2226
+ }, /*#__PURE__*/React__default.createElement(SvgRotateLeft, {
2227
+ onClick: function onClick() {
2228
+ var _mapRef$current4, _mapRef$current5;
2030
2229
 
2031
- MlFollowGps.defaultProps = {
2032
- mapId: undefined,
2033
- style: {
2034
- minWidth: "30px",
2035
- minHeight: "30px",
2036
- width: "30px",
2037
- height: "30px",
2038
- backgroundColor: "#414141",
2039
- borderRadius: "23%",
2040
- margin: 0.15,
2041
- fontSize: "1.3em",
2042
- ":hover": {
2043
- backgroundColor: "#515151",
2044
- color: "#ececec"
2230
+ var bearing = Math.round((_mapRef$current4 = mapRef.current) === null || _mapRef$current4 === void 0 ? void 0 : _mapRef$current4.getBearing());
2231
+ var rest = Math.round(bearing % 90);
2232
+
2233
+ if (bearing < 0) {
2234
+ rest = 90 + rest;
2235
+ }
2236
+
2237
+ if (rest === 0) {
2238
+ rest = 90;
2239
+ }
2240
+
2241
+ (_mapRef$current5 = mapRef.current) === null || _mapRef$current5 === void 0 ? void 0 : _mapRef$current5.setBearing(Math.round(bearing - Math.abs(rest)));
2045
2242
  }
2046
- }
2243
+ })))));
2047
2244
  };
2048
- MlFollowGps.propTypes = {
2245
+
2246
+ MlNavigationCompass.propTypes = {
2049
2247
  /**
2050
- * Id of the target MapLibre instance in mapContext
2248
+ * Component id prefix
2051
2249
  */
2052
- mapId: PropTypes.string,
2250
+ idPrefix: PropTypes.string,
2053
2251
 
2054
2252
  /**
2055
- * CSS style object that is applied to the button component
2253
+ * Style object to adjust css definitions of the component.
2254
+ */
2255
+ style: PropTypes.object,
2256
+
2257
+ /**
2258
+ * Style object to adjust css definitions of the background.
2259
+ */
2260
+ backgroundStyle: PropTypes.object,
2261
+
2262
+ /**
2263
+ * Style object to adjust css definitions of the compass needle.
2264
+ */
2265
+ needleStyle: PropTypes.object,
2266
+
2267
+ /**
2268
+ * Style object to adjust css definitions of the rotate right button.
2269
+ */
2270
+ rotateRightStyle: PropTypes.object,
2271
+
2272
+ /**
2273
+ * Style object to adjust css definitions of the rotate left button.
2056
2274
  */
2057
- style: PropTypes.object
2275
+ rotateLeftStyle: PropTypes.object
2058
2276
  };
2059
2277
 
2278
+ var _excluded$1 = ["color"];
2279
+
2060
2280
  var MlNavigationTools = function MlNavigationTools(props) {
2061
2281
  var mapContext = useContext(MapContext);
2062
2282
  var initializedRef = useRef(false);
@@ -2079,7 +2299,6 @@ var MlNavigationTools = function MlNavigationTools(props) {
2079
2299
  minHeight: "20px",
2080
2300
  width: mediaIsMobile ? "50px" : "30px",
2081
2301
  height: mediaIsMobile ? "50px" : "30px",
2082
- color: "#bbb",
2083
2302
  backgroundColor: "#414141",
2084
2303
  borderRadius: "23%",
2085
2304
  //border: "1px solid #bbb",
@@ -2087,9 +2306,9 @@ var MlNavigationTools = function MlNavigationTools(props) {
2087
2306
  margin: 0.15,
2088
2307
  fontSize: mediaIsMobile ? "1.5em" : "1.2em",
2089
2308
  ":hover": {
2090
- backgroundColor: "#515151",
2091
- color: "#ececec"
2092
- }
2309
+ backgroundColor: "#515151"
2310
+ },
2311
+ color: "#ececec"
2093
2312
  };
2094
2313
  useEffect(function () {
2095
2314
  var _componentId = componentId.current;
@@ -2199,7 +2418,12 @@ var MlNavigationTools = function MlNavigationTools(props) {
2199
2418
  fontSize: mediaIsMobile ? "1.5em" : "1.2em"
2200
2419
  }
2201
2420
  })), /*#__PURE__*/React__default.createElement(MlFollowGps, {
2202
- style: buttonStyle
2421
+ style: _objectSpread2({}, function (_ref) {
2422
+ var color = _ref.color,
2423
+ rest = _objectWithoutProperties(_ref, _excluded$1);
2424
+
2425
+ return rest;
2426
+ }(buttonStyle))
2203
2427
  }), /*#__PURE__*/React__default.createElement(ButtonGroup, {
2204
2428
  orientation: "vertical",
2205
2429
  sx: {
@@ -2215,14 +2439,18 @@ var MlNavigationTools = function MlNavigationTools(props) {
2215
2439
  }
2216
2440
  }
2217
2441
  }, /*#__PURE__*/React__default.createElement(Button, {
2218
- sx: buttonStyle,
2442
+ sx: _objectSpread2(_objectSpread2({}, buttonStyle), {}, {
2443
+ color: "#ececec"
2444
+ }),
2219
2445
  onClick: zoomIn
2220
2446
  }, /*#__PURE__*/React__default.createElement(ControlPointIcon, {
2221
2447
  sx: {
2222
2448
  fontSize: mediaIsMobile ? "1.5em" : "1.2em"
2223
2449
  }
2224
2450
  })), /*#__PURE__*/React__default.createElement(Button, {
2225
- sx: buttonStyle,
2451
+ sx: _objectSpread2(_objectSpread2({}, buttonStyle), {}, {
2452
+ color: "#ececec"
2453
+ }),
2226
2454
  onClick: zoomOut
2227
2455
  }, /*#__PURE__*/React__default.createElement(RemoveCircleOutlineIcon, {
2228
2456
  sx: {
@@ -2234,10 +2462,17 @@ var MlNavigationTools = function MlNavigationTools(props) {
2234
2462
  var MlLayer = function MlLayer(props) {
2235
2463
  // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
2236
2464
  var mapContext = useContext(MapContext);
2465
+ var mapState = useMapState({
2466
+ mapId: props.mapId,
2467
+ watch: {
2468
+ viewport: false,
2469
+ layers: true,
2470
+ sources: false
2471
+ }
2472
+ });
2237
2473
  var layerInitializedRef = useRef(false);
2238
2474
  var mapRef = useRef(null);
2239
2475
  var componentId = useRef((props.layerId ? props.layerId : "MlLayer-") + v4());
2240
- var idSuffixRef = useRef(props.idSuffix || new Date().getTime());
2241
2476
  var layerId = useRef(props.layerId || componentId.current);
2242
2477
  var layerPaintConfRef = useRef(undefined);
2243
2478
  var layerLayoutConfRef = useRef(undefined);
@@ -2278,6 +2513,22 @@ var MlLayer = function MlLayer(props) {
2278
2513
  useEffect(function () {
2279
2514
  if (!mapContext.mapExists(props.mapId) || layerInitializedRef.current) return; // the MapLibre-gl instance (mapContext.map) is accessible here
2280
2515
  // initialize the layer and add it to the MapLibre-gl instance or do something else with it
2516
+ //check if insertBeforeLayer exists
2517
+
2518
+ if (props.insertBeforeLayer) {
2519
+ var _mapState$layers;
2520
+
2521
+ var layerFound = false;
2522
+ mapState === null || mapState === void 0 ? void 0 : (_mapState$layers = mapState.layers) === null || _mapState$layers === void 0 ? void 0 : _mapState$layers.forEach(function (layer) {
2523
+ if (layer.id === props.insertBeforeLayer) {
2524
+ layerFound = true;
2525
+ }
2526
+ });
2527
+
2528
+ if (!layerFound) {
2529
+ return;
2530
+ }
2531
+ }
2281
2532
 
2282
2533
  mapRef.current = mapContext.getMap(props.mapId);
2283
2534
 
@@ -2295,7 +2546,7 @@ var MlLayer = function MlLayer(props) {
2295
2546
  layerPaintConfRef.current = JSON.stringify((_props$options = props.options) === null || _props$options === void 0 ? void 0 : _props$options.paint);
2296
2547
  layerLayoutConfRef.current = JSON.stringify((_props$options2 = props.options) === null || _props$options2 === void 0 ? void 0 : _props$options2.layout);
2297
2548
  }
2298
- }, [mapContext.mapIds, mapContext, props, layerId]);
2549
+ }, [mapContext.mapIds, mapContext, props, mapState.layers]);
2299
2550
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
2300
2551
  };
2301
2552
 
@@ -5397,165 +5648,138 @@ GeoJsonProvider.propTypes = {
5397
5648
  };
5398
5649
 
5399
5650
  /**
5400
- * React hook that allows subscribing to map state changes
5651
+ * MlSpatialElevationProfile returns a Button that will add a standard OSM tile layer to the maplibre-gl instance.
5401
5652
  *
5402
5653
  * @component
5403
5654
  */
5404
5655
 
5405
- function useMapState(props) {
5406
- // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
5656
+ var MlSpatialElevationProfile = function MlSpatialElevationProfile(props) {
5407
5657
  var mapContext = useContext(MapContext);
5658
+ var componentId = useRef((props.idPrefix ? props.idPrefix : "MlSpatialElevationProfile-") + v4());
5659
+ var mapRef = useRef(null);
5408
5660
  var initializedRef = useRef(false);
5409
- var mapRef = useRef(undefined);
5410
-
5411
- var _useState = useState(undefined),
5412
- _useState2 = _slicedToArray(_useState, 2),
5413
- center = _useState2[0],
5414
- setCenter = _useState2[1];
5415
-
5416
- var _useState3 = useState(undefined),
5417
- _useState4 = _slicedToArray(_useState3, 2),
5418
- viewport = _useState4[0],
5419
- setViewport = _useState4[1];
5420
-
5421
- var viewportRef = useRef(undefined);
5422
-
5423
- var _useState5 = useState(undefined),
5424
- _useState6 = _slicedToArray(_useState5, 2),
5425
- layers = _useState6[0],
5426
- setLayers = _useState6[1];
5427
-
5428
- var layersRef = useRef(undefined); //const mapRef = useRef(props.map);
5429
-
5430
- var componentId = useRef(v4());
5431
- /**
5432
- * returns the element if it matches the defined filter criteria
5433
- * to be used as filter function on the layers array
5434
- *
5435
- * @param {object} layer
5436
- */
5437
-
5438
- var layerIdFilter = useCallback(function (layer) {
5439
- if (!props.filter.includeBaseLayers && layer.baseLayer) {
5440
- return false;
5441
- }
5442
-
5443
- if (typeof props.filter.matchLayerIds !== "undefined") {
5444
- if (props.filter.matchLayerIds instanceof RegExp) {
5445
- return props.filter.matchLayerIds.test(layer.id);
5446
- } else {
5447
- return layer.id.includes(props.filter.matchLayerIds);
5448
- }
5449
- }
5450
-
5451
- return true;
5452
- }, [props.filter]);
5453
- var refreshLayerState = useCallback(function () {
5454
- var _layerState = mapRef.current.wrapper.layerState.filter(layerIdFilter);
5455
-
5456
- var _layerStateString = JSON.stringify(_layerState);
5457
-
5458
- if (layersRef.current !== _layerStateString) {
5459
- layersRef.current = _layerStateString;
5460
- setLayers(_layerState);
5461
- }
5462
- }, [layerIdFilter]);
5661
+ var dataSource = useContext(GeoJsonContext);
5662
+ var sourceName = useRef("elevationprofile-" + v4());
5663
+ var layerName = useRef("elevationprofile-layer-" + v4());
5664
+ var createStep = useCallback(function (x, y, z, x2, y2) {
5665
+ //const summand = 0.0002;
5666
+ var line = lineString$1([[x, y], [x2, y2]]);
5667
+ var offsetLine = lineOffset(line, 5, {
5668
+ units: "meters"
5669
+ });
5670
+ var x3 = offsetLine.geometry.coordinates[0][0];
5671
+ var y3 = offsetLine.geometry.coordinates[0][1];
5672
+ var x4 = offsetLine.geometry.coordinates[1][0];
5673
+ var y4 = offsetLine.geometry.coordinates[1][1];
5674
+ return polygon([[[x, y], [x2, y2], [x4, y4], [x3, y3], [x, y]]], {
5675
+ height: z * props.elevationFactor
5676
+ });
5677
+ }, [props.elevationFactor]);
5463
5678
  useEffect(function () {
5464
5679
  var _componentId = componentId.current;
5465
5680
  return function () {
5681
+ // This is the cleanup function, it is called when this react component is removed from react-dom
5466
5682
  if (mapRef.current) {
5467
5683
  mapRef.current.cleanup(_componentId);
5468
- mapRef.current = undefined;
5684
+ mapRef.current = null;
5469
5685
  }
5470
-
5471
- initializedRef.current = false;
5472
5686
  };
5473
5687
  }, []);
5474
5688
  useEffect(function () {
5475
- var _props$watch, _props$watch2;
5476
-
5477
- if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
5478
- // initialize the layer and add it to the MapLibre-gl instance or do something else with it
5479
-
5689
+ if (!mapContext.mapExists(props.mapId) || initializedRef.current) return;
5480
5690
  initializedRef.current = true;
5481
5691
  mapRef.current = mapContext.getMap(props.mapId);
5482
- /*
5483
- mapRef.current.on(
5484
- "move",
5485
- () => {
5486
- setCenter(mapRef.current.getCenter());
5487
- },
5488
- componentId.current
5489
- );
5490
- */
5692
+ mapRef.current.addSource(sourceName.current, {
5693
+ type: "geojson",
5694
+ data: dataSource.data
5695
+ }, componentId.current);
5696
+ mapRef.current.addLayer({
5697
+ id: layerName.current,
5698
+ source: sourceName.current,
5699
+ type: "fill-extrusion",
5700
+ paint: {
5701
+ "fill-extrusion-height": ["get", "height"],
5702
+ "fill-extrusion-opacity": 0.9,
5703
+ "fill-extrusion-color": ["interpolate", ["linear"], ["get", "height"], 0, "rgba(0, 0, 255, 0)", 0.1, "royalblue", 0.3, "cyan", 0.5, "lime", 0.7, "yellow", 1, "yellow"]
5704
+ }
5705
+ }, props.insertBeforeLayer, componentId.current);
5706
+ }, [mapContext.mapIds, props.insertBeforeLayer, props.mapId, dataSource, mapContext]);
5707
+ useEffect(function () {
5708
+ var _mapRef$current$getSo;
5491
5709
 
5492
- if (props !== null && props !== void 0 && (_props$watch = props.watch) !== null && _props$watch !== void 0 && _props$watch.viewport) {
5493
- setViewport(mapRef.current.wrapper.viewportState);
5494
- mapRef.current.wrapper.on("viewportchange", function () {
5495
- var _mapRef$current;
5710
+ if (!mapRef.current || !mapRef.current.getLayer(layerName.current)) return;
5711
+ var data = dataSource.data;
5712
+ if (!data || !data.features) return;
5713
+ var line = data.features.find(function (element) {
5714
+ return element.geometry.type === "LineString";
5715
+ });
5716
+ if (!line || !line.geometry) return;
5717
+ var heights = line.geometry.coordinates.map(function (coordinate, index) {
5718
+ return coordinate[2];
5719
+ });
5720
+ var min = Math.min.apply(Math, _toConsumableArray(heights));
5721
+ var max = Math.max.apply(Math, _toConsumableArray(heights)) - min;
5722
+ max = max === 0 ? 1 : max;
5723
+ mapRef.current.setPaintProperty(layerName.current, "fill-extrusion-color", ["interpolate", ["linear"], ["get", "height"], 0, "rgb(0,255,55)", max * props.elevationFactor, "rgb(255,0,0)"]);
5496
5724
 
5497
- if (viewportRef.current !== ((_mapRef$current = mapRef.current) === null || _mapRef$current === void 0 ? void 0 : _mapRef$current.wrapper.viewportStateString)) {
5498
- var _mapRef$current2, _mapRef$current3, _mapRef$current3$wrap;
5725
+ var lerp = function lerp(x, y, a) {
5726
+ return x * (1 - a) + y * a;
5727
+ };
5499
5728
 
5500
- setViewport((_mapRef$current2 = mapRef.current) === null || _mapRef$current2 === void 0 ? void 0 : _mapRef$current2.wrapper.viewportState);
5501
- setCenter((_mapRef$current3 = mapRef.current) === null || _mapRef$current3 === void 0 ? void 0 : (_mapRef$current3$wrap = _mapRef$current3.wrapper.viewportState) === null || _mapRef$current3$wrap === void 0 ? void 0 : _mapRef$current3$wrap.center);
5729
+ var points = [];
5730
+ line.geometry.coordinates.forEach(function (coordinate, index) {
5731
+ //const point = createPoint(coordinate[0],coordinate[1],coordinate[2]-min);
5732
+ //points.push(point);
5733
+ if (line.geometry.coordinates[index + 1]) {
5734
+ var wayLength = distance([coordinate[0], coordinate[1]], [line.geometry.coordinates[index + 1][0], line.geometry.coordinates[index + 1][1]], {
5735
+ units: "kilometers"
5736
+ });
5737
+ var listLength = ~~(wayLength * 1000 / 10);
5738
+ listLength = listLength < 1 ? 1 : listLength;
5739
+
5740
+ for (var i = 0; i < listLength; i++) {
5741
+ var x = lerp(line.geometry.coordinates[index][0], line.geometry.coordinates[index + 1][0], i / listLength);
5742
+ var y = lerp(line.geometry.coordinates[index][1], line.geometry.coordinates[index + 1][1], i / listLength);
5743
+ var z = lerp(line.geometry.coordinates[index][2] - min, line.geometry.coordinates[index + 1][2] - min, i / listLength);
5744
+ var x2 = lerp(line.geometry.coordinates[index][0], line.geometry.coordinates[index + 1][0], (i + 1) / listLength);
5745
+ var y2 = lerp(line.geometry.coordinates[index][1], line.geometry.coordinates[index + 1][1], (i + 1) / listLength);
5746
+ var point = createStep(x, y, z, x2, y2);
5747
+ points.push(point);
5502
5748
  }
5503
- }, componentId.current);
5504
- }
5505
-
5506
- if (props !== null && props !== void 0 && (_props$watch2 = props.watch) !== null && _props$watch2 !== void 0 && _props$watch2.layers) {
5507
- var _props$filter, _props$filter2;
5508
-
5509
- refreshLayerState();
5510
- mapRef.current.wrapper.on("layerchange", refreshLayerState, {
5511
- includeBaseLayers: props === null || props === void 0 ? void 0 : (_props$filter = props.filter) === null || _props$filter === void 0 ? void 0 : _props$filter.includeBaseLayers,
5512
- matchLayerIds: props === null || props === void 0 ? void 0 : (_props$filter2 = props.filter) === null || _props$filter2 === void 0 ? void 0 : _props$filter2.matchLayerIds
5513
- }, componentId.current);
5514
- }
5515
- }, [mapContext.mapIds, mapContext, props.mapId, refreshLayerState]);
5516
- return {
5517
- layers: layers,
5518
- viewport: viewport
5519
- };
5520
- }
5749
+ }
5750
+ });
5751
+ var newData = dataSource.getEmptyFeatureCollection();
5752
+ newData.features = points;
5753
+ (_mapRef$current$getSo = mapRef.current.getSource(sourceName.current)) === null || _mapRef$current$getSo === void 0 ? void 0 : _mapRef$current$getSo.setData(newData);
5754
+ }, [dataSource.data, createStep, dataSource, props.elevationFactor, mapContext]);
5755
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
5756
+ };
5521
5757
 
5522
- useMapState.defaultProps = {
5523
- mapId: undefined,
5524
- watch: {
5525
- layers: true,
5526
- sources: false,
5527
- viewport: false
5528
- },
5529
- filter: {
5530
- includeBaseLayers: false
5531
- }
5758
+ MlSpatialElevationProfile.defaultProps = {
5759
+ elevationFactor: 1
5532
5760
  };
5533
- useMapState.propTypes = {
5761
+ MlSpatialElevationProfile.propTypes = {
5534
5762
  /**
5535
5763
  * Id of the target MapLibre instance in mapContext
5536
5764
  */
5537
5765
  mapId: PropTypes.string,
5538
5766
 
5539
5767
  /**
5540
- * Defines map Resources to watch
5768
+ * Prefix of the component id this component uses when adding elements to the MapLibreGl-instance
5541
5769
  */
5542
- watch: PropTypes.shape({
5543
- layers: PropTypes.bool,
5544
- sources: PropTypes.bool,
5545
- viewport: PropTypes.bool
5546
- }),
5770
+ idPrefix: PropTypes.string,
5547
5771
 
5548
5772
  /**
5549
- * Filter string or RegExp to more explicitly define the elements watched and increase performance
5550
- * strings will be matched using layerId.includes(matchString)
5551
- * RegExps will be matched using matchRegExp.test(layerId)
5773
+ * Number describes the factor of the height of the elevation
5552
5774
  */
5553
- filter: PropTypes.shape({
5554
- includeBaseLayers: PropTypes.bool,
5555
- matchLayerIds: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(RegExp)]),
5556
- matchSourceIds: PropTypes.oneOfType([PropTypes.string, PropTypes.instanceOf(RegExp)])
5557
- })
5775
+ elevationFactor: PropTypes.number,
5776
+
5777
+ /**
5778
+ * The layerId of an existing layer this layer should be rendered visually beneath
5779
+ * https://maplibre.org/maplibre-gl-js-docs/api/map/#map#addlayer - see "beforeId" property
5780
+ */
5781
+ insertBeforeLayer: PropTypes.string
5558
5782
  };
5559
5783
 
5560
- export { GeoJsonContext, GeoJsonProvider, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlVectorTileLayer, MlWmsLayer, useMapState };
5784
+ export { GeoJsonContext, GeoJsonProvider, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlFollowGps, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlSpatialElevationProfile, MlVectorTileLayer, MlWmsLayer, useMap, useMapState };
5561
5785
  //# sourceMappingURL=index.esm.js.map