@opengeoweb/webmap-react 10.1.0 → 10.2.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
@@ -1,4 +1,4 @@
1
- import { legendImageStore, WMImageEventType, webmapUtils, getLegendGraphicURLForLayer, getPixelCoordFromLatLong, WMJSMAP_LONLAT_EPSGCODE, getLatLongFromPixelCoord, LayerType, getWMJSMapById, debugLogger, DebugType, WMLayer, registerWMLayer, tilesettings, WMBBOX, getWMLayerById, WMJSMap, privateWebMapUtils, generateLayerId } from '@opengeoweb/webmap';
1
+ import { legendImageStore, WMImageEventType, webmapUtils, getLegendGraphicURLForLayer, getPixelCoordFromLatLong, WMJSMAP_LONLAT_EPSGCODE, getLatLongFromPixelCoord, LayerType, getWMJSMapById, debugLogger, DebugType, WMLayer, registerWMLayer, tilesettings, WMBBOX, getWMLayerById, WMJSMap, privateWebMapUtils } from '@opengeoweb/webmap';
2
2
  export { WEBMAP_NAMESPACE, webmapTranslations } from '@opengeoweb/webmap';
3
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
4
  import * as React from 'react';
@@ -6798,17 +6798,32 @@ var addWMLayerPropsBasedOnChildProps = function addWMLayerPropsBasedOnChildProps
6798
6798
  child.onLayerError && child.onLayerError(newWMLayer, new Error(newWMLayer.lastError));
6799
6799
  }
6800
6800
  // This ensures that MultiMapViewConnect works properly.
6801
- setTimeout(function () {
6802
- var wmjsMap = getWMJSMapById(mapId);
6803
- if (!wmjsMap || wmjsMap.isDestroyed) {
6804
- return;
6805
- }
6806
- setWMLayerPropsBasedOnChildProps(child, newWMLayer, props);
6807
- var layerInfo = getLayerUpdateInfo(newWMLayer, mapId);
6808
- onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
6809
- child.onLayerReady && child.onLayerReady(newWMLayer, wmjsMap);
6810
- wmjsMap.draw();
6811
- }, 1);
6801
+ setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6802
+ var wmjsMap, layerInfo;
6803
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
6804
+ while (1) switch (_context.prev = _context.next) {
6805
+ case 0:
6806
+ wmjsMap = getWMJSMapById(mapId);
6807
+ if (!(!wmjsMap || wmjsMap.isDestroyed)) {
6808
+ _context.next = 3;
6809
+ break;
6810
+ }
6811
+ return _context.abrupt("return");
6812
+ case 3:
6813
+ setWMLayerPropsBasedOnChildProps(child, newWMLayer, props);
6814
+ _context.next = 6;
6815
+ return newWMLayer.parseLayer();
6816
+ case 6:
6817
+ layerInfo = getLayerUpdateInfo(newWMLayer, mapId);
6818
+ onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
6819
+ child.onLayerReady && child.onLayerReady(newWMLayer, wmjsMap);
6820
+ wmjsMap.draw();
6821
+ case 10:
6822
+ case "end":
6823
+ return _context.stop();
6824
+ }
6825
+ }, _callee);
6826
+ })), 1);
6812
6827
  })["catch"](function (e) {
6813
6828
  child.onLayerError && child.onLayerError(e);
6814
6829
  });
@@ -6830,11 +6845,11 @@ var removeWMLayerFromMap = function removeWMLayerFromMap(wmLayer, mapId, onUpdat
6830
6845
  mapDimensions: {
6831
6846
  origin: origin,
6832
6847
  mapId: mapId,
6833
- dimensions: wmjsMap.mapdimensions.map(function (_ref) {
6834
- var name = _ref.name,
6835
- units = _ref.units,
6836
- currentValue = _ref.currentValue,
6837
- synced = _ref.synced;
6848
+ dimensions: wmjsMap.mapdimensions.map(function (_ref2) {
6849
+ var name = _ref2.name,
6850
+ units = _ref2.units,
6851
+ currentValue = _ref2.currentValue,
6852
+ synced = _ref2.synced;
6838
6853
  return {
6839
6854
  name: name,
6840
6855
  units: units,
@@ -8836,14 +8851,14 @@ var obsPrecipitationIntensityPWS = {
8836
8851
  };
8837
8852
  var harmonieRelativeHumidityPl = {
8838
8853
  service: KNMIgeoservicesHarmonie.url,
8839
- name: 'relative_humidity__at_pl',
8854
+ name: 'relative_humidity_pl',
8840
8855
  id: webmapUtils.generateLayerId(),
8841
8856
  layerType: LayerType.mapLayer,
8842
8857
  enabled: true
8843
8858
  };
8844
8859
  var harmonieWindPl = {
8845
8860
  service: KNMIgeoservicesHarmonie.url,
8846
- name: 'wind__at_pl',
8861
+ name: 'wind_speed_pl',
8847
8862
  id: webmapUtils.generateLayerId(),
8848
8863
  layerType: LayerType.mapLayer,
8849
8864
  enabled: true
@@ -8871,7 +8886,7 @@ var harmoniePressure = {
8871
8886
  };
8872
8887
  var harmonieWindFlags = {
8873
8888
  service: KNMIgeoservicesHarmonie.url,
8874
- name: 'wind__at_10m',
8889
+ name: 'wind_speed_components_hagl',
8875
8890
  enabled: true,
8876
8891
  id: webmapUtils.generateLayerId(),
8877
8892
  layerType: LayerType.mapLayer
@@ -9086,6 +9101,7 @@ var privateWmsGetCapabilities = privateWebMapUtils.privateWmsGetCapabilities,
9086
9101
  privateGetWMSServiceInfo = privateWebMapUtils.privateGetWMSServiceInfo,
9087
9102
  privateWmsGetLayerTree = privateWebMapUtils.privateWmsGetLayerTree,
9088
9103
  privateWmsFlattenLayerTree = privateWebMapUtils.privateWmsFlattenLayerTree,
9104
+ privateWmtsGetCapabilities = privateWebMapUtils.privateWmtsGetCapabilities,
9089
9105
  QUERYWMS_GETCAPABILITIES = privateWebMapUtils.QUERYWMS_GETCAPABILITIES;
9090
9106
  /**
9091
9107
  * Queries the WMS GetCapabilities. This is the base TanStack hook for the other hooks in this file.
@@ -9188,6 +9204,17 @@ var useQueryGetWMSLayer = function useQueryGetWMSLayer(serviceUrl, name) {
9188
9204
  }, [layers, name]);
9189
9205
  return layer;
9190
9206
  };
9207
+ /**
9208
+ * Returns a stylelist for given layer in a service
9209
+ *
9210
+ * @param {string} serviceUrl
9211
+ * @param {string} name
9212
+ * @returns {(Style[] | null)}
9213
+ */
9214
+ var useGetWMSLayerStyleList = function useGetWMSLayerStyleList(serviceUrl, name) {
9215
+ var _useQueryGetWMSLayer;
9216
+ return ((_useQueryGetWMSLayer = useQueryGetWMSLayer(serviceUrl, name)) === null || _useQueryGetWMSLayer === void 0 ? void 0 : _useQueryGetWMSLayer.styles) || null;
9217
+ };
9191
9218
  /**
9192
9219
  * Returns WMLayer instance. The layer will contains parsed dimensions and styles and keeps a state for these properties.
9193
9220
  *
@@ -9195,29 +9222,52 @@ var useQueryGetWMSLayer = function useQueryGetWMSLayer(serviceUrl, name) {
9195
9222
  * @param {string} name
9196
9223
  * @returns {(WMLayer | null)}
9197
9224
  */
9198
- var useGetWMLayerInstance = function useGetWMLayerInstance(serviceUrl, name) {
9225
+ var useGetWMLayerInstance = function useGetWMLayerInstance(serviceUrl, name, id) {
9199
9226
  var _React$useState9 = React__default.useState(null),
9200
9227
  _React$useState10 = _slicedToArray(_React$useState9, 2),
9201
9228
  layer = _React$useState10[0],
9202
9229
  setLayer = _React$useState10[1];
9203
- var layerId = useRef(generateLayerId()).current;
9230
+ var refId = useRef(webmapUtils.generateLayerId()).current;
9231
+ var layerId = id || refId;
9204
9232
  React__default.useEffect(function () {
9205
- var l = getWMLayerById(layerId);
9206
- if (l) {
9207
- return;
9233
+ // Check if the layer is already registered
9234
+ var l = webmapUtils.getWMLayerById(layerId);
9235
+ if (!l || l.service !== serviceUrl) {
9236
+ // Make a new layer if the serviceUrl changes. (But not when the name changes)
9237
+ var _wmLayer = new WMLayer({
9238
+ name: name,
9239
+ service: serviceUrl,
9240
+ layerType: LayerType.mapLayer,
9241
+ id: layerId
9242
+ });
9243
+ webmapUtils.registerWMLayer(_wmLayer, layerId);
9208
9244
  }
9209
- var wmLayer = new WMLayer({
9210
- name: name,
9211
- service: serviceUrl,
9212
- layerType: LayerType.mapLayer,
9213
- id: layerId
9214
- });
9215
- void wmLayer.parseLayer().then(function () {
9216
- registerWMLayer(wmLayer, layerId);
9245
+ // Set the name and parse the layer
9246
+ var wmLayer = webmapUtils.getWMLayerById(layerId);
9247
+ wmLayer.setName(name).then(function () {
9248
+ webmapUtils.registerWMLayer(wmLayer, layerId);
9249
+ setLayer(wmLayer);
9250
+ })["catch"](function (e) {
9251
+ console.error(e);
9252
+ webmapUtils.registerWMLayer(wmLayer, layerId);
9217
9253
  setLayer(wmLayer);
9218
9254
  });
9219
9255
  }, [layerId, name, serviceUrl]);
9220
9256
  return layer;
9221
9257
  };
9258
+ /**
9259
+ * Used for querying WMTS GetCapabilities documents
9260
+ * @param serviceUrl
9261
+ * @returns
9262
+ */
9263
+ var useQueryWMTSGetCapabilities = function useQueryWMTSGetCapabilities(serviceUrl) {
9264
+ var uriKey = new URLSearchParams(serviceUrl).toString();
9265
+ return useQuery({
9266
+ queryKey: [uriKey, 'queryGetCapabilities'],
9267
+ queryFn: function queryFn() {
9268
+ return privateWmtsGetCapabilities(serviceUrl, [], true);
9269
+ }
9270
+ });
9271
+ };
9222
9272
 
9223
- export { DRAWMODE, DimensionSelectButton, DimensionSelectDialog, DimensionSelectSlider, EDITMODE, EditModeButton as EditModeButtonField, FeatureLayers, GeoJSONTextField, IntersectionSelect, LayerInfoButton, LayerInfoDialog, LayerInfoLegend, LayerInfoList, LayerInfoText, Legend, LegendButton, LegendDialog, LegendLayout, MINUTE_TO_MILLISECOND, MapControlButton, MapControls, MapDimensionSelect, MapDrawContainer, MapTime, MapView, MapViewLayer, MapWarningProperties, NEW_FEATURE_CREATED, NEW_LINESTRING_CREATED, NEW_POINT_CREATED, ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION, ORIGIN_REACTMAPVIEW_ONUPDATELAYERINFO, Proj4js, radarGetCapabilities_spec as RadarGetCapabilities, ReactMapView, ReactMapViewLayer, SelectField, StoryLayoutGrid, WEBMAP_REACT_NAMESPACE, ZoomControls, addFeatureProperties, addGeoJSONProperties, addSelectionTypeToGeoJSON, addWMLayerPropsBasedOnChildProps, basicExampleDrawOptions, basicExampleMultipleShapeDrawOptions, basicExampleMultipleShapeWithValuesDrawOptions, checkHoverFeatures, convertGeoCoordsToScreenCoords, createInterSections, currentlySupportedDrawModes, defaultBox, defaultDelete, defaultGeoJSONStyleProperties, defaultIntersectionStyleProperties, defaultLayers, defaultModes, defaultPoint, defaultPolygon, defaultTimeFormat, dimensionConfig, distance, drawPolyStoryStyles, emptyGeoJSON, endToolExampleConfig, exampleIntersectionOptions, exampleIntersectionWithShapeOptions, exampleIntersections, exampleIntersectionsMultiDrawTool, featureBox, featureMultiPoint, featurePoint, featurePolygon, fillOptions, findClosestCoords, firSelectionType, formatTime, getCurrentDimensionValue, getDimensionIcon, getDimensionLabel, getDimensionValue, getDimensionsList, getDoubleControlToolIcon, getDrawFunctionFromStore, getFeatureCollection, getFeatureExtent, getFeatureLayers, getFirTitle, getGeoJSONPropertyValue, getGeoJson, getIcon, getIntersectionToolIcon, getIsInsideAcceptanceTime, getLastEmptyFeatureIndex, getLayerBbox, getLayerStyles, getLayerUpdateInfo, getPixelCoordFromGeoCoord, getProj4, getTimeDimension, getToolIcon, intersectPointGeoJSONS, intersectPolygonGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isAGeoJSONLayer, isAMapLayer, isBetween, isGeoJSONFeatureCreatedByTool, isPointFeatureCollection, lineString, lineStringCollection, makeLayerPropListFromChildren, marksByDimension, moveFeature, opacityOptions, orderLayers, parseWMJSLayer, projectorCache, publicLayers, publicServices, registerDrawFunction, removeWMLayerFromMap, rewindGeometry, setWMLayerPropsBasedOnChildProps, simpleBoxGeoJSON, simpleBoxGeoJSONWrongOrder, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleGeometryCollectionGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, startToolExampleConfig, strokeWidthOptions, textStyle, textStyleWithMargin, updateEditModeButtonsWithFir, useGeoJSON, useGetWMLayerInstance, useMapDrawTool, useQueryGetWMSGetCapabilities, useQueryGetWMSLayer, useQueryGetWMSLayers, useQueryGetWMSLayersTree, useQueryGetWMSServiceInfo, webmapReactTranslations };
9273
+ export { DRAWMODE, DimensionSelectButton, DimensionSelectDialog, DimensionSelectSlider, EDITMODE, EditModeButton as EditModeButtonField, FeatureLayers, GeoJSONTextField, IntersectionSelect, LayerInfoButton, LayerInfoDialog, LayerInfoLegend, LayerInfoList, LayerInfoText, Legend, LegendButton, LegendDialog, LegendLayout, MINUTE_TO_MILLISECOND, MapControlButton, MapControls, MapDimensionSelect, MapDrawContainer, MapTime, MapView, MapViewLayer, MapWarningProperties, NEW_FEATURE_CREATED, NEW_LINESTRING_CREATED, NEW_POINT_CREATED, ORIGIN_REACTMAPVIEW_ONMAPCHANGEDIMENSION, ORIGIN_REACTMAPVIEW_ONUPDATELAYERINFO, Proj4js, radarGetCapabilities_spec as RadarGetCapabilities, ReactMapView, ReactMapViewLayer, SelectField, StoryLayoutGrid, WEBMAP_REACT_NAMESPACE, ZoomControls, addFeatureProperties, addGeoJSONProperties, addSelectionTypeToGeoJSON, addWMLayerPropsBasedOnChildProps, basicExampleDrawOptions, basicExampleMultipleShapeDrawOptions, basicExampleMultipleShapeWithValuesDrawOptions, checkHoverFeatures, convertGeoCoordsToScreenCoords, createInterSections, currentlySupportedDrawModes, defaultBox, defaultDelete, defaultGeoJSONStyleProperties, defaultIntersectionStyleProperties, defaultLayers, defaultModes, defaultPoint, defaultPolygon, defaultTimeFormat, dimensionConfig, distance, drawPolyStoryStyles, emptyGeoJSON, endToolExampleConfig, exampleIntersectionOptions, exampleIntersectionWithShapeOptions, exampleIntersections, exampleIntersectionsMultiDrawTool, featureBox, featureMultiPoint, featurePoint, featurePolygon, fillOptions, findClosestCoords, firSelectionType, formatTime, getCurrentDimensionValue, getDimensionIcon, getDimensionLabel, getDimensionValue, getDimensionsList, getDoubleControlToolIcon, getDrawFunctionFromStore, getFeatureCollection, getFeatureExtent, getFeatureLayers, getFirTitle, getGeoJSONPropertyValue, getGeoJson, getIcon, getIntersectionToolIcon, getIsInsideAcceptanceTime, getLastEmptyFeatureIndex, getLayerBbox, getLayerStyles, getLayerUpdateInfo, getPixelCoordFromGeoCoord, getProj4, getTimeDimension, getToolIcon, intersectPointGeoJSONS, intersectPolygonGeoJSONS, intersectionFeatureBE, intersectionFeatureNL, isAGeoJSONLayer, isAMapLayer, isBetween, isGeoJSONFeatureCreatedByTool, isPointFeatureCollection, lineString, lineStringCollection, makeLayerPropListFromChildren, marksByDimension, moveFeature, opacityOptions, orderLayers, parseWMJSLayer, projectorCache, publicLayers, publicServices, registerDrawFunction, removeWMLayerFromMap, rewindGeometry, setWMLayerPropsBasedOnChildProps, simpleBoxGeoJSON, simpleBoxGeoJSONWrongOrder, simpleFlightRouteLineStringGeoJSON, simpleFlightRoutePointsGeoJSON, simpleGeometryCollectionGeoJSON, simpleLineStringGeoJSON, simpleMultiPolygon, simplePointsGeojson, simplePolygonGeoJSON, simpleSmallLineStringGeoJSON, startToolExampleConfig, strokeWidthOptions, textStyle, textStyleWithMargin, updateEditModeButtonsWithFir, useGeoJSON, useGetWMLayerInstance, useGetWMSLayerStyleList, useMapDrawTool, useQueryGetWMSGetCapabilities, useQueryGetWMSLayer, useQueryGetWMSLayers, useQueryGetWMSLayersTree, useQueryGetWMSServiceInfo, useQueryWMTSGetCapabilities, webmapReactTranslations };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/webmap-react",
3
- "version": "10.1.0",
3
+ "version": "10.2.0",
4
4
  "description": "GeoWeb react wrapper for webmap",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -1,4 +1,4 @@
1
- import { GetCapabilitiesJson, WMSServiceInfo, LayerTree, LayerProps, WMLayer } from '@opengeoweb/webmap';
1
+ import { GetCapabilitiesJson, WMSServiceInfo, LayerTree, LayerProps, WMLayer, Style } from '@opengeoweb/webmap';
2
2
  import { UseQueryResult } from '@tanstack/react-query';
3
3
  /**
4
4
  * Queries the WMS GetCapabilities. This is the base TanStack hook for the other hooks in this file.
@@ -36,6 +36,14 @@ export declare const useQueryGetWMSLayers: (serviceUrl: string) => LayerProps[];
36
36
  * @returns {(LayerProps | null)}
37
37
  */
38
38
  export declare const useQueryGetWMSLayer: (serviceUrl: string, name: string) => LayerProps | null;
39
+ /**
40
+ * Returns a stylelist for given layer in a service
41
+ *
42
+ * @param {string} serviceUrl
43
+ * @param {string} name
44
+ * @returns {(Style[] | null)}
45
+ */
46
+ export declare const useGetWMSLayerStyleList: (serviceUrl: string, name: string) => Style[] | null;
39
47
  /**
40
48
  * Returns WMLayer instance. The layer will contains parsed dimensions and styles and keeps a state for these properties.
41
49
  *
@@ -43,4 +51,10 @@ export declare const useQueryGetWMSLayer: (serviceUrl: string, name: string) =>
43
51
  * @param {string} name
44
52
  * @returns {(WMLayer | null)}
45
53
  */
46
- export declare const useGetWMLayerInstance: (serviceUrl: string, name: string) => WMLayer | null;
54
+ export declare const useGetWMLayerInstance: (serviceUrl: string, name: string, id?: string) => WMLayer | null;
55
+ /**
56
+ * Used for querying WMTS GetCapabilities documents
57
+ * @param serviceUrl
58
+ * @returns
59
+ */
60
+ export declare const useQueryWMTSGetCapabilities: (serviceUrl: string) => UseQueryResult<GetCapabilitiesJson>;
@@ -0,0 +1 @@
1
+ export {};