@opengeoweb/webmap-react 9.35.1-spike-oltanstack.0 → 9.37.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 +57 -64
- package/package.json +2 -3
- package/src/lib/components/MapDraw/MapDraw.d.ts +1 -0
- package/src/lib/components/MapDraw/MapDrawContainer.d.ts +1 -0
- package/src/lib/components/ReactMapView/types.d.ts +1 -0
- package/src/lib/components/TanStackDemo/TanStackDemo.GetCapabilitiesLiveUpdate.stories.d.ts +0 -9
- package/src/lib/hooks/useHooksGetCapabilities.d.ts +0 -46
package/index.esm.js
CHANGED
|
@@ -1948,8 +1948,9 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
1948
1948
|
screenCoords: result.screenCoords
|
|
1949
1949
|
};
|
|
1950
1950
|
onHoverFeature(_this2.featureEvent);
|
|
1951
|
-
} else {
|
|
1951
|
+
} else if (_this2.featureEvent) {
|
|
1952
1952
|
_this2.featureEvent = undefined;
|
|
1953
|
+
onHoverFeature(undefined);
|
|
1953
1954
|
}
|
|
1954
1955
|
var webmapjs = webmapUtils.getWMJSMapById(mapId);
|
|
1955
1956
|
webmapjs && webmapjs.draw('MapDraw::onHoverFeature');
|
|
@@ -2809,7 +2810,8 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
2809
2810
|
var _this$props9 = this.props,
|
|
2810
2811
|
selectedFeatureIndex = _this$props9.selectedFeatureIndex,
|
|
2811
2812
|
isInEditMode = _this$props9.isInEditMode,
|
|
2812
|
-
mapId = _this$props9.mapId
|
|
2813
|
+
mapId = _this$props9.mapId,
|
|
2814
|
+
linkedFeatures = _this$props9.linkedFeatures;
|
|
2813
2815
|
if (!((_this$geojson3 = this.geojson) !== null && _this$geojson3 !== void 0 && (_this$geojson3 = _this$geojson3.features) !== null && _this$geojson3 !== void 0 && _this$geojson3.length)) {
|
|
2814
2816
|
return;
|
|
2815
2817
|
}
|
|
@@ -2969,8 +2971,8 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
2969
2971
|
}
|
|
2970
2972
|
/* Draw selected feature to display it on top */
|
|
2971
2973
|
drawFeatureGeometry(this.getSelectedFeature(), selectedFeatureIndex);
|
|
2972
|
-
/*
|
|
2973
|
-
if (isInEditMode === true && this.mouseOverPolygonFeatureIndex === selectedFeatureIndex && this.mouseIsOverVertexNr === VERTEX.NONE && this.snappedPolygonIndex === SNAPPEDFEATURE.NONE && this.selectedEdge === EDGE.NONE || this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE) {
|
|
2974
|
+
/* Highlight polygon with mousehover */
|
|
2975
|
+
if (isInEditMode === true && this.mouseOverPolygonFeatureIndex === selectedFeatureIndex && this.mouseIsOverVertexNr === VERTEX.NONE && this.snappedPolygonIndex === SNAPPEDFEATURE.NONE && this.selectedEdge === EDGE.NONE || this.mouseIsOverVertexNr === VERTEX.MIDDLE_POINT_OF_FEATURE || linkedFeatures) {
|
|
2974
2976
|
var _feature3 = this.getSelectedFeature();
|
|
2975
2977
|
var featureProperties = _feature3.properties;
|
|
2976
2978
|
if (this.mouseOverPolygonCoordinates.length >= 2) {
|
|
@@ -3491,6 +3493,7 @@ MapDraw.defaultProps = {
|
|
|
3491
3493
|
|
|
3492
3494
|
var MapDrawContainer = function MapDrawContainer(_ref) {
|
|
3493
3495
|
var featureLayers = _ref.featureLayers,
|
|
3496
|
+
linkedFeatures = _ref.linkedFeatures,
|
|
3494
3497
|
mapId = _ref.mapId;
|
|
3495
3498
|
return jsx(Fragment, {
|
|
3496
3499
|
children: featureLayers.map(function (layer) {
|
|
@@ -3501,6 +3504,7 @@ var MapDrawContainer = function MapDrawContainer(_ref) {
|
|
|
3501
3504
|
},
|
|
3502
3505
|
children: jsx(MapDraw, {
|
|
3503
3506
|
geojson: layer.geojson,
|
|
3507
|
+
linkedFeatures: linkedFeatures,
|
|
3504
3508
|
isInEditMode: layer.isInEditMode,
|
|
3505
3509
|
isInDeleteMode: layer.isInDeleteMode,
|
|
3506
3510
|
drawMode: layer.drawMode,
|
|
@@ -6704,7 +6708,16 @@ var makeLayerPropListFromChildren = function makeLayerPropListFromChildren(child
|
|
|
6704
6708
|
return myChildren;
|
|
6705
6709
|
};
|
|
6706
6710
|
var parseWMJSLayer = function parseWMJSLayer(wmLayer, forceReload) {
|
|
6707
|
-
return
|
|
6711
|
+
return new Promise(function (resolve, reject) {
|
|
6712
|
+
var callback = function callback() {
|
|
6713
|
+
if (wmLayer.hasError) {
|
|
6714
|
+
reject(new Error(wmLayer.lastError));
|
|
6715
|
+
} else {
|
|
6716
|
+
resolve(wmLayer);
|
|
6717
|
+
}
|
|
6718
|
+
};
|
|
6719
|
+
wmLayer.parseLayer(callback, forceReload, 'ReactMapView parseWMJSLayer');
|
|
6720
|
+
});
|
|
6708
6721
|
};
|
|
6709
6722
|
var setWMLayerPropsBasedOnChildProps = function setWMLayerPropsBasedOnChildProps(child, wmLayer, mapViewProps) {
|
|
6710
6723
|
var needsRedraw = false;
|
|
@@ -6762,7 +6775,7 @@ var setWMLayerPropsBasedOnChildProps = function setWMLayerPropsBasedOnChildProps
|
|
|
6762
6775
|
};
|
|
6763
6776
|
var addWMLayerPropsBasedOnChildProps = function addWMLayerPropsBasedOnChildProps(child, mapId, props, onUpdateLayerInformation) {
|
|
6764
6777
|
var wmjsMap = getWMJSMapById(mapId);
|
|
6765
|
-
if (!wmjsMap
|
|
6778
|
+
if (!wmjsMap) {
|
|
6766
6779
|
return;
|
|
6767
6780
|
}
|
|
6768
6781
|
var keepOnTop = child.layerType === LayerType.overLayer || false;
|
|
@@ -6787,18 +6800,11 @@ var addWMLayerPropsBasedOnChildProps = function addWMLayerPropsBasedOnChildProps
|
|
|
6787
6800
|
if (newWMLayer.hasError === true) {
|
|
6788
6801
|
child.onLayerError && child.onLayerError(newWMLayer, new Error(newWMLayer.lastError));
|
|
6789
6802
|
}
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
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);
|
|
6803
|
+
setWMLayerPropsBasedOnChildProps(child, newWMLayer, props);
|
|
6804
|
+
var layerInfo = getLayerUpdateInfo(newWMLayer, mapId);
|
|
6805
|
+
onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
|
|
6806
|
+
child.onLayerReady && child.onLayerReady(newWMLayer, wmjsMap);
|
|
6807
|
+
wmjsMap.draw();
|
|
6802
6808
|
})["catch"](function (e) {
|
|
6803
6809
|
child.onLayerError && child.onLayerError(e);
|
|
6804
6810
|
});
|
|
@@ -6895,6 +6901,10 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
|
6895
6901
|
*/
|
|
6896
6902
|
_this.onStartRefetchTimer = function (force) {
|
|
6897
6903
|
var shouldAutoFetch = _this.props.shouldAutoFetch;
|
|
6904
|
+
/* TODO, Maarten Plieger, 2021-09-02
|
|
6905
|
+
This causes many issues, we should improve the update strategy.
|
|
6906
|
+
Certain presets have >20 layers. This causes 20 times parsing the GetCapabilities for a minor update of the store.
|
|
6907
|
+
*/
|
|
6898
6908
|
_this.clearRefetchTimer();
|
|
6899
6909
|
var autoFetchInterval = Number(shouldAutoFetch); // Default true -> 1 minute
|
|
6900
6910
|
var refetch = function refetch() {
|
|
@@ -6904,40 +6914,20 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
|
6904
6914
|
var mapId = _this.props.mapId;
|
|
6905
6915
|
var wmjsMap = webmapUtils.getWMJSMapById(mapId);
|
|
6906
6916
|
var layers = wmjsMap === null || wmjsMap === void 0 ? void 0 : wmjsMap.getLayers();
|
|
6907
|
-
layers === null || layers === void 0 || layers.forEach(
|
|
6908
|
-
|
|
6909
|
-
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
|
|
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
|
-
}());
|
|
6917
|
+
layers === null || layers === void 0 || layers.forEach(function (layer) {
|
|
6918
|
+
if (layer.enabled !== false) {
|
|
6919
|
+
parseWMJSLayer(layer, true).then(function (wmLayer) {
|
|
6920
|
+
var _this2 = _this,
|
|
6921
|
+
props = _this2.props;
|
|
6922
|
+
var mapId = props.mapId,
|
|
6923
|
+
onUpdateLayerInformation = props.onUpdateLayerInformation;
|
|
6924
|
+
var layerInfo = getLayerUpdateInfo(wmLayer, mapId);
|
|
6925
|
+
onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
|
|
6926
|
+
})["catch"](function (e) {
|
|
6927
|
+
console.error(e);
|
|
6928
|
+
});
|
|
6929
|
+
}
|
|
6930
|
+
});
|
|
6941
6931
|
}
|
|
6942
6932
|
};
|
|
6943
6933
|
if (autoFetchInterval > 0) {
|
|
@@ -7220,13 +7210,13 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
|
7220
7210
|
// ReactWMJSLayer Layer Childs: Detect all ReactLayers connected to WMJSLayers, remove WMJSLayer if there is no ReactLayer
|
|
7221
7211
|
var wmjsLayers = wmjsMap.getLayers();
|
|
7222
7212
|
var onUpdateLayerInformation = props.onUpdateLayerInformation,
|
|
7223
|
-
|
|
7213
|
+
_mapId = props.mapId;
|
|
7224
7214
|
wmjsLayers.forEach(function (wmLayer) {
|
|
7225
7215
|
var isWMLayerInReactMapViewChildren = myChildren.find(function (child) {
|
|
7226
7216
|
return child.id === wmLayer.ReactWMJSLayerId;
|
|
7227
7217
|
});
|
|
7228
7218
|
if (!isWMLayerInReactMapViewChildren) {
|
|
7229
|
-
removeWMLayerFromMap(wmLayer,
|
|
7219
|
+
removeWMLayerFromMap(wmLayer, _mapId, onUpdateLayerInformation);
|
|
7230
7220
|
}
|
|
7231
7221
|
});
|
|
7232
7222
|
// ReactWMJSLayer BaseLayer Childs: For the baseLayers, detect all ReactLayers connected to WMJSLayers, remove WMJSLayer if there is no ReactLayer
|
|
@@ -7253,29 +7243,29 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
|
7253
7243
|
var layerIsInThisMap = wmjsMap.hasLayer(wmLayer);
|
|
7254
7244
|
if (!layerIsInThisMap) {
|
|
7255
7245
|
// Add a new layer, it is not in the this map
|
|
7256
|
-
addWMLayerPropsBasedOnChildProps(child,
|
|
7246
|
+
addWMLayerPropsBasedOnChildProps(child, _mapId, props, onUpdateLayerInformation);
|
|
7257
7247
|
needsRedraw = true;
|
|
7258
7248
|
} else {
|
|
7259
7249
|
// Handle existing layer
|
|
7260
7250
|
if (child.name !== undefined && wmLayer.name !== child.name) {
|
|
7261
7251
|
// Handle layer name change
|
|
7262
|
-
wmLayer.setName(child.name).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7252
|
+
wmLayer.setName(child.name).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
7263
7253
|
var layerInfo;
|
|
7264
|
-
return _regeneratorRuntime().wrap(function
|
|
7265
|
-
while (1) switch (
|
|
7254
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
7255
|
+
while (1) switch (_context.prev = _context.next) {
|
|
7266
7256
|
case 0:
|
|
7267
|
-
|
|
7268
|
-
return wmLayer
|
|
7257
|
+
_context.next = 2;
|
|
7258
|
+
return parseWMJSLayer(wmLayer, false);
|
|
7269
7259
|
case 2:
|
|
7270
|
-
layerInfo = getLayerUpdateInfo(wmLayer,
|
|
7260
|
+
layerInfo = getLayerUpdateInfo(wmLayer, _mapId);
|
|
7271
7261
|
setWMLayerPropsBasedOnChildProps(child, wmLayer, props);
|
|
7272
7262
|
onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
|
|
7273
7263
|
wmjsMap.draw();
|
|
7274
7264
|
case 6:
|
|
7275
7265
|
case "end":
|
|
7276
|
-
return
|
|
7266
|
+
return _context.stop();
|
|
7277
7267
|
}
|
|
7278
|
-
},
|
|
7268
|
+
}, _callee);
|
|
7279
7269
|
})))["catch"](function (e) {
|
|
7280
7270
|
child.onLayerError && child.onLayerError(wmLayer, e);
|
|
7281
7271
|
});
|
|
@@ -7418,9 +7408,11 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
|
7418
7408
|
passiveMap = _this$props5.passiveMap,
|
|
7419
7409
|
children = _this$props5.children,
|
|
7420
7410
|
onClick = _this$props5.onClick,
|
|
7421
|
-
mapId = _this$props5.mapId
|
|
7411
|
+
mapId = _this$props5.mapId,
|
|
7412
|
+
linkedFeatures = _this$props5.linkedFeatures;
|
|
7422
7413
|
var adagucInitialised = this.state.adagucInitialised;
|
|
7423
7414
|
var featureLayers = getFeatureLayers(children);
|
|
7415
|
+
// TODO: Improve in https://gitlab.com/opengeoweb/opengeoweb/-/issues/4579
|
|
7424
7416
|
featureLayers.forEach(function (featureLayer) {
|
|
7425
7417
|
var wmFeatureLayer = getWMLayerById(featureLayer.id);
|
|
7426
7418
|
if (!wmFeatureLayer) {
|
|
@@ -7480,6 +7472,7 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
|
|
|
7480
7472
|
children: children
|
|
7481
7473
|
}), adagucInitialised && featureLayers && featureLayers.length ? jsx(MapDrawContainer, {
|
|
7482
7474
|
featureLayers: featureLayers,
|
|
7475
|
+
linkedFeatures: linkedFeatures,
|
|
7483
7476
|
mapId: mapId
|
|
7484
7477
|
}) : null]
|
|
7485
7478
|
}), passiveMap &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/webmap-react",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.37.0",
|
|
4
4
|
"description": "GeoWeb react wrapper for webmap",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -19,8 +19,7 @@
|
|
|
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"
|
|
23
|
-
"@tanstack/react-query": "^5.61.5"
|
|
22
|
+
"react-i18next": "^15.1.1"
|
|
24
23
|
},
|
|
25
24
|
"peerDependencies": {
|
|
26
25
|
"react": "18",
|
|
@@ -28,6 +28,7 @@ export interface FeatureEvent {
|
|
|
28
28
|
export interface MapDrawProps {
|
|
29
29
|
mapId: string;
|
|
30
30
|
geojson: GeoJSON.FeatureCollection;
|
|
31
|
+
linkedFeatures?: GeoJSON.FeatureCollection;
|
|
31
32
|
drawMode: string;
|
|
32
33
|
deletePolygonCallback?: string;
|
|
33
34
|
exitDrawModeCallback: (reason: DrawModeExitCallback, newGeoJSON?: GeoJSON.FeatureCollection) => void;
|
|
@@ -31,6 +31,7 @@ export interface ReactMapViewProps {
|
|
|
31
31
|
holdShiftToScroll?: boolean;
|
|
32
32
|
shouldDisablePrefetching?: boolean;
|
|
33
33
|
t?: TFunction;
|
|
34
|
+
linkedFeatures?: GeoJSON.FeatureCollection;
|
|
34
35
|
onWMJSMount?: (mapId: string) => void;
|
|
35
36
|
onWMJSUnMount?: (mapId: string) => void;
|
|
36
37
|
onMapChangeDimension?: (payload: SetMapDimensionPayload) => void;
|
|
@@ -1,46 +0,0 @@
|
|
|
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;
|