@opengeoweb/webmap-react 10.1.0 → 11.0.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/README.md CHANGED
@@ -5,3 +5,7 @@ This library was generated with [Nx](https://nx.dev).
5
5
  ## Running unit tests
6
6
 
7
7
  Run `nx test webmap-react` to execute the unit tests via [Jest](https://jestjs.io).
8
+
9
+ ### TypeScript Documentation
10
+
11
+ - [TypeScript Docs](https://opengeoweb.gitlab.io/opengeoweb/typescript-docs/webmap-react/)
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';
@@ -1206,12 +1206,14 @@ var getPixelCoordFromGeoCoord = function getPixelCoordFromGeoCoord(featureCoords
1206
1206
  y: featureCoord[1]
1207
1207
  };
1208
1208
  coordinates = proj.proj4.transform(from, to, coordinates);
1209
- var x = width * (coordinates.x - bbox.left) / (bbox.right - bbox.left);
1210
- var y = height * (coordinates.y - bbox.top) / (bbox.bottom - bbox.top);
1211
- XYCoords.push({
1212
- x: x,
1213
- y: y
1214
- });
1209
+ if (coordinates !== null) {
1210
+ var x = width * (coordinates.x - bbox.left) / (bbox.right - bbox.left);
1211
+ var y = height * (coordinates.y - bbox.top) / (bbox.bottom - bbox.top);
1212
+ XYCoords.push({
1213
+ x: x,
1214
+ y: y
1215
+ });
1216
+ }
1215
1217
  }
1216
1218
  } catch (err) {
1217
1219
  _iterator2.e(err);
@@ -6798,19 +6800,34 @@ var addWMLayerPropsBasedOnChildProps = function addWMLayerPropsBasedOnChildProps
6798
6800
  child.onLayerError && child.onLayerError(newWMLayer, new Error(newWMLayer.lastError));
6799
6801
  }
6800
6802
  // 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);
6803
+ setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6804
+ var wmjsMap, layerInfo;
6805
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
6806
+ while (1) switch (_context.prev = _context.next) {
6807
+ case 0:
6808
+ wmjsMap = getWMJSMapById(mapId);
6809
+ if (!(!wmjsMap || wmjsMap.isDestroyed)) {
6810
+ _context.next = 3;
6811
+ break;
6812
+ }
6813
+ return _context.abrupt("return");
6814
+ case 3:
6815
+ setWMLayerPropsBasedOnChildProps(child, newWMLayer, props);
6816
+ _context.next = 6;
6817
+ return newWMLayer.parseLayer();
6818
+ case 6:
6819
+ layerInfo = getLayerUpdateInfo(newWMLayer, mapId);
6820
+ onUpdateLayerInformation && onUpdateLayerInformation(layerInfo);
6821
+ child.onLayerReady && child.onLayerReady(newWMLayer, wmjsMap);
6822
+ wmjsMap.draw();
6823
+ case 10:
6824
+ case "end":
6825
+ return _context.stop();
6826
+ }
6827
+ }, _callee);
6828
+ })), 1);
6812
6829
  })["catch"](function (e) {
6813
- child.onLayerError && child.onLayerError(e);
6830
+ child.onLayerError && child.onLayerError(newWMLayer, e);
6814
6831
  });
6815
6832
  }
6816
6833
  };
@@ -6830,11 +6847,11 @@ var removeWMLayerFromMap = function removeWMLayerFromMap(wmLayer, mapId, onUpdat
6830
6847
  mapDimensions: {
6831
6848
  origin: origin,
6832
6849
  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;
6850
+ dimensions: wmjsMap.mapdimensions.map(function (_ref2) {
6851
+ var name = _ref2.name,
6852
+ units = _ref2.units,
6853
+ currentValue = _ref2.currentValue,
6854
+ synced = _ref2.synced;
6838
6855
  return {
6839
6856
  name: name,
6840
6857
  units: units,
@@ -8836,14 +8853,14 @@ var obsPrecipitationIntensityPWS = {
8836
8853
  };
8837
8854
  var harmonieRelativeHumidityPl = {
8838
8855
  service: KNMIgeoservicesHarmonie.url,
8839
- name: 'relative_humidity__at_pl',
8856
+ name: 'relative_humidity_pl',
8840
8857
  id: webmapUtils.generateLayerId(),
8841
8858
  layerType: LayerType.mapLayer,
8842
8859
  enabled: true
8843
8860
  };
8844
8861
  var harmonieWindPl = {
8845
8862
  service: KNMIgeoservicesHarmonie.url,
8846
- name: 'wind__at_pl',
8863
+ name: 'wind_speed_pl',
8847
8864
  id: webmapUtils.generateLayerId(),
8848
8865
  layerType: LayerType.mapLayer,
8849
8866
  enabled: true
@@ -8871,7 +8888,7 @@ var harmoniePressure = {
8871
8888
  };
8872
8889
  var harmonieWindFlags = {
8873
8890
  service: KNMIgeoservicesHarmonie.url,
8874
- name: 'wind__at_10m',
8891
+ name: 'wind_speed_components_hagl',
8875
8892
  enabled: true,
8876
8893
  id: webmapUtils.generateLayerId(),
8877
8894
  layerType: LayerType.mapLayer
@@ -9086,6 +9103,7 @@ var privateWmsGetCapabilities = privateWebMapUtils.privateWmsGetCapabilities,
9086
9103
  privateGetWMSServiceInfo = privateWebMapUtils.privateGetWMSServiceInfo,
9087
9104
  privateWmsGetLayerTree = privateWebMapUtils.privateWmsGetLayerTree,
9088
9105
  privateWmsFlattenLayerTree = privateWebMapUtils.privateWmsFlattenLayerTree,
9106
+ privateWmtsGetCapabilities = privateWebMapUtils.privateWmtsGetCapabilities,
9089
9107
  QUERYWMS_GETCAPABILITIES = privateWebMapUtils.QUERYWMS_GETCAPABILITIES;
9090
9108
  /**
9091
9109
  * Queries the WMS GetCapabilities. This is the base TanStack hook for the other hooks in this file.
@@ -9188,6 +9206,17 @@ var useQueryGetWMSLayer = function useQueryGetWMSLayer(serviceUrl, name) {
9188
9206
  }, [layers, name]);
9189
9207
  return layer;
9190
9208
  };
9209
+ /**
9210
+ * Returns a stylelist for given layer in a service
9211
+ *
9212
+ * @param {string} serviceUrl
9213
+ * @param {string} name
9214
+ * @returns {(Style[] | null)}
9215
+ */
9216
+ var useGetWMSLayerStyleList = function useGetWMSLayerStyleList(serviceUrl, name) {
9217
+ var _useQueryGetWMSLayer;
9218
+ return ((_useQueryGetWMSLayer = useQueryGetWMSLayer(serviceUrl, name)) === null || _useQueryGetWMSLayer === void 0 ? void 0 : _useQueryGetWMSLayer.styles) || null;
9219
+ };
9191
9220
  /**
9192
9221
  * Returns WMLayer instance. The layer will contains parsed dimensions and styles and keeps a state for these properties.
9193
9222
  *
@@ -9195,29 +9224,52 @@ var useQueryGetWMSLayer = function useQueryGetWMSLayer(serviceUrl, name) {
9195
9224
  * @param {string} name
9196
9225
  * @returns {(WMLayer | null)}
9197
9226
  */
9198
- var useGetWMLayerInstance = function useGetWMLayerInstance(serviceUrl, name) {
9227
+ var useGetWMLayerInstance = function useGetWMLayerInstance(serviceUrl, name, id) {
9199
9228
  var _React$useState9 = React__default.useState(null),
9200
9229
  _React$useState10 = _slicedToArray(_React$useState9, 2),
9201
9230
  layer = _React$useState10[0],
9202
9231
  setLayer = _React$useState10[1];
9203
- var layerId = useRef(generateLayerId()).current;
9232
+ var refId = useRef(webmapUtils.generateLayerId()).current;
9233
+ var layerId = id || refId;
9204
9234
  React__default.useEffect(function () {
9205
- var l = getWMLayerById(layerId);
9206
- if (l) {
9207
- return;
9235
+ // Check if the layer is already registered
9236
+ var l = webmapUtils.getWMLayerById(layerId);
9237
+ if (!l || l.service !== serviceUrl) {
9238
+ // Make a new layer if the serviceUrl changes. (But not when the name changes)
9239
+ var _wmLayer = new WMLayer({
9240
+ name: name,
9241
+ service: serviceUrl,
9242
+ layerType: LayerType.mapLayer,
9243
+ id: layerId
9244
+ });
9245
+ webmapUtils.registerWMLayer(_wmLayer, layerId);
9208
9246
  }
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);
9247
+ // Set the name and parse the layer
9248
+ var wmLayer = webmapUtils.getWMLayerById(layerId);
9249
+ wmLayer.setName(name).then(function () {
9250
+ webmapUtils.registerWMLayer(wmLayer, layerId);
9251
+ setLayer(wmLayer);
9252
+ })["catch"](function (e) {
9253
+ console.error(e);
9254
+ webmapUtils.registerWMLayer(wmLayer, layerId);
9217
9255
  setLayer(wmLayer);
9218
9256
  });
9219
9257
  }, [layerId, name, serviceUrl]);
9220
9258
  return layer;
9221
9259
  };
9260
+ /**
9261
+ * Used for querying WMTS GetCapabilities documents
9262
+ * @param serviceUrl
9263
+ * @returns
9264
+ */
9265
+ var useQueryWMTSGetCapabilities = function useQueryWMTSGetCapabilities(serviceUrl) {
9266
+ var uriKey = new URLSearchParams(serviceUrl).toString();
9267
+ return useQuery({
9268
+ queryKey: [uriKey, 'queryGetCapabilities'],
9269
+ queryFn: function queryFn() {
9270
+ return privateWmtsGetCapabilities(serviceUrl, [], true);
9271
+ }
9272
+ });
9273
+ };
9222
9274
 
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 };
9275
+ 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": "11.0.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 {};