@mapcomponents/react-maplibre 0.1.36 → 0.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.js +1 -0
- package/CHANGELOG.md +12 -0
- package/coverage/clover.xml +435 -351
- package/coverage/coverage-final.json +29 -26
- package/coverage/lcov-report/index.html +74 -59
- package/coverage/lcov-report/src/components/MapLibreMap/MapLibreMap.tsx.html +75 -27
- package/coverage/lcov-report/src/components/MapLibreMap/index.html +13 -13
- package/coverage/lcov-report/src/components/MlCreatePdfButton/MlCreatePdfButton.tsx.html +9 -9
- package/coverage/lcov-report/src/components/MlCreatePdfButton/index.html +11 -11
- package/coverage/lcov-report/src/components/MlFeatureEditor/MlFeatureEditor.tsx.html +3 -6
- package/coverage/lcov-report/src/components/MlFeatureEditor/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/MlFillExtrusionLayer.tsx.html +3 -3
- package/coverage/lcov-report/src/components/MlFillExtrusionLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlFollowGps/MlFollowGps.tsx.html +3 -3
- package/coverage/lcov-report/src/components/MlFollowGps/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGPXViewer/MlGPXViewer.tsx.html +3 -3
- package/coverage/lcov-report/src/components/MlGPXViewer/gpxConverter.js.html +8 -8
- package/coverage/lcov-report/src/components/MlGPXViewer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/MlGeoJsonLayer.tsx.html +2 -2
- package/coverage/lcov-report/src/components/MlGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/MlImageMarkerLayer.tsx.html +2 -2
- package/coverage/lcov-report/src/components/MlImageMarkerLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayer/MlLayer.tsx.html +2 -2
- package/coverage/lcov-report/src/components/MlLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerMagnify/MlLayerMagnify.tsx.html +15 -27
- package/coverage/lcov-report/src/components/MlLayerMagnify/index.html +18 -18
- package/coverage/lcov-report/src/components/MlLayerSwipe/MlLayerSwipe.tsx.html +13 -28
- package/coverage/lcov-report/src/components/MlLayerSwipe/index.html +19 -19
- package/coverage/lcov-report/src/components/MlLayerSwitcher/MlLayerSwitcher.js.html +2 -2
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/LayerBox.js.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/components/index.html +1 -1
- package/coverage/lcov-report/src/components/MlLayerSwitcher/index.html +1 -1
- package/coverage/lcov-report/src/components/MlMarker/MlMarker.tsx.html +9 -9
- package/coverage/lcov-report/src/components/MlMarker/index.html +11 -11
- package/coverage/lcov-report/src/components/MlNavigationCompass/MlNavigationCompass.tsx.html +6 -6
- package/coverage/lcov-report/src/components/MlNavigationCompass/index.html +1 -1
- package/coverage/lcov-report/src/components/MlNavigationTools/MlNavigationTools.tsx.html +7 -7
- package/coverage/lcov-report/src/components/MlNavigationTools/index.html +11 -11
- package/coverage/lcov-report/src/components/MlOsmLayer/MlOsmLayer.js.html +3 -3
- package/coverage/lcov-report/src/components/MlOsmLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/MlScaleReference.js.html +1 -1
- package/coverage/lcov-report/src/components/MlScaleReference/index.html +1 -1
- package/coverage/lcov-report/src/components/MlShareMapState/MlShareMapState.js.html +2 -2
- package/coverage/lcov-report/src/components/MlShareMapState/index.html +1 -1
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js.html +9 -36
- package/coverage/lcov-report/src/components/MlSpatialElevationProfile/index.html +1 -1
- package/coverage/lcov-report/src/components/MlThreeJsLayer/MlThreeJsLayer.js.html +2 -2
- package/coverage/lcov-report/src/components/MlThreeJsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.tsx.html +3 -3
- package/coverage/lcov-report/src/components/MlTransitionGeoJsonLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/MlUseMapDebugger.js.html +1 -1
- package/coverage/lcov-report/src/components/MlUseMapDebugger/index.html +1 -1
- package/coverage/lcov-report/src/components/MlVectorTileLayer/MlVectorTileLayer.tsx.html +3 -3
- package/coverage/lcov-report/src/components/MlVectorTileLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js.html +2 -2
- package/coverage/lcov-report/src/components/MlWmsFeatureInfoPopup/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLayer/MlWmsLayer.tsx.html +5 -5
- package/coverage/lcov-report/src/components/MlWmsLayer/index.html +1 -1
- package/coverage/lcov-report/src/components/MlWmsLoader/MlWmsLoader.tsx.html +3 -6
- package/coverage/lcov-report/src/components/MlWmsLoader/index.html +1 -1
- package/coverage/lcov-report/src/contexts/MapContext.tsx.html +358 -0
- package/coverage/lcov-report/src/contexts/SimpleDataContext.js.html +103 -0
- package/coverage/lcov-report/src/contexts/SimpleDataProvider.js.html +277 -0
- package/coverage/lcov-report/src/contexts/index.html +146 -0
- package/coverage/lcov-report/src/hooks/index.html +11 -11
- package/coverage/lcov-report/src/hooks/useLayer.ts.html +15 -126
- package/coverage/lcov-report/src/hooks/useMap.ts.html +13 -61
- package/coverage/lcov-report/src/hooks/useMapState.ts.html +6 -6
- package/coverage/lcov-report/src/hooks/useWms.js.html +7 -7
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +15 -3
- package/coverage/lcov.info +790 -615
- package/dist/index.esm.js +187 -59
- package/dist/index.esm.js.map +1 -1
- package/docs-build/{0.fd1aa3ea21956d993519.manager.bundle.js → 0.20735a16c2ad9677fe7d.manager.bundle.js} +1 -1
- package/docs-build/{0.d0c23b79.iframe.bundle.js → 0.93d0ce3d.iframe.bundle.js} +2 -2
- package/docs-build/0.93d0ce3d.iframe.bundle.js.map +1 -0
- package/docs-build/{1.34075652.iframe.bundle.js → 1.2b1ae3fa.iframe.bundle.js} +2 -2
- package/docs-build/1.2b1ae3fa.iframe.bundle.js.map +1 -0
- package/docs-build/{16.ca488dae.iframe.bundle.js → 16.2c8135a1.iframe.bundle.js} +2 -2
- package/docs-build/16.2c8135a1.iframe.bundle.js.map +1 -0
- package/docs-build/{17.e40eac7f.iframe.bundle.js → 17.9a16865a.iframe.bundle.js} +2 -2
- package/docs-build/17.9a16865a.iframe.bundle.js.map +1 -0
- package/docs-build/{18.62af0912.iframe.bundle.js → 18.4c47f37e.iframe.bundle.js} +2 -2
- package/docs-build/18.4c47f37e.iframe.bundle.js.map +1 -0
- package/docs-build/{19.0a217189.iframe.bundle.js → 19.cdf25e28.iframe.bundle.js} +2 -2
- package/docs-build/19.cdf25e28.iframe.bundle.js.map +1 -0
- package/docs-build/{2.f15ae19a.iframe.bundle.js → 2.4518b817.iframe.bundle.js} +2 -2
- package/docs-build/2.4518b817.iframe.bundle.js.map +1 -0
- package/docs-build/{4.f741dafe1833630ec8bf.manager.bundle.js → 4.8ac31bba1926f4f011b0.manager.bundle.js} +2 -2
- package/docs-build/{4.f741dafe1833630ec8bf.manager.bundle.js.LICENSE.txt → 4.8ac31bba1926f4f011b0.manager.bundle.js.LICENSE.txt} +0 -0
- package/docs-build/{5.d4de191e7daeefb036ca.manager.bundle.js → 5.daf044a6c0f55d839078.manager.bundle.js} +1 -1
- package/docs-build/{6.2b178c5444648ee5c0fa.manager.bundle.js → 6.99fba2cf6af0473f8209.manager.bundle.js} +2 -2
- package/docs-build/{6.2b178c5444648ee5c0fa.manager.bundle.js.LICENSE.txt → 6.99fba2cf6af0473f8209.manager.bundle.js.LICENSE.txt} +0 -0
- package/docs-build/{7.7c16aea8ec7ea6e91994.manager.bundle.js → 7.b6a48b90f61cb575c2e4.manager.bundle.js} +1 -1
- package/docs-build/{8.52fa838fdf937b29676a.manager.bundle.js → 8.50518a5391398d9d5812.manager.bundle.js} +1 -1
- package/docs-build/assets/3D/godzilla_simple.glb +0 -0
- package/docs-build/catalogue/mc_meta.json +1 -1
- package/docs-build/iframe.html +1 -1
- package/docs-build/index.html +1 -1
- package/docs-build/{main.8a7ec710ea1c16b5e13f.manager.bundle.js → main.ef9704b1252e8efa56a0.manager.bundle.js} +1 -1
- package/docs-build/main~24120820.e0a66582.iframe.bundle.js +2 -0
- package/docs-build/main~24120820.e0a66582.iframe.bundle.js.map +1 -0
- package/docs-build/{runtime~main.67aa1de2d72f40a81164.manager.bundle.js → runtime~main.6e6ed7dc9ea4785ef286.manager.bundle.js} +1 -1
- package/docs-build/stories.json +416 -168
- package/docs-build/vendors~main.4b570b3072ba06ee44b5.manager.bundle.js +2 -0
- package/docs-build/{vendors~main.351900838c49e9200954.manager.bundle.js.LICENSE.txt → vendors~main.4b570b3072ba06ee44b5.manager.bundle.js.LICENSE.txt} +27 -24
- package/docs-build/{vendors~main~0ad7406a.a6abfed7.iframe.bundle.js → vendors~main~0ad7406a.22b96f8e.iframe.bundle.js} +2 -2
- package/docs-build/vendors~main~0ad7406a.22b96f8e.iframe.bundle.js.map +1 -0
- package/docs-build/{vendors~main~0f485567.1d7a15b7.iframe.bundle.js → vendors~main~0f485567.df27e62a.iframe.bundle.js} +2 -2
- package/docs-build/vendors~main~0f485567.df27e62a.iframe.bundle.js.map +1 -0
- package/docs-build/{vendors~main~41a6ab2c.525ecc56.iframe.bundle.js → vendors~main~41a6ab2c.7f3a1ced.iframe.bundle.js} +2 -2
- package/docs-build/vendors~main~41a6ab2c.7f3a1ced.iframe.bundle.js.map +1 -0
- package/docs-build/{vendors~main~73914085.227c6747.iframe.bundle.js → vendors~main~73914085.3d4f5bbf.iframe.bundle.js} +4 -4
- package/docs-build/{vendors~main~73914085.227c6747.iframe.bundle.js.map → vendors~main~73914085.3d4f5bbf.iframe.bundle.js.map} +1 -1
- package/docs-build/{vendors~main~9c5b28f6.f02cc741.iframe.bundle.js → vendors~main~9c5b28f6.f8614bdc.iframe.bundle.js} +3 -3
- package/docs-build/vendors~main~9c5b28f6.f8614bdc.iframe.bundle.js.map +1 -0
- package/docs-build/{vendors~main~b5906859.4083ac60.iframe.bundle.js → vendors~main~b5906859.b606e812.iframe.bundle.js} +3 -3
- package/docs-build/vendors~main~b5906859.b606e812.iframe.bundle.js.map +1 -0
- package/docs-build/vendors~main~b9cf3951.a6200a51.iframe.bundle.js +63 -0
- package/docs-build/vendors~main~b9cf3951.a6200a51.iframe.bundle.js.map +1 -0
- package/docs-build/{vendors~main~d939e436.92c27fbf.iframe.bundle.js → vendors~main~d939e436.aa5d1533.iframe.bundle.js} +2 -2
- package/docs-build/vendors~main~d939e436.aa5d1533.iframe.bundle.js.map +1 -0
- package/docs-build/{vendors~main~dab50aa4.b0d58038.iframe.bundle.js → vendors~main~dab50aa4.277284e0.iframe.bundle.js} +4 -4
- package/docs-build/{vendors~main~dab50aa4.b0d58038.iframe.bundle.js.map → vendors~main~dab50aa4.277284e0.iframe.bundle.js.map} +1 -1
- package/package.json +17 -15
- package/rollup.config.js +5 -6
- package/src/components/MapLibreMap/MapLibreMap.stories.js +1 -1
- package/src/components/MapLibreMap/MapLibreMap.test.js +1 -1
- package/src/components/MapLibreMap/MapLibreMap.tsx +32 -16
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.test.js +1 -1
- package/src/components/MapLibreMap/lib/MapLibreGlWrapper.ts +2 -2
- package/src/components/MlBasicComponent.js +4 -1
- package/src/components/MlFeatureEditor/MlFeatureEditor.test.js +1 -1
- package/src/components/MlFeatureEditor/MlFeatureEditor.tsx +0 -1
- package/src/components/MlFollowGps/MlFollowGps.test.js +1 -1
- package/src/components/MlLayer/MlLayer.test.js +1 -1
- package/src/components/MlLayerMagnify/MlLayerMagnify.test.js +1 -1
- package/src/components/MlLayerMagnify/MlLayerMagnify.tsx +3 -7
- package/src/components/MlLayerSwipe/MlLayerSwipe.test.js +1 -1
- package/src/components/MlLayerSwipe/MlLayerSwipe.tsx +2 -7
- package/src/components/MlLayerSwitcher/MlLayerSwitcher.js +1 -1
- package/src/components/MlNavigationCompass/MlNavigationCompass.test.js +1 -1
- package/src/components/MlShareMapState/MlShareMapState.js +1 -1
- package/src/components/MlSpatialElevationProfile/MlSpatialElevationProfile.js +4 -13
- package/src/components/MlThreeJsLayer/MlThreeJsLayer.js +1 -1
- package/src/components/MlTransitionGeoJsonLayer/MlTransitionGeoJsonLayer.stories.js +1 -1
- package/src/components/MlWmsFeatureInfoPopup/MlWmsFeatureInfoPopup.js +1 -1
- package/src/components/MlWmsLoader/MlWmsLoader.tsx +1 -2
- package/src/contexts/MapComponentsProvider.test.js +260 -0
- package/src/contexts/MapContext.tsx +92 -0
- package/src/contexts/SimpleDataContext.js +6 -0
- package/src/contexts/SimpleDataProvider.js +64 -0
- package/src/contexts/SimpleDataProvider.test.js +68 -0
- package/src/custom.d.tsx +1 -1
- package/src/decorators/MapContextDecorator.js +1 -1
- package/src/decorators/MultiMapContextDecorator.js +1 -1
- package/src/hooks/useLayer.ts +12 -49
- package/src/hooks/useMap.ts +9 -26
- package/src/hooks/useMapState.ts +3 -3
- package/src/index.ts +5 -1
- package/src/ui_components/LoadingOverlayContext.js +1 -1
- package/src/util/layerRemovalTest.js +1 -1
- package/src/util/sourceRemovalTest.js +1 -1
- package/docs-build/0.d0c23b79.iframe.bundle.js.map +0 -1
- package/docs-build/1.34075652.iframe.bundle.js.map +0 -1
- package/docs-build/16.ca488dae.iframe.bundle.js.map +0 -1
- package/docs-build/17.e40eac7f.iframe.bundle.js.map +0 -1
- package/docs-build/18.62af0912.iframe.bundle.js.map +0 -1
- package/docs-build/19.0a217189.iframe.bundle.js.map +0 -1
- package/docs-build/2.f15ae19a.iframe.bundle.js.map +0 -1
- package/docs-build/main~24120820.ba6665a8.iframe.bundle.js +0 -2
- package/docs-build/main~24120820.ba6665a8.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main.351900838c49e9200954.manager.bundle.js +0 -2
- package/docs-build/vendors~main~0ad7406a.a6abfed7.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~0f485567.1d7a15b7.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~41a6ab2c.525ecc56.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~9c5b28f6.f02cc741.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~b5906859.4083ac60.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~b9cf3951.45da142d.iframe.bundle.js +0 -68
- package/docs-build/vendors~main~b9cf3951.45da142d.iframe.bundle.js.map +0 -1
- package/docs-build/vendors~main~d939e436.92c27fbf.iframe.bundle.js.map +0 -1
- package/public/stories.json +0 -331
package/dist/index.esm.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { useRef, useContext, useEffect,
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import 'd3';
|
|
2
|
+
import React__default, { useState, useRef, useContext, useEffect, useCallback, Children, isValidElement, cloneElement, useMemo } from 'react';
|
|
5
3
|
import { Map as Map$1, Popup } from 'maplibre-gl';
|
|
6
4
|
import { v4 } from 'uuid';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
7
6
|
import jsPDF from 'jspdf';
|
|
8
7
|
import styled$3 from '@emotion/styled';
|
|
9
8
|
import { keyframes } from '@emotion/react';
|
|
@@ -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,19 +108,84 @@ function __makeTemplateObject(cooked, raw) {
|
|
|
108
108
|
return cooked;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
var MapContext =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
var
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
(
|
|
122
|
-
|
|
123
|
-
});
|
|
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
|
+
};
|
|
124
189
|
|
|
125
190
|
/**
|
|
126
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.
|
|
@@ -664,6 +729,23 @@ var defaultProps$2 = {
|
|
|
664
729
|
options: {
|
|
665
730
|
center: { lng: 8.607, lat: 53.1409349 },
|
|
666
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
|
+
},
|
|
667
749
|
},
|
|
668
750
|
};
|
|
669
751
|
/**
|
|
@@ -678,10 +760,10 @@ var defaultProps$2 = {
|
|
|
678
760
|
*/
|
|
679
761
|
var MapLibreMap = function (props) {
|
|
680
762
|
var map = useRef(null);
|
|
681
|
-
var mapContainer = useRef(
|
|
763
|
+
var mapContainer = useRef();
|
|
682
764
|
var mapContext = useContext(MapContext);
|
|
683
765
|
var mapIdRef = useRef(props.mapId);
|
|
684
|
-
var
|
|
766
|
+
var initializedRef = useRef(false);
|
|
685
767
|
useEffect(function () {
|
|
686
768
|
var mapId = mapIdRef.current;
|
|
687
769
|
return function () {
|
|
@@ -692,10 +774,12 @@ var MapLibreMap = function (props) {
|
|
|
692
774
|
};
|
|
693
775
|
}, []);
|
|
694
776
|
useEffect(function () {
|
|
777
|
+
if (initializedRef.current)
|
|
778
|
+
return;
|
|
695
779
|
if (mapContainer.current) {
|
|
780
|
+
initializedRef.current = true;
|
|
696
781
|
map.current = new MapLibreGlWrapper({
|
|
697
|
-
|
|
698
|
-
mapOptions: __assign({ container: mapContainer.current }, mapOptions),
|
|
782
|
+
mapOptions: __assign({ style: '', container: mapContainer.current }, props.options),
|
|
699
783
|
onReady: function (map, wrapper) {
|
|
700
784
|
map.once("load", function () {
|
|
701
785
|
if (props.mapId) {
|
|
@@ -708,9 +792,8 @@ var MapLibreMap = function (props) {
|
|
|
708
792
|
},
|
|
709
793
|
});
|
|
710
794
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
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 });
|
|
714
797
|
};
|
|
715
798
|
MapLibreMap.defaultProps = defaultProps$2;
|
|
716
799
|
|
|
@@ -895,22 +978,15 @@ function useMap(props) {
|
|
|
895
978
|
// initialize the layer and add it to the MapLibre-gl instance or do something else with it
|
|
896
979
|
initializedRef.current = true;
|
|
897
980
|
mapRef.current = mapContext.getMap(props.mapId);
|
|
898
|
-
// @ts-ignore
|
|
899
981
|
setMap(mapRef.current);
|
|
900
982
|
setMapIsReady(true);
|
|
901
|
-
}, [
|
|
902
|
-
mapContext.mapIds,
|
|
903
|
-
mapState.layers,
|
|
904
|
-
mapContext,
|
|
905
|
-
props.waitForLayer,
|
|
906
|
-
props.mapId,
|
|
907
|
-
]);
|
|
983
|
+
}, [mapContext.mapIds, mapState.layers, mapContext, props.waitForLayer, props.mapId]);
|
|
908
984
|
return {
|
|
909
985
|
map: map,
|
|
910
986
|
mapIsReady: mapIsReady,
|
|
911
987
|
componentId: componentId.current,
|
|
912
988
|
layers: mapState.layers,
|
|
913
|
-
cleanup: cleanup
|
|
989
|
+
cleanup: cleanup,
|
|
914
990
|
};
|
|
915
991
|
}
|
|
916
992
|
|
|
@@ -12094,7 +12170,6 @@ var MlFeatureEditor = function (props) {
|
|
|
12094
12170
|
var _a;
|
|
12095
12171
|
if (draw.current &&
|
|
12096
12172
|
((_a = props.geojson) === null || _a === void 0 ? void 0 : _a.geometry)) {
|
|
12097
|
-
// @ts-ignore
|
|
12098
12173
|
draw.current.set({ type: "FeatureCollection", features: [props.geojson] });
|
|
12099
12174
|
}
|
|
12100
12175
|
}, [props.geojson, drawToolsReady]);
|
|
@@ -12137,8 +12212,7 @@ function useLayer(props) {
|
|
|
12137
12212
|
var layerLayoutConfRef = useRef("");
|
|
12138
12213
|
var _a = useState(), layer = _a[0], setLayer = _a[1];
|
|
12139
12214
|
var initializedRef = useRef(false);
|
|
12140
|
-
var layerId = useRef(props.layerId ||
|
|
12141
|
-
(props.idPrefix ? props.idPrefix : "Layer-") + mapHook.componentId);
|
|
12215
|
+
var layerId = useRef(props.layerId || (props.idPrefix ? props.idPrefix : "Layer-") + mapHook.componentId);
|
|
12142
12216
|
var createLayer = useCallback(function () {
|
|
12143
12217
|
var _a, _b;
|
|
12144
12218
|
if (initializedRef.current || !mapHook.map)
|
|
@@ -12189,26 +12263,22 @@ function useLayer(props) {
|
|
|
12189
12263
|
createLayer();
|
|
12190
12264
|
}, [mapHook.map, props.options, createLayer]);
|
|
12191
12265
|
useEffect(function () {
|
|
12192
|
-
var _a;
|
|
12193
|
-
if (!initializedRef.current ||
|
|
12194
|
-
!((_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)))
|
|
12195
12268
|
return;
|
|
12196
|
-
|
|
12197
|
-
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);
|
|
12198
12271
|
}, [props.geojson, mapHook.map, props.options.type]);
|
|
12199
12272
|
useEffect(function () {
|
|
12200
12273
|
var _a, _b, _c, _d, _e;
|
|
12201
|
-
if (!mapHook.map ||
|
|
12202
|
-
!((_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)) ||
|
|
12203
|
-
!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)
|
|
12204
12275
|
return;
|
|
12205
12276
|
var key;
|
|
12206
12277
|
var layoutString = JSON.stringify(props.options.layout);
|
|
12207
12278
|
if (props.options.layout && layoutString !== layerLayoutConfRef.current) {
|
|
12208
12279
|
var oldLayout = JSON.parse(layerLayoutConfRef.current);
|
|
12209
12280
|
for (key in props.options.layout) {
|
|
12210
|
-
if (((_d = props.options.layout) === null || _d === void 0 ? void 0 : _d[key]) &&
|
|
12211
|
-
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]) {
|
|
12212
12282
|
mapHook.map.map.setLayoutProperty(layerId.current, key, props.options.layout[key]);
|
|
12213
12283
|
}
|
|
12214
12284
|
}
|
|
@@ -12218,8 +12288,7 @@ function useLayer(props) {
|
|
|
12218
12288
|
if (paintString !== layerPaintConfRef.current) {
|
|
12219
12289
|
var oldPaint = JSON.parse(layerPaintConfRef.current);
|
|
12220
12290
|
for (key in props.options.paint) {
|
|
12221
|
-
if (((_e = props.options.paint) === null || _e === void 0 ? void 0 : _e[key]) &&
|
|
12222
|
-
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]) {
|
|
12223
12292
|
mapHook.map.map.setPaintProperty(layerId.current, key, props.options.paint[key]);
|
|
12224
12293
|
}
|
|
12225
12294
|
}
|
|
@@ -13466,7 +13535,7 @@ MlWmsLayer.propTypes = {
|
|
|
13466
13535
|
var MlLayerMagnify = function (props) {
|
|
13467
13536
|
var mapContext = useContext(MapContext);
|
|
13468
13537
|
var syncMoveInitializedRef = useRef(false);
|
|
13469
|
-
var syncCleanupFunctionRef = useRef(
|
|
13538
|
+
var syncCleanupFunctionRef = useRef(function () { });
|
|
13470
13539
|
var _a = useState('50'), swipeX = _a[0], setSwipeX = _a[1];
|
|
13471
13540
|
var swipeXRef = useRef('50');
|
|
13472
13541
|
var _b = useState('50'), swipeY = _b[0], setSwipeY = _b[1];
|
|
@@ -13496,10 +13565,7 @@ var MlLayerMagnify = function (props) {
|
|
|
13496
13565
|
var _onResize = onResize.current;
|
|
13497
13566
|
return function () {
|
|
13498
13567
|
window.removeEventListener("resize", _onResize);
|
|
13499
|
-
|
|
13500
|
-
// @ts-ignore
|
|
13501
|
-
syncCleanupFunctionRef.current();
|
|
13502
|
-
}
|
|
13568
|
+
syncCleanupFunctionRef.current();
|
|
13503
13569
|
};
|
|
13504
13570
|
}, []);
|
|
13505
13571
|
var onMove = useCallback(function (e) {
|
|
@@ -13625,7 +13691,7 @@ var MlLayerSwipe = function (props) {
|
|
|
13625
13691
|
var initializedRef = useRef(false);
|
|
13626
13692
|
var _a = useState(50), swipeX = _a[0], setSwipeX = _a[1];
|
|
13627
13693
|
var swipeXRef = useRef(0);
|
|
13628
|
-
var syncCleanupFunctionRef = useRef(
|
|
13694
|
+
var syncCleanupFunctionRef = useRef(function () { });
|
|
13629
13695
|
var mapExists = useCallback(function () {
|
|
13630
13696
|
if (!props.map1Id || !props.map2Id) {
|
|
13631
13697
|
return false;
|
|
@@ -13636,10 +13702,7 @@ var MlLayerSwipe = function (props) {
|
|
|
13636
13702
|
return true;
|
|
13637
13703
|
}, [mapContext, props.map1Id, props.map2Id]);
|
|
13638
13704
|
var cleanup = function () {
|
|
13639
|
-
|
|
13640
|
-
// @ts-ignore
|
|
13641
|
-
syncCleanupFunctionRef.current();
|
|
13642
|
-
}
|
|
13705
|
+
syncCleanupFunctionRef.current();
|
|
13643
13706
|
};
|
|
13644
13707
|
var onMove = useCallback(function (e) {
|
|
13645
13708
|
if (!mapExists())
|
|
@@ -13653,7 +13716,6 @@ var MlLayerSwipe = function (props) {
|
|
|
13653
13716
|
: 0);
|
|
13654
13717
|
clientX -= bounds.x;
|
|
13655
13718
|
var swipeX_tmp = parseFloat(((clientX / bounds.width) * 100).toFixed(2));
|
|
13656
|
-
console.log(swipeX_tmp);
|
|
13657
13719
|
if (swipeXRef.current !== swipeX_tmp) {
|
|
13658
13720
|
setSwipeX(swipeX_tmp);
|
|
13659
13721
|
swipeXRef.current = swipeX_tmp;
|
|
@@ -18371,6 +18433,10 @@ MlOsmLayer.propTypes = {
|
|
|
18371
18433
|
insertBeforeLayer: PropTypes.string
|
|
18372
18434
|
};
|
|
18373
18435
|
|
|
18436
|
+
/**
|
|
18437
|
+
* This component is deprecated and will be removed in the next major release
|
|
18438
|
+
*/
|
|
18439
|
+
|
|
18374
18440
|
var MlBasicComponent = function MlBasicComponent(props) {
|
|
18375
18441
|
// Use a useRef hook to reference the layer object to be able to access it later inside useEffect hooks
|
|
18376
18442
|
// without the requirement of adding it to the dependency list (ignore the false eslint exhaustive deps warning)
|
|
@@ -18498,5 +18564,67 @@ useWms.defaultProps = {
|
|
|
18498
18564
|
}
|
|
18499
18565
|
};
|
|
18500
18566
|
|
|
18501
|
-
|
|
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 };
|
|
18502
18630
|
//# sourceMappingURL=index.esm.js.map
|