@mapcomponents/react-maplibre 0.1.29 → 0.1.32

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 (108) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/coverage/clover.xml +50 -50
  3. package/coverage/coverage-final.json +15 -15
  4. package/coverage/lcov-report/index.html +17 -17
  5. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.js.html +1 -1
  6. package/coverage/lcov-report/src/components/MapLibreMap/index.html +1 -1
  7. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.js.html +11 -11
  8. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +11 -11
  9. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.js.html +1 -1
  10. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
  11. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.js.html +4 -4
  12. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  13. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.js.html +4 -4
  14. package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
  15. package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.js.html +4 -4
  16. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +8 -8
  17. package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
  18. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.js.html +1 -1
  19. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  20. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.js.html +2 -2
  21. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
  22. package/coverage/lcov-report/src/components/MlLayer/MlLayer.js.html +2 -2
  23. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  24. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.js.html +4 -4
  25. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +1 -1
  26. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.js.html +3 -3
  27. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +1 -1
  28. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +1 -1
  29. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
  30. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  31. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  32. package/coverage/lcov-report/src/components/MlMarker/MlMarker.js.html +1 -1
  33. package/coverage/lcov-report/src/components/MlMarker/index.html +1 -1
  34. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.js.html +6 -6
  35. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  36. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.js.html +7 -7
  37. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +11 -11
  38. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +3 -3
  39. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  40. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
  41. package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
  42. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +1 -1
  43. package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
  44. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +4 -4
  45. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  46. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +1 -1
  47. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
  48. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.js.html +2 -2
  49. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
  50. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  51. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  52. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.js.html +3 -3
  53. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
  54. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +1 -1
  55. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
  56. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.js.html +5 -5
  57. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
  58. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.js.html +1 -1
  59. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
  60. package/coverage/lcov-report/src/hooks/index.html +1 -1
  61. package/coverage/lcov-report/src/hooks/useMap.js.html +1 -1
  62. package/coverage/lcov-report/src/hooks/useMapState.js.html +1 -1
  63. package/coverage/lcov-report/src/hooks/useWms.js.html +1 -1
  64. package/coverage/lcov-report/src/i18n.js.html +1 -1
  65. package/coverage/lcov-report/src/index.html +1 -1
  66. package/coverage/lcov-report/src/translations/english.js.html +1 -1
  67. package/coverage/lcov-report/src/translations/german.js.html +1 -1
  68. package/coverage/lcov-report/src/translations/index.html +1 -1
  69. package/coverage/lcov.info +47 -47
  70. package/dist/index.esm.js +572 -10
  71. package/dist/index.esm.js.map +1 -1
  72. package/package.json +7 -4
  73. package/public/thumbnails/MlCreatePdfButton.png +0 -0
  74. package/public/thumbnails/MlDeckGlTerrainLayer.png +0 -0
  75. package/public/thumbnails/MlFillExtrusionLayer.png +0 -0
  76. package/public/thumbnails/MlLaermkarte.png +0 -0
  77. package/public/thumbnails/MlLayerMagnify.png +0 -0
  78. package/public/thumbnails/MlLayerSwipe.png +0 -0
  79. package/public/thumbnails/MlMapDrawTools.png +0 -0
  80. package/public/thumbnails/MlThreeJsLayer.png +0 -0
  81. package/public/thumbnails/MlTransitionGeoJsonLayer.png +0 -0
  82. package/public/thumbnails/MlVectorTileLayer.png +0 -0
  83. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.js +1 -1
  84. package/src/components/MlCreatePdfButton/MlCreatePdfButton.doc.de.md +1 -3
  85. package/src/components/MlCreatePdfButton/MlCreatePdfButton.doc.en.md +0 -2
  86. package/src/components/MlCreatePdfButton/MlCreatePdfButton.meta.json +1 -1
  87. package/src/components/MlFeatureEditor/MlFeatureEditor.doc.de.md +1 -3
  88. package/src/components/MlFeatureEditor/MlFeatureEditor.meta.json +1 -1
  89. package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.doc.de.md +1 -3
  90. package/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.meta.json +1 -1
  91. package/src/components/MlFollowGps/MlFollowGps.doc.de.md +1 -3
  92. package/src/components/MlGPXViewer/MlGPXViewer.doc.de.md +1 -3
  93. package/src/components/MlGPXViewer/MlGPXViewer.meta.json +1 -1
  94. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.doc.de.md +1 -3
  95. package/src/components/MlGeoJsonLayer/MlGeoJsonLayer.meta.json +1 -1
  96. package/src/components/MlLayerMagnify/MlLayerMagnify.doc.de.md +1 -3
  97. package/src/components/MlLayerSwipe/MlLayerSwipe.doc.de.md +1 -3
  98. package/src/components/MlNavigationCompass/MlNavigationCompass.doc.de.md +1 -3
  99. package/src/components/MlNavigationTools/MlNavigationTools.doc.de.md +1 -3
  100. package/src/components/MlScaleReference/MlScaleReference.doc.de.md +1 -3
  101. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.doc.de.md +1 -4
  102. package/src/components/MlThreeJsLayer/MlThreeJsLayer.doc.de.md +1 -3
  103. package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.js +1 -1
  104. package/src/components/MlVectorTileLayer/MlVectorTileLayer.doc.de.md +1 -3
  105. package/src/components/MlVectorTileLayer/MlVectorTileLayer.meta.json +1 -1
  106. package/src/components/MlWmsLoader/MlWmsLoader.doc.de.md +1 -3
  107. package/src/components/MlWmsLoader/MlWmsLoader.meta.json +1 -1
  108. package/src/index.js +3 -0
package/dist/index.esm.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import React__default, { useRef, useContext, useEffect, useState, useCallback, useMemo, createElement } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { MapContext } from '@mapcomponents/react-core';
4
- import maplibregl, { Popup } from 'maplibre-gl';
4
+ import maplibregl from '!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
8
  import GpsFixedIcon from '@mui/icons-material/GpsFixed';
9
- import { point, circle, lineArc, bbox, lineOffset, distance } from '@turf/turf';
9
+ import { point, circle, lineArc, bbox, lineOffset, distance, lineString as lineString$1, length, lineChunk, featureCollection } from '@turf/turf';
10
+ import maplibregl$1, { Popup } from 'maplibre-gl';
10
11
  import jsPDF from 'jspdf';
11
12
  import PrinterIcon from '@mui/icons-material/Print';
12
13
  import ButtonGroup from '@mui/material/ButtonGroup';
@@ -30,6 +31,8 @@ import List from '@mui/material/List';
30
31
  import ListItem from '@mui/material/ListItem';
31
32
  import ListItemText from '@mui/material/ListItemText';
32
33
  import { lineString, polygon } from '@turf/helpers';
34
+ import Paper from '@mui/material/Paper';
35
+ import WMSCapabilities from 'wms-capabilities';
33
36
 
34
37
  function ownKeys(object, enumerableOnly) {
35
38
  var keys = Object.keys(object);
@@ -118,6 +121,24 @@ function _defineProperty(obj, key, value) {
118
121
  return obj;
119
122
  }
120
123
 
124
+ function _extends() {
125
+ _extends = Object.assign || function (target) {
126
+ for (var i = 1; i < arguments.length; i++) {
127
+ var source = arguments[i];
128
+
129
+ for (var key in source) {
130
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
131
+ target[key] = source[key];
132
+ }
133
+ }
134
+ }
135
+
136
+ return target;
137
+ };
138
+
139
+ return _extends.apply(this, arguments);
140
+ }
141
+
121
142
  function _objectWithoutPropertiesLoose(source, excluded) {
122
143
  if (source == null) return {};
123
144
  var target = {};
@@ -1715,7 +1736,7 @@ var createPdf = function createPdf(map, locationValue, setLoading) {
1715
1736
  container.style.height = toPixels(height);
1716
1737
  hidden.appendChild(container); //Render map
1717
1738
 
1718
- var renderMap = new maplibregl.Map({
1739
+ var renderMap = new maplibregl$1.Map({
1719
1740
  container: container,
1720
1741
  center: map.getCenter(),
1721
1742
  zoom: map.getZoom(),
@@ -1914,10 +1935,10 @@ var MlImageMarkerLayer = function MlImageMarkerLayer(props) {
1914
1935
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null);
1915
1936
  };
1916
1937
 
1917
- 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); }
1938
+ function _extends$1() { _extends$1 = 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$1.apply(this, arguments); }
1918
1939
 
1919
1940
  function SvgRotateRight(props) {
1920
- return /*#__PURE__*/createElement("svg", _extends({
1941
+ return /*#__PURE__*/createElement("svg", _extends$1({
1921
1942
  width: "39.675098mm",
1922
1943
  height: "104.27064mm",
1923
1944
  viewBox: "0 0 39.675098 104.27064"
@@ -1934,10 +1955,10 @@ function SvgRotateRight(props) {
1934
1955
 
1935
1956
  var _g;
1936
1957
 
1937
- function _extends$1() { _extends$1 = 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$1.apply(this, arguments); }
1958
+ function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
1938
1959
 
1939
1960
  function SvgRotateLeft(props) {
1940
- return /*#__PURE__*/createElement("svg", _extends$1({
1961
+ return /*#__PURE__*/createElement("svg", _extends$2({
1941
1962
  width: "39.675098mm",
1942
1963
  height: "104.27064mm",
1943
1964
  viewBox: "0 0 39.675098 104.27064"
@@ -1950,10 +1971,10 @@ function SvgRotateLeft(props) {
1950
1971
 
1951
1972
  var _g$1;
1952
1973
 
1953
- function _extends$2() { _extends$2 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$2.apply(this, arguments); }
1974
+ function _extends$3() { _extends$3 = 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$3.apply(this, arguments); }
1954
1975
 
1955
1976
  function SvgNeedle(props) {
1956
- return /*#__PURE__*/createElement("svg", _extends$2({
1977
+ return /*#__PURE__*/createElement("svg", _extends$3({
1957
1978
  width: "75.967445mm",
1958
1979
  height: "234.71339mm",
1959
1980
  viewBox: "0 0 75.967445 234.71339"
@@ -5554,5 +5575,546 @@ MlSpatialElevationProfile.propTypes = {
5554
5575
  insertBeforeLayer: PropTypes.string
5555
5576
  };
5556
5577
 
5557
- export { GeoJsonContext, GeoJsonProvider, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlFollowGps, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlSpatialElevationProfile, MlVectorTileLayer, MlWmsLayer, useMap, useMapState };
5578
+ var _showNextTransitionSegment = function _showNextTransitionSegment(props, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef, setDisplayGeojson) {
5579
+ var _arguments = arguments;
5580
+
5581
+ if (typeof transitionGeojsonDataRef.current[currentTransitionStepRef.current] !== "undefined") {
5582
+ // if at last transition step set to target geojson
5583
+ // else to an assembled LineString from common geometry and the current transition step geometry
5584
+ var newData = currentTransitionStepRef.current + 1 === transitionGeojsonDataRef.current.length ? props.geojson : lineString$1([].concat(_toConsumableArray(transitionGeojsonCommonDataRef.current), _toConsumableArray(transitionGeojsonDataRef.current[currentTransitionStepRef.current].geometry.coordinates)));
5585
+ setDisplayGeojson(newData);
5586
+
5587
+ if (typeof props.onTransitionFrame === "function") {
5588
+ props.onTransitionFrame(newData);
5589
+ }
5590
+
5591
+ currentTransitionStepRef.current++;
5592
+
5593
+ if (transitionInProgressRef.current && currentTransitionStepRef.current < transitionGeojsonDataRef.current.length) {
5594
+ transitionTimeoutRef.current = setTimeout(function () {
5595
+ return _showNextTransitionSegment.apply(void 0, _toConsumableArray(_arguments));
5596
+ }, msPerStep);
5597
+ } else {
5598
+ if (typeof props.onTransitionEnd === "function") {
5599
+ props.onTransitionEnd(props.geojson);
5600
+ }
5601
+
5602
+ transitionInProgressRef.current = false;
5603
+ }
5604
+ }
5605
+ };
5606
+
5607
+ var _transitionToGeojson = function _transitionToGeojson(props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, map, transitionTimeoutRef, setDisplayGeojson) {
5608
+ // create the transition geojson between oldGeojsonRef.current and props.geojson
5609
+ // create a geojson that contains no common point between the two line features
5610
+ var transitionCoordinatesShort = [];
5611
+ var transitionCoordinatesLong = [];
5612
+ var targetCoordinates = [];
5613
+ var srcCoordinates = [];
5614
+ transitionGeojsonCommonDataRef.current = [];
5615
+ var sourceGeojson = oldGeojsonRef.current || {
5616
+ geometry: {
5617
+ type: "LineString",
5618
+ coordinates: []
5619
+ },
5620
+ properties: {},
5621
+ type: "Feature"
5622
+ };
5623
+ var targetGeojson = props.geojson;
5624
+ var longerGeojson = targetGeojson;
5625
+ var shorterGeojson = sourceGeojson;
5626
+ var reverseOrder = false; // In case one geojson is missing completely use the first two coordinates of the other geojson
5627
+
5628
+ if (typeof longerGeojson.geometry === "undefined" && typeof shorterGeojson.geometry !== "undefined" && shorterGeojson.geometry.coordinates.length > 1) {
5629
+ longerGeojson = lineString$1(shorterGeojson.geometry.coordinates.slice(0, 2));
5630
+ } else if (typeof shorterGeojson.geometry === "undefined" && typeof longerGeojson.geometry !== "undefined" && longerGeojson.geometry.coordinates.length > 1) {
5631
+ shorterGeojson = lineString$1(longerGeojson.geometry.coordinates.slice(0, 2));
5632
+ } else if (typeof shorterGeojson.geometry === "undefined" && typeof longerGeojson.geometry === "undefined") {
5633
+ return;
5634
+ }
5635
+
5636
+ if (longerGeojson.geometry.coordinates.length < shorterGeojson.geometry.coordinates.length) {
5637
+ longerGeojson = sourceGeojson;
5638
+ shorterGeojson = targetGeojson;
5639
+ reverseOrder = true;
5640
+ }
5641
+
5642
+ if (longerGeojson && shorterGeojson) {
5643
+ for (var i = 0, len = longerGeojson.geometry.coordinates.length; i < len; i++) {
5644
+ if (typeof shorterGeojson.geometry.coordinates[i] !== "undefined" && longerGeojson.geometry.coordinates[i][0] === shorterGeojson.geometry.coordinates[i][0] && longerGeojson.geometry.coordinates[i][1] === shorterGeojson.geometry.coordinates[i][1]) {
5645
+ // if coordinates are equal
5646
+ transitionGeojsonCommonDataRef.current.push(longerGeojson.geometry.coordinates[i]);
5647
+ } else {
5648
+ if (typeof longerGeojson.geometry.coordinates[i] !== "undefined") {
5649
+ transitionCoordinatesLong.push(longerGeojson.geometry.coordinates[i]);
5650
+ }
5651
+
5652
+ if (typeof shorterGeojson.geometry.coordinates[i] !== "undefined") {
5653
+ transitionCoordinatesShort.push(shorterGeojson.geometry.coordinates[i]);
5654
+ }
5655
+ }
5656
+ }
5657
+ }
5658
+
5659
+ if (reverseOrder) {
5660
+ targetCoordinates = transitionCoordinatesShort;
5661
+ srcCoordinates = transitionCoordinatesLong;
5662
+ } else {
5663
+ targetCoordinates = transitionCoordinatesLong;
5664
+ srcCoordinates = transitionCoordinatesShort;
5665
+ }
5666
+
5667
+ if (targetCoordinates.length < 2 && srcCoordinates < 2) return; // create props.transitionTime / msPerStep (=: transitionSteps) Versions of transitionGeojsonCommonDataRef.current + transitionCoordinates making the transitionCoordinates transitionCoordinatesDistance / transitionSteps longer on each step
5668
+
5669
+ var transitionSteps = props.transitionTime / msPerStep;
5670
+ var srcCoordinatesDistance = srcCoordinates.length > 1 ? Math.round(length(lineString$1(srcCoordinates))) : 0;
5671
+ var targetCoordinatesDistance = targetCoordinates.length > 1 ? Math.round(length(lineString$1(targetCoordinates))) : 0;
5672
+ var transitionDistance = targetCoordinatesDistance + srcCoordinatesDistance;
5673
+ var srcCoordinatesShare = srcCoordinatesDistance / transitionDistance;
5674
+ var srcTransitionSteps = Math.round(transitionSteps * srcCoordinatesShare);
5675
+ var srcPerStepDistance = Math.round(srcCoordinatesDistance / srcTransitionSteps * 100) / 100;
5676
+ var targetCoordinatesShare = targetCoordinatesDistance / transitionDistance;
5677
+ var targetTransitionSteps = Math.round(transitionSteps * targetCoordinatesShare);
5678
+ var targetPerStepDistance = Math.round(targetCoordinatesDistance / targetTransitionSteps * 100) / 100; // use srcPerStepDistance as src coordinates are always animated backwards
5679
+
5680
+
5681
+ var transitionStepData;
5682
+ transitionStepData = _toConsumableArray(createTransitionSteps(srcCoordinates, srcPerStepDistance, srcTransitionSteps));
5683
+ transitionStepData.reverse();
5684
+ transitionStepData = [].concat(_toConsumableArray(transitionStepData), _toConsumableArray(createTransitionSteps(targetCoordinates, targetPerStepDistance, targetTransitionSteps)));
5685
+ transitionStepData.push(targetGeojson);
5686
+ transitionGeojsonDataRef.current = transitionStepData;
5687
+ currentTransitionStepRef.current = 1;
5688
+ transitionInProgressRef.current = true;
5689
+ transitionTimeoutRef.current = setTimeout(function () {
5690
+ return _showNextTransitionSegment(props, map, transitionInProgressRef, transitionGeojsonDataRef, transitionGeojsonCommonDataRef, currentTransitionStepRef, msPerStep, transitionTimeoutRef, setDisplayGeojson);
5691
+ }, msPerStep);
5692
+ };
5693
+
5694
+ var createTransitionSteps = function createTransitionSteps(linestringCoordinates, perStepDistance, stepCnt) {
5695
+ var transitionSteps = [];
5696
+
5697
+ if (linestringCoordinates.length > 1) {
5698
+ var tmpChunks = lineChunk(lineString$1(linestringCoordinates), perStepDistance); // tmpLineString contains all coordinates of all previous plus current loop iteration
5699
+
5700
+ var tmpLinestring = tmpChunks.features[0];
5701
+
5702
+ for (var i = 0; i < stepCnt; i++) {
5703
+ transitionSteps.push(tmpLinestring);
5704
+
5705
+ if (typeof tmpChunks.features[i] !== "undefined") {
5706
+ tmpLinestring = lineString$1([].concat(_toConsumableArray(tmpLinestring.geometry.coordinates), _toConsumableArray(tmpChunks.features[i].geometry.coordinates)));
5707
+ } else {
5708
+ break;
5709
+ }
5710
+ }
5711
+ }
5712
+
5713
+ return transitionSteps;
5714
+ };
5715
+
5716
+ var _excluded$2 = ["geojson"];
5717
+ var msPerStep = 50;
5718
+ /**
5719
+ * Adds source and layer of types "line", "fill" or "circle" to display GeoJSON data on the map.
5720
+ *
5721
+ * @component
5722
+ */
5723
+
5724
+ var MlTransitionGeoJsonLayer = function MlTransitionGeoJsonLayer(props) {
5725
+ var geojson = props.geojson,
5726
+ restProps = _objectWithoutProperties(props, _excluded$2); // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
5727
+
5728
+
5729
+ var mapHook = useMap({
5730
+ mapId: props.mapId,
5731
+ waitForLayer: props.insertBeforeLayer
5732
+ });
5733
+ var initializedRef = useRef(false); // transition effect variables
5734
+
5735
+ var oldGeojsonRef = useRef(null);
5736
+ var transitionInProgressRef = useRef(false);
5737
+ var transitionTimeoutRef = useRef(undefined);
5738
+ var currentTransitionStepRef = useRef(false);
5739
+ var transitionGeojsonDataRef = useRef([]);
5740
+ var transitionGeojsonCommonDataRef = useRef([]);
5741
+
5742
+ var _useState = useState(featureCollection([])),
5743
+ _useState2 = _slicedToArray(_useState, 2),
5744
+ displayGeojson = _useState2[0],
5745
+ setDisplayGeojson = _useState2[1];
5746
+
5747
+ useEffect(function () {
5748
+ return function () {
5749
+ // This is the cleanup function, it is called when this react component is removed from react-dom
5750
+ if (transitionTimeoutRef.current) {
5751
+ clearTimeout(transitionTimeoutRef.current);
5752
+ }
5753
+ };
5754
+ }, []);
5755
+ var transitionToGeojson = useCallback(function () {
5756
+ _transitionToGeojson(props, transitionGeojsonCommonDataRef, transitionGeojsonDataRef, transitionInProgressRef, oldGeojsonRef, msPerStep, currentTransitionStepRef, mapHook.map, transitionTimeoutRef, setDisplayGeojson);
5757
+ }, [props, mapHook.map]);
5758
+ useEffect(function () {
5759
+ if (!mapHook.map || !initializedRef.current) return;
5760
+
5761
+ if (typeof props.transitionTime !== "undefined" && props.type === "line" && oldGeojsonRef.current) {
5762
+ transitionInProgressRef.current = false;
5763
+ currentTransitionStepRef.current = false;
5764
+ transitionGeojsonDataRef.current = [];
5765
+ transitionGeojsonCommonDataRef.current = [];
5766
+ transitionToGeojson();
5767
+ }
5768
+
5769
+ oldGeojsonRef.current = props.geojson;
5770
+ }, [mapHook.map, transitionToGeojson, props]);
5771
+ var startTransition = useCallback(function () {
5772
+ if (props.type === "line" && typeof props.transitionTime !== "undefined" && props.transitionTime && typeof props.geojson.geometry !== "undefined" && JSON.stringify(oldGeojsonRef.current) !== JSON.stringify(props.geojson)) {
5773
+ transitionToGeojson(props.geojson);
5774
+ oldGeojsonRef.current = props.geojson;
5775
+ }
5776
+ }, [props, transitionToGeojson]);
5777
+ useEffect(function () {
5778
+ if (!mapHook.mapIsReady || !props.geojson) return;
5779
+ initializedRef.current = true;
5780
+ startTransition();
5781
+ }, [mapHook.mapIsReady, startTransition, props]);
5782
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, _extends({}, restProps, {
5783
+ geojson: displayGeojson
5784
+ })));
5785
+ };
5786
+
5787
+ MlTransitionGeoJsonLayer.propTypes = {
5788
+ /**
5789
+ * Id of the target MapLibre instance in mapContext
5790
+ */
5791
+ mapId: PropTypes.string,
5792
+
5793
+ /**
5794
+ * Type of the layer that will be added to the MapLibre instance.
5795
+ * Possible values: "line", "circle", "fill"
5796
+ */
5797
+ type: PropTypes.string,
5798
+
5799
+ /**
5800
+ * Layout property object, that is passed to the addLayer call.
5801
+ * Possible props depend on the layer type.
5802
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
5803
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
5804
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
5805
+ */
5806
+ layout: PropTypes.object,
5807
+
5808
+ /**
5809
+ * Paint property object, that is passed to the addLayer call.
5810
+ * Possible props depend on the layer type.
5811
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#line
5812
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#circle
5813
+ * https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/#fill
5814
+ */
5815
+ paint: PropTypes.object,
5816
+
5817
+ /**
5818
+ * Javascript object with optional properties "fill", "line", "circle" to override implicit layer type default paint properties.
5819
+ */
5820
+ defaultPaintOverrides: PropTypes.object,
5821
+
5822
+ /**
5823
+ * Javascript object that is spread into the addLayer commands first parameter.
5824
+ */
5825
+ options: PropTypes.object,
5826
+
5827
+ /**
5828
+ * GeoJSON data that is supposed to be rendered by this component.
5829
+ */
5830
+ geojson: PropTypes.object,
5831
+
5832
+ /**
5833
+ * Id of an existing layer in the mapLibre instance to help specify the layer order
5834
+ * This layer will be visually beneath the layer with the "insertBeforeLayer" id.
5835
+ */
5836
+ insertBeforeLayer: PropTypes.string,
5837
+
5838
+ /**
5839
+ * Click event handler that is executed whenever a geometry rendered by this component is clicked.
5840
+ */
5841
+ onClick: PropTypes.func,
5842
+
5843
+ /**
5844
+ * Hover event handler that is executed whenever a geometry rendered by this component is hovered.
5845
+ */
5846
+ onHover: PropTypes.func,
5847
+
5848
+ /**
5849
+ * Leave event handler that is executed whenever a geometry rendered by this component is
5850
+ * left/unhovered.
5851
+ */
5852
+ onLeave: PropTypes.func,
5853
+
5854
+ /**
5855
+ * Creates transition animation whenever the geojson prop changes.
5856
+ * Only works with layer type "line" and LineString GeoJSON data.
5857
+ */
5858
+ transitionTime: PropTypes.number
5859
+ };
5860
+
5861
+ /**
5862
+ * Adds a marker to the map and displays a marker description next to it
5863
+ *
5864
+ * @param {object} props
5865
+ * @param {string} props.mapId Id of the target MapLibre instance in mapContext
5866
+ * @param {number} props.lng
5867
+ * @param {number} props.lat
5868
+ * @param {string} props.content
5869
+ *
5870
+ * @component
5871
+ */
5872
+
5873
+ var MlMarker = function MlMarker(props) {
5874
+ var mapContext = useContext(MapContext);
5875
+ var mapState = useMapState({
5876
+ mapId: props.mapId,
5877
+ watch: {
5878
+ viewport: true
5879
+ }
5880
+ });
5881
+ var iframe = useRef(undefined);
5882
+ var initializedRef = useRef(false);
5883
+ var mapRef = useRef(undefined);
5884
+ var componentId = useRef((props.idPrefix ? props.idPrefix : "MlMarker-") + v4());
5885
+
5886
+ var _useState = useState({
5887
+ width: "400px",
5888
+ height: "500px"
5889
+ }),
5890
+ _useState2 = _slicedToArray(_useState, 2),
5891
+ iframeDimensions = _useState2[0],
5892
+ setIframeDimensions = _useState2[1];
5893
+
5894
+ var _useState3 = useState(undefined),
5895
+ _useState4 = _slicedToArray(_useState3, 2),
5896
+ markerPixelPos = _useState4[0],
5897
+ setMarkerPixelPos = _useState4[1];
5898
+
5899
+ useEffect(function () {
5900
+ var _componentId = componentId.current;
5901
+ return function () {
5902
+ // This is the cleanup function, it is called when this react component is removed from react-dom
5903
+ // try to remove anything this component has added to the MapLibre-gl instance
5904
+ // e.g.: remove the layer
5905
+ // mapContext.getMap(props.mapId).removeLayer(layerRef.current);
5906
+ // check for the existence of map.style before calling getLayer or getSource
5907
+ if (mapRef.current) {
5908
+ mapRef.current.cleanup(_componentId);
5909
+ mapRef.current = undefined;
5910
+ }
5911
+
5912
+ initializedRef.current = false;
5913
+ };
5914
+ }, []);
5915
+ useEffect(function () {
5916
+ if (!mapContext.mapExists(props.mapId) || initializedRef.current) return; // the MapLibre-gl instance (mapContext.getMap(props.mapId)) is accessible here
5917
+ // initialize the layer and add it to the MapLibre-gl instance or do something else with it
5918
+
5919
+ initializedRef.current = true;
5920
+ mapRef.current = mapContext.getMap(props.mapId);
5921
+ }, [mapContext.mapIds, mapContext, props.mapId]);
5922
+ useEffect(function () {
5923
+ var _mapRef$current;
5924
+
5925
+ if (!((_mapRef$current = mapRef.current) !== null && _mapRef$current !== void 0 && _mapRef$current.project)) return;
5926
+
5927
+ var _pixelPos = mapRef.current.project([props.lng, props.lat]);
5928
+
5929
+ setMarkerPixelPos(_pixelPos);
5930
+ }, [props.lng, props.lat, mapState.viewport]);
5931
+ useEffect(function () {
5932
+ var _iframe$current, _iframe$current$conte, _iframe$current$conte2, _iframe$current$conte3;
5933
+
5934
+ if (mapRef.current && (_iframe$current = iframe.current) !== null && _iframe$current !== void 0 && (_iframe$current$conte = _iframe$current.contentWindow) !== null && _iframe$current$conte !== void 0 && (_iframe$current$conte2 = _iframe$current$conte.document) !== null && _iframe$current$conte2 !== void 0 && (_iframe$current$conte3 = _iframe$current$conte2.body) !== null && _iframe$current$conte3 !== void 0 && _iframe$current$conte3.scrollHeight) {
5935
+ setTimeout(function () {
5936
+ var _iframe$current2, _iframe$current2$cont, _iframe$current2$cont2, _iframe$current2$cont3, _iframe$current3, _iframe$current3$cont, _iframe$current3$cont2, _iframe$current3$cont3;
5937
+
5938
+ var mapHeight = mapRef.current._container.clientHeight;
5939
+
5940
+ var _pixelPos = mapRef.current.project([props.lng, props.lat]);
5941
+
5942
+ var pixelToBottom = mapHeight - _pixelPos.y;
5943
+ var iframeHeight = (_iframe$current2 = iframe.current) === null || _iframe$current2 === void 0 ? void 0 : (_iframe$current2$cont = _iframe$current2.contentWindow) === null || _iframe$current2$cont === void 0 ? void 0 : (_iframe$current2$cont2 = _iframe$current2$cont.document) === null || _iframe$current2$cont2 === void 0 ? void 0 : (_iframe$current2$cont3 = _iframe$current2$cont2.body) === null || _iframe$current2$cont3 === void 0 ? void 0 : _iframe$current2$cont3.scrollHeight;
5944
+ var iframeWidth = (_iframe$current3 = iframe.current) === null || _iframe$current3 === void 0 ? void 0 : (_iframe$current3$cont = _iframe$current3.contentWindow) === null || _iframe$current3$cont === void 0 ? void 0 : (_iframe$current3$cont2 = _iframe$current3$cont.document) === null || _iframe$current3$cont2 === void 0 ? void 0 : (_iframe$current3$cont3 = _iframe$current3$cont2.body) === null || _iframe$current3$cont3 === void 0 ? void 0 : _iframe$current3$cont3.scrollWidth;
5945
+ setIframeDimensions({
5946
+ width: iframeWidth,
5947
+ height: pixelToBottom < iframeHeight ? pixelToBottom : iframeHeight
5948
+ });
5949
+ }, 100);
5950
+ }
5951
+ }, [props.lng, props.lat, props.content]);
5952
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(MlGeoJsonLayer, {
5953
+ geojson: {
5954
+ type: "Feature",
5955
+ geometry: {
5956
+ type: "Point",
5957
+ coordinates: [props.lng, props.lat]
5958
+ },
5959
+ properties: {}
5960
+ },
5961
+ paint: {
5962
+ "circle-radius": 14,
5963
+ "circle-color": "rgba(40,200,20,0.5)"
5964
+ },
5965
+ type: "circle",
5966
+ mapId: props.mapId
5967
+ }), markerPixelPos && /*#__PURE__*/React__default.createElement(Paper, {
5968
+ sx: {
5969
+ opacity: 0.7,
5970
+ position: "fixed",
5971
+ display: "flex",
5972
+
5973
+ /** TODO: fix positioning delay when moving the map */
5974
+ left: markerPixelPos.x,
5975
+ top: markerPixelPos.y,
5976
+ width: iframeDimensions.width,
5977
+ height: iframeDimensions.height,
5978
+ "&:hover": {
5979
+ opacity: 1
5980
+ },
5981
+ zIndex: -1
5982
+ }
5983
+ }, /*#__PURE__*/React__default.createElement("iframe", {
5984
+ style: {
5985
+ width: "100%"
5986
+ },
5987
+ srcDoc: props.content,
5988
+ ref: iframe,
5989
+ sandbox: "allow-same-origin allow-popups-to-escape-sandbox",
5990
+ frameBorder: "0",
5991
+ title: componentId.current
5992
+ })));
5993
+ };
5994
+
5995
+ MlMarker.defaultProps = {
5996
+ mapId: undefined
5997
+ };
5998
+ MlMarker.propTypes = {
5999
+ /**
6000
+ * Id of the target MapLibre instance in mapContext
6001
+ */
6002
+ mapId: PropTypes.string,
6003
+
6004
+ /**
6005
+ * Longitude of the marker position
6006
+ */
6007
+ lng: PropTypes.number,
6008
+
6009
+ /**
6010
+ * Latitude of the marker position
6011
+ */
6012
+ lat: PropTypes.number,
6013
+
6014
+ /**
6015
+ * Content of the description popup
6016
+ */
6017
+ content: PropTypes.string
6018
+ };
6019
+
6020
+ function useWms(props) {
6021
+ // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
6022
+ var _useState = useState(undefined),
6023
+ _useState2 = _slicedToArray(_useState, 2),
6024
+ getFeatureInfoUrl = _useState2[0],
6025
+ setGetFeatureInfoUrl = _useState2[1];
6026
+
6027
+ var _useState3 = useState(props.url),
6028
+ _useState4 = _slicedToArray(_useState3, 2),
6029
+ url = _useState4[0],
6030
+ setUrl = _useState4[1];
6031
+
6032
+ var _useState5 = useState(""),
6033
+ _useState6 = _slicedToArray(_useState5, 2),
6034
+ wmsUrl = _useState6[0],
6035
+ setWmsUrl = _useState6[1];
6036
+
6037
+ var _useState7 = useState(undefined),
6038
+ _useState8 = _slicedToArray(_useState7, 2),
6039
+ capabilities = _useState8[0],
6040
+ setCapabilities = _useState8[1];
6041
+
6042
+ var _useState9 = useState(undefined),
6043
+ _useState10 = _slicedToArray(_useState9, 2),
6044
+ error = _useState10[0],
6045
+ setError = _useState10[1];
6046
+
6047
+ var clearState = function clearState() {
6048
+ setGetFeatureInfoUrl(undefined);
6049
+ setCapabilities(undefined); //setLayers([]);
6050
+
6051
+ setWmsUrl("");
6052
+ };
6053
+
6054
+ useEffect(function () {
6055
+ var _propsUrlParams2;
6056
+
6057
+ // extract URL parameters from the given URL
6058
+ clearState();
6059
+ setError(undefined);
6060
+ if (!url) return;
6061
+
6062
+ var _propsUrlParams;
6063
+
6064
+ var _wmsUrl = url;
6065
+
6066
+ if (url.indexOf("?") !== -1) {
6067
+ _propsUrlParams = url.split("?");
6068
+ _wmsUrl = _propsUrlParams[0];
6069
+ }
6070
+
6071
+ var _urlParamsFromUrl = new URLSearchParams((_propsUrlParams2 = _propsUrlParams) === null || _propsUrlParams2 === void 0 ? void 0 : _propsUrlParams2[1]);
6072
+
6073
+ var urlParamsObj = _objectSpread2(_objectSpread2({}, Object.fromEntries(_urlParamsFromUrl)), props.urlParameters); // create URLSearchParams object to assemble the URL Parameters
6074
+
6075
+
6076
+ var urlParams = new URLSearchParams(urlParamsObj);
6077
+ var urlParamsStr = decodeURIComponent(urlParams.toString()) + "".replace(/%2F/g, "/").replace(/%3A/g, ":");
6078
+ fetch(_wmsUrl + "?" + urlParamsStr).then(function (res) {
6079
+ if (!res.ok) {
6080
+ throw Error(res.statusText + " (" + res.status + " - " + res.type + ")");
6081
+ } else {
6082
+ return res.text();
6083
+ }
6084
+ }).then(function (data) {
6085
+ setCapabilities(new WMSCapabilities(data).toJSON());
6086
+ }).catch(function (error) {
6087
+ //reset local state
6088
+ clearState();
6089
+ console.log(error);
6090
+ setError(error.message);
6091
+ });
6092
+ }, [url, props.urlParameters]);
6093
+ useEffect(function () {
6094
+ var _capabilities$Capabil, _capabilities$Capabil2, _capabilities$Capabil3, _capabilities$Capabil4, _capabilities$Capabil5, _capabilities$Capabil6, _capabilities$Capabil7, _capabilities$Capabil8, _capabilities$Capabil9, _capabilities$Capabil10, _capabilities$Capabil11, _capabilities$Capabil12, _capabilities$Capabil13, _capabilities$Capabil14;
6095
+
6096
+ if (!(capabilities !== null && capabilities !== void 0 && capabilities.Service)) return;
6097
+ setWmsUrl((_capabilities$Capabil = capabilities.Capability) === null || _capabilities$Capabil === void 0 ? void 0 : (_capabilities$Capabil2 = _capabilities$Capabil.Request) === null || _capabilities$Capabil2 === void 0 ? void 0 : (_capabilities$Capabil3 = _capabilities$Capabil2.GetMap) === null || _capabilities$Capabil3 === void 0 ? void 0 : (_capabilities$Capabil4 = _capabilities$Capabil3.DCPType) === null || _capabilities$Capabil4 === void 0 ? void 0 : (_capabilities$Capabil5 = _capabilities$Capabil4[0]) === null || _capabilities$Capabil5 === void 0 ? void 0 : (_capabilities$Capabil6 = _capabilities$Capabil5.HTTP) === null || _capabilities$Capabil6 === void 0 ? void 0 : (_capabilities$Capabil7 = _capabilities$Capabil6.Get) === null || _capabilities$Capabil7 === void 0 ? void 0 : _capabilities$Capabil7.OnlineResource); // set getFeatureInfo url
6098
+
6099
+ setGetFeatureInfoUrl((_capabilities$Capabil8 = capabilities.Capability) === null || _capabilities$Capabil8 === void 0 ? void 0 : (_capabilities$Capabil9 = _capabilities$Capabil8.Request) === null || _capabilities$Capabil9 === void 0 ? void 0 : (_capabilities$Capabil10 = _capabilities$Capabil9.GetFeatureInfo) === null || _capabilities$Capabil10 === void 0 ? void 0 : (_capabilities$Capabil11 = _capabilities$Capabil10.DCPType) === null || _capabilities$Capabil11 === void 0 ? void 0 : (_capabilities$Capabil12 = _capabilities$Capabil11[0]) === null || _capabilities$Capabil12 === void 0 ? void 0 : (_capabilities$Capabil13 = _capabilities$Capabil12.HTTP) === null || _capabilities$Capabil13 === void 0 ? void 0 : (_capabilities$Capabil14 = _capabilities$Capabil13.Get) === null || _capabilities$Capabil14 === void 0 ? void 0 : _capabilities$Capabil14.OnlineResource);
6100
+ }, [capabilities]);
6101
+ return {
6102
+ capabilities: capabilities,
6103
+ getFeatureInfoUrl: getFeatureInfoUrl,
6104
+ wmsUrl: wmsUrl,
6105
+ error: error,
6106
+ setUrl: setUrl
6107
+ };
6108
+ }
6109
+
6110
+ useWms.defaultProps = {
6111
+ url: "",
6112
+ urlParameters: {
6113
+ SERVICE: "WMS",
6114
+ VERSION: "1.3.0",
6115
+ REQUEST: "getCapabilities"
6116
+ }
6117
+ };
6118
+
6119
+ export { GeoJsonContext, GeoJsonProvider, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlFollowGps, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlMarker, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlSpatialElevationProfile, MlTransitionGeoJsonLayer, MlVectorTileLayer, MlWmsLayer, useMap, useMapState, useWms };
5558
6120
  //# sourceMappingURL=index.esm.js.map