@opengeoweb/webmap-react 9.35.0 → 9.35.1-spike-oltanstack.0
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/index.esm.js
CHANGED
|
@@ -6704,16 +6704,7 @@ var makeLayerPropListFromChildren = function makeLayerPropListFromChildren(child
|
|
|
6704
6704
|
return myChildren;
|
|
6705
6705
|
};
|
|
6706
6706
|
var parseWMJSLayer = function parseWMJSLayer(wmLayer, forceReload) {
|
|
6707
|
-
return
|
|
6708
|
-
var callback = function callback() {
|
|
6709
|
-
if (wmLayer.hasError) {
|
|
6710
|
-
reject(new Error(wmLayer.lastError));
|
|
6711
|
-
} else {
|
|
6712
|
-
resolve(wmLayer);
|
|
6713
|
-
}
|
|
6714
|
-
};
|
|
6715
|
-
wmLayer.parseLayer(callback, forceReload, 'ReactMapView parseWMJSLayer');
|
|
6716
|
-
});
|
|
6707
|
+
return wmLayer.parseLayer(forceReload);
|
|
6717
6708
|
};
|
|
6718
6709
|
var setWMLayerPropsBasedOnChildProps = function setWMLayerPropsBasedOnChildProps(child, wmLayer, mapViewProps) {
|
|
6719
6710
|
var needsRedraw = false;
|
|
@@ -6771,7 +6762,7 @@ var setWMLayerPropsBasedOnChildProps = function setWMLayerPropsBasedOnChildProps
|
|
|
6771
6762
|
};
|
|
6772
6763
|
var addWMLayerPropsBasedOnChildProps = function addWMLayerPropsBasedOnChildProps(child, mapId, props, onUpdateLayerInformation) {
|
|
6773
6764
|
var wmjsMap = getWMJSMapById(mapId);
|
|
6774
|
-
if (!wmjsMap) {
|
|
6765
|
+
if (!wmjsMap || wmjsMap.isDestroyed) {
|
|
6775
6766
|
return;
|
|
6776
6767
|
}
|
|
6777
6768
|
var keepOnTop = child.layerType === LayerType.overLayer || false;
|
|
@@ -6796,11 +6787,18 @@ var addWMLayerPropsBasedOnChildProps = function addWMLayerPropsBasedOnChildProps
|
|
|
6796
6787
|
if (newWMLayer.hasError === true) {
|
|
6797
6788
|
child.onLayerError && child.onLayerError(newWMLayer, new Error(newWMLayer.lastError));
|
|
6798
6789
|
}
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6790
|
+
// This ensures that MultiMapViewConnect works properly.
|
|
6791
|
+
setTimeout(function () {
|
|
6792
|
+
var wmjsMap = getWMJSMapById(mapId);
|
|
6793
|
+
if (!wmjsMap || wmjsMap.isDestroyed) {
|
|
6794
|
+
return;
|
|
6795
|
+
}
|
|
6796
|
+
setWMLayerPropsBasedOnChildProps(child, newWMLayer, props);
|
|
6797
|
+
var layerInfo = getLayerUpdateInfo(newWMLayer, mapId);
|
|
6798
|
+
onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
|
|
6799
|
+
child.onLayerReady && child.onLayerReady(newWMLayer, wmjsMap);
|
|
6800
|
+
wmjsMap.draw();
|
|
6801
|
+
}, 1);
|
|
6804
6802
|
})["catch"](function (e) {
|
|
6805
6803
|
child.onLayerError && child.onLayerError(e);
|
|
6806
6804
|
});
|
|
@@ -6897,10 +6895,6 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
|
6897
6895
|
*/
|
|
6898
6896
|
_this.onStartRefetchTimer = function (force) {
|
|
6899
6897
|
var shouldAutoFetch = _this.props.shouldAutoFetch;
|
|
6900
|
-
/* TODO, Maarten Plieger, 2021-09-02
|
|
6901
|
-
This causes many issues, we should improve the update strategy.
|
|
6902
|
-
Certain presets have >20 layers. This causes 20 times parsing the GetCapabilities for a minor update of the store.
|
|
6903
|
-
*/
|
|
6904
6898
|
_this.clearRefetchTimer();
|
|
6905
6899
|
var autoFetchInterval = Number(shouldAutoFetch); // Default true -> 1 minute
|
|
6906
6900
|
var refetch = function refetch() {
|
|
@@ -6910,20 +6904,40 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
|
6910
6904
|
var mapId = _this.props.mapId;
|
|
6911
6905
|
var wmjsMap = webmapUtils.getWMJSMapById(mapId);
|
|
6912
6906
|
var layers = wmjsMap === null || wmjsMap === void 0 ? void 0 : wmjsMap.getLayers();
|
|
6913
|
-
layers === null || layers === void 0 || layers.forEach(function (
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
|
|
6907
|
+
layers === null || layers === void 0 || layers.forEach( /*#__PURE__*/function () {
|
|
6908
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(layer) {
|
|
6909
|
+
var _this2, _props, _mapId, onUpdateLayerInformation, layerInfo;
|
|
6910
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
6911
|
+
while (1) switch (_context.prev = _context.next) {
|
|
6912
|
+
case 0:
|
|
6913
|
+
if (!(layer.enabled !== false)) {
|
|
6914
|
+
_context.next = 13;
|
|
6915
|
+
break;
|
|
6916
|
+
}
|
|
6917
|
+
_context.prev = 1;
|
|
6918
|
+
_context.next = 4;
|
|
6919
|
+
return layer.parseLayer();
|
|
6920
|
+
case 4:
|
|
6921
|
+
_this2 = _this, _props = _this2.props;
|
|
6922
|
+
_mapId = _props.mapId, onUpdateLayerInformation = _props.onUpdateLayerInformation;
|
|
6923
|
+
layerInfo = getLayerUpdateInfo(layer, _mapId);
|
|
6924
|
+
onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
|
|
6925
|
+
_context.next = 13;
|
|
6926
|
+
break;
|
|
6927
|
+
case 10:
|
|
6928
|
+
_context.prev = 10;
|
|
6929
|
+
_context.t0 = _context["catch"](1);
|
|
6930
|
+
console.error(_context.t0);
|
|
6931
|
+
case 13:
|
|
6932
|
+
case "end":
|
|
6933
|
+
return _context.stop();
|
|
6934
|
+
}
|
|
6935
|
+
}, _callee, null, [[1, 10]]);
|
|
6936
|
+
}));
|
|
6937
|
+
return function (_x) {
|
|
6938
|
+
return _ref.apply(this, arguments);
|
|
6939
|
+
};
|
|
6940
|
+
}());
|
|
6927
6941
|
}
|
|
6928
6942
|
};
|
|
6929
6943
|
if (autoFetchInterval > 0) {
|
|
@@ -7206,13 +7220,13 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
|
7206
7220
|
// ReactWMJSLayer Layer Childs: Detect all ReactLayers connected to WMJSLayers, remove WMJSLayer if there is no ReactLayer
|
|
7207
7221
|
var wmjsLayers = wmjsMap.getLayers();
|
|
7208
7222
|
var onUpdateLayerInformation = props.onUpdateLayerInformation,
|
|
7209
|
-
|
|
7223
|
+
_mapId2 = props.mapId;
|
|
7210
7224
|
wmjsLayers.forEach(function (wmLayer) {
|
|
7211
7225
|
var isWMLayerInReactMapViewChildren = myChildren.find(function (child) {
|
|
7212
7226
|
return child.id === wmLayer.ReactWMJSLayerId;
|
|
7213
7227
|
});
|
|
7214
7228
|
if (!isWMLayerInReactMapViewChildren) {
|
|
7215
|
-
removeWMLayerFromMap(wmLayer,
|
|
7229
|
+
removeWMLayerFromMap(wmLayer, _mapId2, onUpdateLayerInformation);
|
|
7216
7230
|
}
|
|
7217
7231
|
});
|
|
7218
7232
|
// ReactWMJSLayer BaseLayer Childs: For the baseLayers, detect all ReactLayers connected to WMJSLayers, remove WMJSLayer if there is no ReactLayer
|
|
@@ -7239,29 +7253,29 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
|
7239
7253
|
var layerIsInThisMap = wmjsMap.hasLayer(wmLayer);
|
|
7240
7254
|
if (!layerIsInThisMap) {
|
|
7241
7255
|
// Add a new layer, it is not in the this map
|
|
7242
|
-
addWMLayerPropsBasedOnChildProps(child,
|
|
7256
|
+
addWMLayerPropsBasedOnChildProps(child, _mapId2, props, onUpdateLayerInformation);
|
|
7243
7257
|
needsRedraw = true;
|
|
7244
7258
|
} else {
|
|
7245
7259
|
// Handle existing layer
|
|
7246
7260
|
if (child.name !== undefined && wmLayer.name !== child.name) {
|
|
7247
7261
|
// Handle layer name change
|
|
7248
|
-
wmLayer.setName(child.name).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7262
|
+
wmLayer.setName(child.name).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
7249
7263
|
var layerInfo;
|
|
7250
|
-
return _regeneratorRuntime().wrap(function
|
|
7251
|
-
while (1) switch (
|
|
7264
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
7265
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
7252
7266
|
case 0:
|
|
7253
|
-
|
|
7254
|
-
return
|
|
7267
|
+
_context2.next = 2;
|
|
7268
|
+
return wmLayer.parseLayer();
|
|
7255
7269
|
case 2:
|
|
7256
|
-
layerInfo = getLayerUpdateInfo(wmLayer,
|
|
7270
|
+
layerInfo = getLayerUpdateInfo(wmLayer, _mapId2);
|
|
7257
7271
|
setWMLayerPropsBasedOnChildProps(child, wmLayer, props);
|
|
7258
7272
|
onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
|
|
7259
7273
|
wmjsMap.draw();
|
|
7260
7274
|
case 6:
|
|
7261
7275
|
case "end":
|
|
7262
|
-
return
|
|
7276
|
+
return _context2.stop();
|
|
7263
7277
|
}
|
|
7264
|
-
},
|
|
7278
|
+
}, _callee2);
|
|
7265
7279
|
})))["catch"](function (e) {
|
|
7266
7280
|
child.onLayerError && child.onLayerError(wmLayer, e);
|
|
7267
7281
|
});
|
|
@@ -7407,7 +7421,6 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
|
7407
7421
|
mapId = _this$props5.mapId;
|
|
7408
7422
|
var adagucInitialised = this.state.adagucInitialised;
|
|
7409
7423
|
var featureLayers = getFeatureLayers(children);
|
|
7410
|
-
// TODO: Improve in https://gitlab.com/opengeoweb/opengeoweb/-/issues/4579
|
|
7411
7424
|
featureLayers.forEach(function (featureLayer) {
|
|
7412
7425
|
var wmFeatureLayer = getWMLayerById(featureLayer.id);
|
|
7413
7426
|
if (!wmFeatureLayer) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/webmap-react",
|
|
3
|
-
"version": "9.35.0",
|
|
3
|
+
"version": "9.35.1-spike-oltanstack.0",
|
|
4
4
|
"description": "GeoWeb react wrapper for webmap",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"react-resize-detector": "^9.1.0",
|
|
20
20
|
"i18next": "^23.11.5",
|
|
21
21
|
"@mui/material": "^6.1.1",
|
|
22
|
-
"react-i18next": "^15.1.1"
|
|
22
|
+
"react-i18next": "^15.1.1",
|
|
23
|
+
"@tanstack/react-query": "^5.61.5"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
25
26
|
"react": "18",
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { GetCapabilitiesJson, WMSServiceInfo, LayerTree, LayerProps, WMLayer } from '@opengeoweb/webmap';
|
|
2
|
+
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
+
/**
|
|
4
|
+
* Queries the WMS GetCapabilities. This is the base TanStack hook for the other hooks in this file.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} serviceUrl
|
|
7
|
+
* @returns {UseQueryResult<GetCapabilitiesJson>}
|
|
8
|
+
*/
|
|
9
|
+
export declare const useQueryGetWMSGetCapabilities: (serviceUrl: string) => UseQueryResult<GetCapabilitiesJson>;
|
|
10
|
+
/**
|
|
11
|
+
* Returns details about the WMS service
|
|
12
|
+
*
|
|
13
|
+
* @param {string} serviceUrl
|
|
14
|
+
* @returns {(WMSServiceInfo | null)}
|
|
15
|
+
*/
|
|
16
|
+
export declare const useQueryGetWMSServiceInfo: (serviceUrl: string) => WMSServiceInfo | null;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the layer tree in hierarchical order for a WMS service. Cached by TanStack. Uses the same store as in queryWMSGetCapabilities.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} serviceUrl
|
|
21
|
+
* @returns {(LayerTree | null)}
|
|
22
|
+
*/
|
|
23
|
+
export declare const useQueryGetWMSLayersTree: (serviceUrl: string) => LayerTree | null;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the flat layer list (without hierarchy) for a WMS service. Cached by TanStack. Uses the same store as in queryWMSGetCapabilities.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} serviceUrl
|
|
28
|
+
* @returns {LayerProps[]}
|
|
29
|
+
*/
|
|
30
|
+
export declare const useQueryGetWMSLayers: (serviceUrl: string) => LayerProps[];
|
|
31
|
+
/**
|
|
32
|
+
* Returns specific layer from the WMS service
|
|
33
|
+
*
|
|
34
|
+
* @param {string} serviceUrl
|
|
35
|
+
* @param {string} name
|
|
36
|
+
* @returns {(LayerProps | null)}
|
|
37
|
+
*/
|
|
38
|
+
export declare const useQueryGetWMSLayer: (serviceUrl: string, name: string) => LayerProps | null;
|
|
39
|
+
/**
|
|
40
|
+
* Returns WMLayer instance. The layer will contains parsed dimensions and styles and keeps a state for these properties.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} serviceUrl
|
|
43
|
+
* @param {string} name
|
|
44
|
+
* @returns {(WMLayer | null)}
|
|
45
|
+
*/
|
|
46
|
+
export declare const useGetWMLayerInstance: (serviceUrl: string, name: string) => WMLayer | null;
|