@mapcomponents/react-maplibre 0.1.35 → 0.1.38

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 (183) hide show
  1. package/.storybook/main.js +1 -0
  2. package/CHANGELOG.md +10 -0
  3. package/coverage/clover.xml +435 -351
  4. package/coverage/coverage-final.json +29 -26
  5. package/coverage/lcov-report/index.html +74 -59
  6. package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +75 -27
  7. package/coverage/lcov-report/src/components/MapLibreMap/index.html +13 -13
  8. package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +9 -9
  9. package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +11 -11
  10. package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +3 -6
  11. package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
  12. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +3 -3
  13. package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
  14. package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +3 -3
  15. package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
  16. package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.html +3 -3
  17. package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +8 -8
  18. package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
  19. package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +2 -2
  20. package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
  21. package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +2 -2
  22. package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
  23. package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +2 -2
  24. package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
  25. package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +15 -27
  26. package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +18 -18
  27. package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +13 -28
  28. package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +19 -19
  29. package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +2 -2
  30. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
  31. package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
  32. package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
  33. package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +9 -9
  34. package/coverage/lcov-report/src/components/MlMarker/index.html +11 -11
  35. package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +6 -6
  36. package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
  37. package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +7 -7
  38. package/coverage/lcov-report/src/components/MlNavigationTools/index.html +11 -11
  39. package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +3 -3
  40. package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
  41. package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
  42. package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
  43. package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +2 -2
  44. package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
  45. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +9 -36
  46. package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
  47. package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +2 -2
  48. package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
  49. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +3 -3
  50. package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
  51. package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
  52. package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
  53. package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +3 -3
  54. package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
  55. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +2 -2
  56. package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
  57. package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +5 -5
  58. package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
  59. package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +3 -6
  60. package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
  61. package/coverage/lcov-report/src/contexts/MapContext.tsx.html +358 -0
  62. package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +103 -0
  63. package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +277 -0
  64. package/coverage/lcov-report/src/contexts/index.html +146 -0
  65. package/coverage/lcov-report/src/hooks/index.html +11 -11
  66. package/coverage/lcov-report/src/hooks/useLayer.ts.html +15 -126
  67. package/coverage/lcov-report/src/hooks/useMap.ts.html +13 -61
  68. package/coverage/lcov-report/src/hooks/useMapState.ts.html +6 -6
  69. package/coverage/lcov-report/src/hooks/useWms.js.html +7 -7
  70. package/coverage/lcov-report/src/index.html +1 -1
  71. package/coverage/lcov-report/src/index.ts.html +15 -3
  72. package/coverage/lcov.info +790 -615
  73. package/dist/index.esm.js +187 -45
  74. package/dist/index.esm.js.map +1 -1
  75. package/docs-build/{0.fd1aa3ea21956d993519.manager.bundle.js → 0.20735a16c2ad9677fe7d.manager.bundle.js} +1 -1
  76. package/docs-build/{0.d0c23b79.iframe.bundle.js → 0.93d0ce3d.iframe.bundle.js} +2 -2
  77. package/docs-build/0.93d0ce3d.iframe.bundle.js.map +1 -0
  78. package/docs-build/{1.34075652.iframe.bundle.js → 1.2b1ae3fa.iframe.bundle.js} +2 -2
  79. package/docs-build/1.2b1ae3fa.iframe.bundle.js.map +1 -0
  80. package/docs-build/{16.ca488dae.iframe.bundle.js → 16.2c8135a1.iframe.bundle.js} +2 -2
  81. package/docs-build/16.2c8135a1.iframe.bundle.js.map +1 -0
  82. package/docs-build/{17.e40eac7f.iframe.bundle.js → 17.9a16865a.iframe.bundle.js} +2 -2
  83. package/docs-build/17.9a16865a.iframe.bundle.js.map +1 -0
  84. package/docs-build/{18.62af0912.iframe.bundle.js → 18.4c47f37e.iframe.bundle.js} +2 -2
  85. package/docs-build/18.4c47f37e.iframe.bundle.js.map +1 -0
  86. package/docs-build/{19.0a217189.iframe.bundle.js → 19.cdf25e28.iframe.bundle.js} +2 -2
  87. package/docs-build/19.cdf25e28.iframe.bundle.js.map +1 -0
  88. package/docs-build/{2.f15ae19a.iframe.bundle.js → 2.4518b817.iframe.bundle.js} +2 -2
  89. package/docs-build/2.4518b817.iframe.bundle.js.map +1 -0
  90. package/docs-build/{4.f741dafe1833630ec8bf.manager.bundle.js → 4.8ac31bba1926f4f011b0.manager.bundle.js} +2 -2
  91. package/docs-build/{4.f741dafe1833630ec8bf.manager.bundle.js.LICENSE.txt → 4.8ac31bba1926f4f011b0.manager.bundle.js.LICENSE.txt} +0 -0
  92. package/docs-build/{5.d4de191e7daeefb036ca.manager.bundle.js → 5.daf044a6c0f55d839078.manager.bundle.js} +1 -1
  93. package/docs-build/{6.2b178c5444648ee5c0fa.manager.bundle.js → 6.99fba2cf6af0473f8209.manager.bundle.js} +2 -2
  94. package/docs-build/{6.2b178c5444648ee5c0fa.manager.bundle.js.LICENSE.txt → 6.99fba2cf6af0473f8209.manager.bundle.js.LICENSE.txt} +0 -0
  95. package/docs-build/{7.7c16aea8ec7ea6e91994.manager.bundle.js → 7.b6a48b90f61cb575c2e4.manager.bundle.js} +1 -1
  96. package/docs-build/{8.52fa838fdf937b29676a.manager.bundle.js → 8.50518a5391398d9d5812.manager.bundle.js} +1 -1
  97. package/docs-build/assets/3D/godzilla_simple.glb +0 -0
  98. package/docs-build/catalogue/mc_meta.json +1 -1
  99. package/docs-build/iframe.html +1 -1
  100. package/docs-build/index.html +1 -1
  101. package/docs-build/{main.8a7ec710ea1c16b5e13f.manager.bundle.js → main.ef9704b1252e8efa56a0.manager.bundle.js} +1 -1
  102. package/docs-build/main~24120820.e0a66582.iframe.bundle.js +2 -0
  103. package/docs-build/main~24120820.e0a66582.iframe.bundle.js.map +1 -0
  104. package/docs-build/{runtime~main.67aa1de2d72f40a81164.manager.bundle.js → runtime~main.6e6ed7dc9ea4785ef286.manager.bundle.js} +1 -1
  105. package/docs-build/stories.json +416 -168
  106. package/docs-build/vendors~main.4b570b3072ba06ee44b5.manager.bundle.js +2 -0
  107. package/docs-build/{vendors~main.351900838c49e9200954.manager.bundle.js.LICENSE.txt → vendors~main.4b570b3072ba06ee44b5.manager.bundle.js.LICENSE.txt} +27 -24
  108. package/docs-build/{vendors~main~0ad7406a.a6abfed7.iframe.bundle.js → vendors~main~0ad7406a.22b96f8e.iframe.bundle.js} +2 -2
  109. package/docs-build/vendors~main~0ad7406a.22b96f8e.iframe.bundle.js.map +1 -0
  110. package/docs-build/{vendors~main~0f485567.1d7a15b7.iframe.bundle.js → vendors~main~0f485567.df27e62a.iframe.bundle.js} +2 -2
  111. package/docs-build/vendors~main~0f485567.df27e62a.iframe.bundle.js.map +1 -0
  112. package/docs-build/{vendors~main~41a6ab2c.525ecc56.iframe.bundle.js → vendors~main~41a6ab2c.7f3a1ced.iframe.bundle.js} +2 -2
  113. package/docs-build/vendors~main~41a6ab2c.7f3a1ced.iframe.bundle.js.map +1 -0
  114. package/docs-build/{vendors~main~73914085.227c6747.iframe.bundle.js → vendors~main~73914085.3d4f5bbf.iframe.bundle.js} +4 -4
  115. package/docs-build/{vendors~main~73914085.227c6747.iframe.bundle.js.map → vendors~main~73914085.3d4f5bbf.iframe.bundle.js.map} +1 -1
  116. package/docs-build/{vendors~main~9c5b28f6.f02cc741.iframe.bundle.js → vendors~main~9c5b28f6.f8614bdc.iframe.bundle.js} +3 -3
  117. package/docs-build/vendors~main~9c5b28f6.f8614bdc.iframe.bundle.js.map +1 -0
  118. package/docs-build/{vendors~main~b5906859.4083ac60.iframe.bundle.js → vendors~main~b5906859.b606e812.iframe.bundle.js} +3 -3
  119. package/docs-build/vendors~main~b5906859.b606e812.iframe.bundle.js.map +1 -0
  120. package/docs-build/vendors~main~b9cf3951.a6200a51.iframe.bundle.js +63 -0
  121. package/docs-build/vendors~main~b9cf3951.a6200a51.iframe.bundle.js.map +1 -0
  122. package/docs-build/{vendors~main~d939e436.92c27fbf.iframe.bundle.js → vendors~main~d939e436.aa5d1533.iframe.bundle.js} +2 -2
  123. package/docs-build/vendors~main~d939e436.aa5d1533.iframe.bundle.js.map +1 -0
  124. package/docs-build/{vendors~main~dab50aa4.b0d58038.iframe.bundle.js → vendors~main~dab50aa4.277284e0.iframe.bundle.js} +4 -4
  125. package/docs-build/{vendors~main~dab50aa4.b0d58038.iframe.bundle.js.map → vendors~main~dab50aa4.277284e0.iframe.bundle.js.map} +1 -1
  126. package/package.json +18 -15
  127. package/rollup.config.js +5 -6
  128. package/src/components/MapLibreMap/MapLibreMap.stories.js +1 -1
  129. package/src/components/MapLibreMap/MapLibreMap.test.js +1 -1
  130. package/src/components/MapLibreMap/MapLibreMap.tsx +32 -16
  131. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.test.js +1 -1
  132. package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +2 -2
  133. package/src/components/MlBasicComponent.js +4 -1
  134. package/src/components/MlFeatureEditor/MlFeatureEditor.test.js +1 -1
  135. package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +0 -1
  136. package/src/components/MlFollowGps/MlFollowGps.test.js +1 -1
  137. package/src/components/MlLayer/MlLayer.test.js +1 -1
  138. package/src/components/MlLayerMagnify/MlLayerMagnify.test.js +1 -1
  139. package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +3 -7
  140. package/src/components/MlLayerSwipe/MlLayerSwipe.test.js +1 -1
  141. package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +2 -7
  142. package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +1 -1
  143. package/src/components/MlNavigationCompass/MlNavigationCompass.test.js +1 -1
  144. package/src/components/MlShareMapState/MlShareMapState.js +1 -1
  145. package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js +4 -13
  146. package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +1 -1
  147. package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.stories.js +1 -1
  148. package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js +1 -1
  149. package/src/components/MlWmsLoader/MlWmsLoader.tsx +1 -2
  150. package/src/contexts/MapComponentsProvider.test.js +260 -0
  151. package/src/contexts/MapContext.tsx +92 -0
  152. package/src/contexts/SimpleDataContext.js +6 -0
  153. package/src/contexts/SimpleDataProvider.js +64 -0
  154. package/src/contexts/SimpleDataProvider.test.js +68 -0
  155. package/src/custom.d.tsx +1 -1
  156. package/src/decorators/MapContextDecorator.js +1 -1
  157. package/src/decorators/MultiMapContextDecorator.js +1 -1
  158. package/src/hooks/useLayer.ts +12 -49
  159. package/src/hooks/useMap.ts +9 -26
  160. package/src/hooks/useMapState.ts +3 -3
  161. package/src/index.ts +5 -1
  162. package/src/ui_components/LoadingOverlayContext.js +1 -1
  163. package/src/util/layerRemovalTest.js +1 -1
  164. package/src/util/sourceRemovalTest.js +1 -1
  165. package/docs-build/0.d0c23b79.iframe.bundle.js.map +0 -1
  166. package/docs-build/1.34075652.iframe.bundle.js.map +0 -1
  167. package/docs-build/16.ca488dae.iframe.bundle.js.map +0 -1
  168. package/docs-build/17.e40eac7f.iframe.bundle.js.map +0 -1
  169. package/docs-build/18.62af0912.iframe.bundle.js.map +0 -1
  170. package/docs-build/19.0a217189.iframe.bundle.js.map +0 -1
  171. package/docs-build/2.f15ae19a.iframe.bundle.js.map +0 -1
  172. package/docs-build/main~24120820.ba6665a8.iframe.bundle.js +0 -2
  173. package/docs-build/main~24120820.ba6665a8.iframe.bundle.js.map +0 -1
  174. package/docs-build/vendors~main.351900838c49e9200954.manager.bundle.js +0 -2
  175. package/docs-build/vendors~main~0ad7406a.a6abfed7.iframe.bundle.js.map +0 -1
  176. package/docs-build/vendors~main~0f485567.1d7a15b7.iframe.bundle.js.map +0 -1
  177. package/docs-build/vendors~main~41a6ab2c.525ecc56.iframe.bundle.js.map +0 -1
  178. package/docs-build/vendors~main~9c5b28f6.f02cc741.iframe.bundle.js.map +0 -1
  179. package/docs-build/vendors~main~b5906859.4083ac60.iframe.bundle.js.map +0 -1
  180. package/docs-build/vendors~main~b9cf3951.45da142d.iframe.bundle.js +0 -68
  181. package/docs-build/vendors~main~b9cf3951.45da142d.iframe.bundle.js.map +0 -1
  182. package/docs-build/vendors~main~d939e436.92c27fbf.iframe.bundle.js.map +0 -1
  183. package/public/stories.json +0 -331
package/dist/index.esm.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { useRef, useContext, useEffect, useState, useCallback, Children, isValidElement, cloneElement, useMemo } from 'react';
3
- import { MapContext } from '@mapcomponents/react-core';
2
+ import React__default, { useState, useRef, useContext, useEffect, useCallback, Children, isValidElement, cloneElement, useMemo } from 'react';
4
3
  import { Map as Map$1, Popup } from 'maplibre-gl';
5
4
  import { v4 } from 'uuid';
6
5
  import PropTypes from 'prop-types';
@@ -16,6 +15,7 @@ import syncMove from '@mapbox/mapbox-gl-sync-move';
16
15
  import * as ReactDOM from 'react-dom';
17
16
  import ReactDOM__default from 'react-dom';
18
17
  import WMSCapabilities from 'wms-capabilities';
18
+ import * as d3 from 'd3';
19
19
 
20
20
  /*! *****************************************************************************
21
21
  Copyright (c) Microsoft Corporation.
@@ -108,6 +108,85 @@ function __makeTemplateObject(cooked, raw) {
108
108
  return cooked;
109
109
  }
110
110
 
111
+ var MapContext = React__default.createContext({});
112
+ /**
113
+ * MapComponentsProvider must be imported and wrapped around component where at least one of its child nodes requires access to a MapLibre-gl or openlayers instance that is registered in this mapContext.
114
+ MapComponentsProvider must be used one level higher than the first use of MapContext.
115
+ *
116
+ * MapComponentsProvider requires at least one use of the MapLibreMap component somewhere down the component tree that will create the MapLibre-gl object and set the reference at MapContext.map. For MapLibre maps it is a good idea to provide a mapId attribute to the MapLibreMap Component even if you are only using a single map instance at start. It will make a later transition to using multiple instances within the same project much easier.
117
+ */
118
+ var MapComponentsProvider = function (_a) {
119
+ var children = _a.children;
120
+ var _b = useState(undefined), map = _b[0], setMap = _b[1];
121
+ var _c = useState([]), mapIds = _c[0], setMapIds = _c[1];
122
+ var mapIds_raw = useRef([]);
123
+ var maps = useRef({});
124
+ var removeMap = function (mapId) {
125
+ if (mapId) {
126
+ if (typeof maps.current[mapId] !== "undefined") {
127
+ delete maps.current[mapId];
128
+ }
129
+ var mapIdIndex = mapIds_raw.current.indexOf(mapId);
130
+ if (mapIdIndex > -1) {
131
+ mapIds_raw.current.splice(mapIdIndex, 1);
132
+ }
133
+ setMapIds(__spreadArray([], mapIds_raw.current, true));
134
+ if (mapIds.length === 1 && map) {
135
+ setMap(undefined);
136
+ }
137
+ }
138
+ else {
139
+ setMap(undefined);
140
+ removeMap("anonymous_map");
141
+ }
142
+ };
143
+ var setMapHandler = function (mapInstance) {
144
+ setMap(mapInstance);
145
+ if (mapIds.length === 0) {
146
+ var mapId = "anonymous_map";
147
+ setMapIds(__spreadArray(__spreadArray([], mapIds, true), [mapId], false));
148
+ maps.current[mapId] = mapInstance;
149
+ }
150
+ };
151
+ var value = {
152
+ map: map,
153
+ setMap: setMapHandler,
154
+ maps: maps.current,
155
+ mapIds: mapIds,
156
+ registerMap: function (mapId, mapInstance) {
157
+ if (mapId && mapInstance) {
158
+ maps.current[mapId] = mapInstance;
159
+ mapIds_raw.current.push(mapId);
160
+ setMapIds(__spreadArray([], mapIds_raw.current, true));
161
+ if (!map) {
162
+ setMap(mapInstance);
163
+ }
164
+ }
165
+ },
166
+ removeMap: removeMap,
167
+ mapExists: function (mapId) {
168
+ if (mapId && Object.keys(maps.current).indexOf(mapId) === -1) {
169
+ return false;
170
+ }
171
+ else if (!mapId && !map) {
172
+ return false;
173
+ }
174
+ return true;
175
+ },
176
+ getMap: function (mapId) {
177
+ if (mapId && mapIds.indexOf(mapId) !== -1) {
178
+ return maps.current[mapId];
179
+ }
180
+ else if (!mapId && map) {
181
+ return map;
182
+ }
183
+ return null;
184
+ },
185
+ };
186
+ //@ts-ignore
187
+ return React__default.createElement(MapContext.Provider, { value: value }, children);
188
+ };
189
+
111
190
  /**
112
191
  * Creates a MapLibre-gl-js instance and offers all of the native MapLibre functions and properties as well as additional functionality such as element registration & cleanup and more events.
113
192
  *
@@ -650,6 +729,23 @@ var defaultProps$2 = {
650
729
  options: {
651
730
  center: { lng: 8.607, lat: 53.1409349 },
652
731
  zoom: 11,
732
+ container: '',
733
+ style: {
734
+ version: 8,
735
+ name: "blank",
736
+ center: [0, 0],
737
+ zoom: 0,
738
+ sources: {},
739
+ layers: [
740
+ {
741
+ id: "background",
742
+ type: "background",
743
+ paint: {
744
+ "background-color": "rgba(80,0,0,0)",
745
+ },
746
+ },
747
+ ],
748
+ },
653
749
  },
654
750
  };
655
751
  /**
@@ -664,10 +760,10 @@ var defaultProps$2 = {
664
760
  */
665
761
  var MapLibreMap = function (props) {
666
762
  var map = useRef(null);
667
- var mapContainer = useRef(null);
763
+ var mapContainer = useRef();
668
764
  var mapContext = useContext(MapContext);
669
765
  var mapIdRef = useRef(props.mapId);
670
- var mapOptions = props.options;
766
+ var initializedRef = useRef(false);
671
767
  useEffect(function () {
672
768
  var mapId = mapIdRef.current;
673
769
  return function () {
@@ -678,10 +774,12 @@ var MapLibreMap = function (props) {
678
774
  };
679
775
  }, []);
680
776
  useEffect(function () {
777
+ if (initializedRef.current)
778
+ return;
681
779
  if (mapContainer.current) {
780
+ initializedRef.current = true;
682
781
  map.current = new MapLibreGlWrapper({
683
- // @ts-ignore
684
- mapOptions: __assign({ container: mapContainer.current }, mapOptions),
782
+ mapOptions: __assign({ style: '', container: mapContainer.current }, props.options),
685
783
  onReady: function (map, wrapper) {
686
784
  map.once("load", function () {
687
785
  if (props.mapId) {
@@ -694,9 +792,8 @@ var MapLibreMap = function (props) {
694
792
  },
695
793
  });
696
794
  }
697
- // eslint-disable-next-line react-hooks/exhaustive-deps
698
- }, [mapContainer]);
699
- return (React__default.createElement("div", { ref: mapContainer, className: "mapContainer", style: props.style }));
795
+ }, [props.options, props.mapId]);
796
+ return React__default.createElement("div", { ref: mapContainer, className: "mapContainer", style: props.style });
700
797
  };
701
798
  MapLibreMap.defaultProps = defaultProps$2;
702
799
 
@@ -881,22 +978,15 @@ function useMap(props) {
881
978
  // initialize the layer and add it to the MapLibre-gl instance or do something else with it
882
979
  initializedRef.current = true;
883
980
  mapRef.current = mapContext.getMap(props.mapId);
884
- // @ts-ignore
885
981
  setMap(mapRef.current);
886
982
  setMapIsReady(true);
887
- }, [
888
- mapContext.mapIds,
889
- mapState.layers,
890
- mapContext,
891
- props.waitForLayer,
892
- props.mapId,
893
- ]);
983
+ }, [mapContext.mapIds, mapState.layers, mapContext, props.waitForLayer, props.mapId]);
894
984
  return {
895
985
  map: map,
896
986
  mapIsReady: mapIsReady,
897
987
  componentId: componentId.current,
898
988
  layers: mapState.layers,
899
- cleanup: cleanup
989
+ cleanup: cleanup,
900
990
  };
901
991
  }
902
992
 
@@ -12080,7 +12170,6 @@ var MlFeatureEditor = function (props) {
12080
12170
  var _a;
12081
12171
  if (draw.current &&
12082
12172
  ((_a = props.geojson) === null || _a === void 0 ? void 0 : _a.geometry)) {
12083
- // @ts-ignore
12084
12173
  draw.current.set({ type: "FeatureCollection", features: [props.geojson] });
12085
12174
  }
12086
12175
  }, [props.geojson, drawToolsReady]);
@@ -12123,8 +12212,7 @@ function useLayer(props) {
12123
12212
  var layerLayoutConfRef = useRef("");
12124
12213
  var _a = useState(), layer = _a[0], setLayer = _a[1];
12125
12214
  var initializedRef = useRef(false);
12126
- var layerId = useRef(props.layerId ||
12127
- (props.idPrefix ? props.idPrefix : "Layer-") + mapHook.componentId);
12215
+ var layerId = useRef(props.layerId || (props.idPrefix ? props.idPrefix : "Layer-") + mapHook.componentId);
12128
12216
  var createLayer = useCallback(function () {
12129
12217
  var _a, _b;
12130
12218
  if (initializedRef.current || !mapHook.map)
@@ -12175,26 +12263,22 @@ function useLayer(props) {
12175
12263
  createLayer();
12176
12264
  }, [mapHook.map, props.options, createLayer]);
12177
12265
  useEffect(function () {
12178
- var _a;
12179
- if (!initializedRef.current ||
12180
- !((_a = mapHook === null || mapHook === void 0 ? void 0 : mapHook.map) === null || _a === void 0 ? void 0 : _a.map.getSource(layerId.current)))
12266
+ var _a, _b, _c, _d;
12267
+ if (!initializedRef.current || !((_b = (_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.getSource(layerId.current)))
12181
12268
  return;
12182
- // @ts-ignore
12183
- mapHook.map.map.getSource(layerId.current).setData(props.geojson);
12269
+ //@ts-ignore setData only exists on GeoJsonSource
12270
+ (_d = (_c = mapHook.map.map.getSource(layerId.current)) === null || _c === void 0 ? void 0 : _c.setData) === null || _d === void 0 ? void 0 : _d.call(_c, props.geojson);
12184
12271
  }, [props.geojson, mapHook.map, props.options.type]);
12185
12272
  useEffect(function () {
12186
12273
  var _a, _b, _c, _d, _e;
12187
- if (!mapHook.map ||
12188
- !((_c = (_b = (_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.getLayer) === null || _c === void 0 ? void 0 : _c.call(_b, layerId.current)) ||
12189
- !initializedRef.current)
12274
+ if (!mapHook.map || !((_c = (_b = (_a = mapHook.map) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.getLayer) === null || _c === void 0 ? void 0 : _c.call(_b, layerId.current)) || !initializedRef.current)
12190
12275
  return;
12191
12276
  var key;
12192
12277
  var layoutString = JSON.stringify(props.options.layout);
12193
12278
  if (props.options.layout && layoutString !== layerLayoutConfRef.current) {
12194
12279
  var oldLayout = JSON.parse(layerLayoutConfRef.current);
12195
12280
  for (key in props.options.layout) {
12196
- if (((_d = props.options.layout) === null || _d === void 0 ? void 0 : _d[key]) &&
12197
- props.options.layout[key] !== oldLayout[key]) {
12281
+ if (((_d = props.options.layout) === null || _d === void 0 ? void 0 : _d[key]) && props.options.layout[key] !== oldLayout[key]) {
12198
12282
  mapHook.map.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);
12199
12283
  }
12200
12284
  }
@@ -12204,8 +12288,7 @@ function useLayer(props) {
12204
12288
  if (paintString !== layerPaintConfRef.current) {
12205
12289
  var oldPaint = JSON.parse(layerPaintConfRef.current);
12206
12290
  for (key in props.options.paint) {
12207
- if (((_e = props.options.paint) === null || _e === void 0 ? void 0 : _e[key]) &&
12208
- props.options.paint[key] !== oldPaint[key]) {
12291
+ if (((_e = props.options.paint) === null || _e === void 0 ? void 0 : _e[key]) && props.options.paint[key] !== oldPaint[key]) {
12209
12292
  mapHook.map.map.setPaintProperty(layerId.current, key, props.options.paint[key]);
12210
12293
  }
12211
12294
  }
@@ -13452,7 +13535,7 @@ MlWmsLayer.propTypes = {
13452
13535
  var MlLayerMagnify = function (props) {
13453
13536
  var mapContext = useContext(MapContext);
13454
13537
  var syncMoveInitializedRef = useRef(false);
13455
- var syncCleanupFunctionRef = useRef(null);
13538
+ var syncCleanupFunctionRef = useRef(function () { });
13456
13539
  var _a = useState('50'), swipeX = _a[0], setSwipeX = _a[1];
13457
13540
  var swipeXRef = useRef('50');
13458
13541
  var _b = useState('50'), swipeY = _b[0], setSwipeY = _b[1];
@@ -13482,10 +13565,7 @@ var MlLayerMagnify = function (props) {
13482
13565
  var _onResize = onResize.current;
13483
13566
  return function () {
13484
13567
  window.removeEventListener("resize", _onResize);
13485
- if (typeof syncCleanupFunctionRef.current === 'function') {
13486
- // @ts-ignore
13487
- syncCleanupFunctionRef.current();
13488
- }
13568
+ syncCleanupFunctionRef.current();
13489
13569
  };
13490
13570
  }, []);
13491
13571
  var onMove = useCallback(function (e) {
@@ -13611,7 +13691,7 @@ var MlLayerSwipe = function (props) {
13611
13691
  var initializedRef = useRef(false);
13612
13692
  var _a = useState(50), swipeX = _a[0], setSwipeX = _a[1];
13613
13693
  var swipeXRef = useRef(0);
13614
- var syncCleanupFunctionRef = useRef(null);
13694
+ var syncCleanupFunctionRef = useRef(function () { });
13615
13695
  var mapExists = useCallback(function () {
13616
13696
  if (!props.map1Id || !props.map2Id) {
13617
13697
  return false;
@@ -13622,10 +13702,7 @@ var MlLayerSwipe = function (props) {
13622
13702
  return true;
13623
13703
  }, [mapContext, props.map1Id, props.map2Id]);
13624
13704
  var cleanup = function () {
13625
- if (syncCleanupFunctionRef.current) {
13626
- // @ts-ignore
13627
- syncCleanupFunctionRef.current();
13628
- }
13705
+ syncCleanupFunctionRef.current();
13629
13706
  };
13630
13707
  var onMove = useCallback(function (e) {
13631
13708
  if (!mapExists())
@@ -13639,7 +13716,6 @@ var MlLayerSwipe = function (props) {
13639
13716
  : 0);
13640
13717
  clientX -= bounds.x;
13641
13718
  var swipeX_tmp = parseFloat(((clientX / bounds.width) * 100).toFixed(2));
13642
- console.log(swipeX_tmp);
13643
13719
  if (swipeXRef.current !== swipeX_tmp) {
13644
13720
  setSwipeX(swipeX_tmp);
13645
13721
  swipeXRef.current = swipeX_tmp;
@@ -18357,6 +18433,10 @@ MlOsmLayer.propTypes = {
18357
18433
  insertBeforeLayer: PropTypes.string
18358
18434
  };
18359
18435
 
18436
+ /**
18437
+ * This component is deprecated and will be removed in the next major release
18438
+ */
18439
+
18360
18440
  var MlBasicComponent = function MlBasicComponent(props) {
18361
18441
  // Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
18362
18442
  // without the requirement of adding it to the dependency list (ignore the false eslint exhaustive deps warning)
@@ -18484,5 +18564,67 @@ useWms.defaultProps = {
18484
18564
  }
18485
18565
  };
18486
18566
 
18487
- export { GeoJsonContext, GeoJsonProvider, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlFollowGps, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlMarker, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlSpatialElevationProfile, MlTransitionGeoJsonLayer, MlVectorTileLayer, MlWmsLayer, useLayer, useMap, useMapState, useWms };
18567
+ var SimpleDataContext = /*#__PURE__*/React__default.createContext({});
18568
+ var SimpleDataContextProvider = SimpleDataContext.Provider;
18569
+
18570
+ var SimpleDataProvider = function SimpleDataProvider(props) {
18571
+ var _useState = useState(null),
18572
+ _useState2 = _slicedToArray(_useState, 2),
18573
+ data = _useState2[0],
18574
+ setData = _useState2[1];
18575
+
18576
+ useEffect(function () {
18577
+ if (!props.url) return;
18578
+ var data_promise = null;
18579
+
18580
+ if (props.format === "json") {
18581
+ data_promise = d3.json(props.url);
18582
+ } else if (props.format === "csv") {
18583
+ data_promise = d3.csv(props.url);
18584
+ } else if (props.format === "xml") {
18585
+ data_promise = d3.xml(props.url);
18586
+ }
18587
+
18588
+ if (data_promise) {
18589
+ data_promise.then(function (received_data) {
18590
+ if (props.format === "xml") {
18591
+ if (props.nodeType) {
18592
+ var dataTmp = [];
18593
+ received_data.querySelectorAll(props.nodeType).forEach(function (el) {
18594
+ dataTmp.push(props.formatData(el));
18595
+ });
18596
+ setData(dataTmp);
18597
+ }
18598
+ } else {
18599
+ if (props.data_property) {
18600
+ received_data = received_data[props.data_property];
18601
+ }
18602
+
18603
+ if (typeof props.formatData === "function") {
18604
+ setData(received_data.map(props.formatData));
18605
+ } else {
18606
+ setData(received_data);
18607
+ }
18608
+ }
18609
+
18610
+ if (typeof props.onData === "function") {
18611
+ props.onData();
18612
+ }
18613
+ });
18614
+ }
18615
+ }, [props.url, props]);
18616
+ var value = {
18617
+ data: data,
18618
+ setData: setData
18619
+ };
18620
+ return /*#__PURE__*/React__default.createElement(SimpleDataContextProvider, {
18621
+ value: value
18622
+ }, props.children);
18623
+ };
18624
+
18625
+ SimpleDataProvider.propTypes = {
18626
+ children: PropTypes.node.isRequired
18627
+ };
18628
+
18629
+ export { GeoJsonContext, GeoJsonProvider, MapComponentsProvider, MapContext, MapLibreMap, MlBasicComponent, MlComponentTemplate, MlCreatePdfButton, MlFeatureEditor, MlFillExtrusionLayer, MlFollowGps, MlGPXViewer, MlGeoJsonLayer, MlImageMarkerLayer, MlLayer, MlLayerMagnify, MlLayerSwipe, MlMarker, MlNavigationCompass, MlNavigationTools, MlOsmLayer, MlSpatialElevationProfile, MlTransitionGeoJsonLayer, MlVectorTileLayer, MlWmsLayer, SimpleDataContext, SimpleDataProvider, useLayer, useMap, useMapState, useWms };
18488
18630
  //# sourceMappingURL=index.esm.js.map