@opengeoweb/webmap-react 9.26.0 → 9.27.1

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,7 +1,8 @@
1
+ import { WEBMAP_NAMESPACE, webmapTranslations, legendImageStore, WMImageEventType, webmapUtils, getLegendGraphicURLForLayer, getPixelCoordFromLatLong, WMJSMAP_LONLAT_EPSGCODE, getLatLongFromPixelCoord, LayerType, getWMJSMapById, debugLogger, DebugType, WMLayer, registerWMLayer, WMBBOX, getWMLayerById, WMJSMap, tilesettings } from '@opengeoweb/webmap';
2
+ export { WEBMAP_NAMESPACE, webmapTranslations } from '@opengeoweb/webmap';
1
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
4
  import * as React from 'react';
3
5
  import React__default, { useRef, useState, useEffect } from 'react';
4
- import { legendImageStore, WMImageEventType, webmapUtils, getLegendGraphicURLForLayer, getPixelCoordFromLatLong, WMJSMAP_LONLAT_EPSGCODE, getLatLongFromPixelCoord, LayerType, getWMJSMapById, debugLogger, DebugType, WMLayer, registerWMLayer, WMBBOX, getWMLayerById, WMJSMap, tilesettings } from '@opengeoweb/webmap';
5
6
  import { CustomTooltip, CanvasComponent, ToolContainerDraggable, CustomIconButton, dateUtils, PROJECTION } from '@opengeoweb/shared';
6
7
  import i18n from 'i18next';
7
8
  import { initReactI18next, useTranslation } from 'react-i18next';
@@ -9,7 +10,7 @@ import { Paper, Box, Typography, Grid, TextField, FormControl, InputLabel, Selec
9
10
  import { Home, Add, Minus, List, Delete, Edit, DrawRegion, DrawPolygon, Location, DrawFIRLand, ArrowUp, Equalizer, DimensionsElevation, Link, LinkOff, Info, DimensionsOther, DimensionsRefTime, DimensionsTime } from '@opengeoweb/theme';
10
11
  import _, { cloneDeep } from 'lodash';
11
12
  import * as turf from '@turf/turf';
12
- import { polygonToLineString, booleanClockwise, rewind } from '@turf/turf';
13
+ import { polygonToLine, booleanClockwise, rewind } from '@turf/turf';
13
14
  import proj4 from 'proj4';
14
15
  import { produce } from 'immer';
15
16
  import { debounce } from 'throttle-debounce';
@@ -1832,16 +1833,20 @@ i18n.use(initReactI18next).init({
1832
1833
  },
1833
1834
  resources: {
1834
1835
  en: {
1835
- [WEBMAP_REACT_NAMESPACE]: webmapReactTranslations.en
1836
+ [WEBMAP_REACT_NAMESPACE]: webmapReactTranslations.en,
1837
+ [WEBMAP_NAMESPACE]: webmapTranslations.en
1836
1838
  },
1837
1839
  fi: {
1838
- [WEBMAP_REACT_NAMESPACE]: webmapReactTranslations.fi
1840
+ [WEBMAP_REACT_NAMESPACE]: webmapReactTranslations.fi,
1841
+ [WEBMAP_NAMESPACE]: webmapTranslations.fi
1839
1842
  },
1840
1843
  no: {
1841
- [WEBMAP_REACT_NAMESPACE]: webmapReactTranslations.no
1844
+ [WEBMAP_REACT_NAMESPACE]: webmapReactTranslations.no,
1845
+ [WEBMAP_NAMESPACE]: webmapTranslations.no
1842
1846
  },
1843
1847
  nl: {
1844
- [WEBMAP_REACT_NAMESPACE]: webmapReactTranslations.nl
1848
+ [WEBMAP_REACT_NAMESPACE]: webmapReactTranslations.nl,
1849
+ [WEBMAP_NAMESPACE]: webmapTranslations.nl
1845
1850
  }
1846
1851
  }
1847
1852
  });
@@ -6025,7 +6030,7 @@ const intersectPolygonGeoJSONS = (a, b, geoJSONProperties = {
6025
6030
  };
6026
6031
  const simplifiedA = turf.simplify(featureA, options);
6027
6032
  const simplifiedB = turf.simplify(featureB, options);
6028
- const intersection = turf.intersect(simplifiedA, simplifiedB);
6033
+ const intersection = turf.intersect(turf.featureCollection([simplifiedA, simplifiedB]));
6029
6034
  return addFeatureProperties({
6030
6035
  type: 'FeatureCollection',
6031
6036
  features: intersection === null ? [{
@@ -6137,7 +6142,7 @@ const rewindGeometry = geoJSON => {
6137
6142
  const {
6138
6143
  geometry
6139
6144
  } = geoJSON.features[0];
6140
- const lineString = polygonToLineString(geometry);
6145
+ const lineString = polygonToLine(geometry);
6141
6146
  if (booleanClockwise(lineString.geometry.coordinates)) {
6142
6147
  // eslint-disable-next-line no-param-reassign
6143
6148
  geoJSONDraft.features[0].geometry = rewind(geoJSONDraft.features[0].geometry);
@@ -9892,10 +9897,7 @@ class ReactMapView extends React.Component {
9892
9897
  currentChildren: []
9893
9898
  };
9894
9899
  this.refetchTimer = null;
9895
- /**
9896
- * Last epoch time the map was visible in millisecs. Null if the map is currently visible.
9897
- */
9898
- this.lastVisible = null;
9900
+ this.lastRefetched = null;
9899
9901
  this.handleVisibilityChange = () => {
9900
9902
  const {
9901
9903
  shouldAutoFetch
@@ -9903,14 +9905,14 @@ class ReactMapView extends React.Component {
9903
9905
  const autoFetchInterval = Number(shouldAutoFetch); // Default true -> 1 minute
9904
9906
  const autoFetchIntervalMilliSeconds = Math.abs(autoFetchInterval) * MINUTE_TO_MILLISECOND;
9905
9907
  if (document.visibilityState === 'visible') {
9906
- if (this.lastVisible &&
9907
- // skip if last visibility change was within 1 minute (or the autoFetchInterval)
9908
- new Date().getTime() - this.lastVisible > autoFetchIntervalMilliSeconds) {
9908
+ if (this.lastRefetched &&
9909
+ // skip if last refetch was within 1 minute (or the autoFetchInterval)
9910
+ new Date().getTime() - this.lastRefetched > autoFetchIntervalMilliSeconds) {
9909
9911
  this.onStartRefetchTimer(true);
9912
+ } else {
9913
+ this.onStartRefetchTimer();
9910
9914
  }
9911
- this.lastVisible = null;
9912
9915
  } else {
9913
- this.lastVisible = new Date().getTime();
9914
9916
  this.clearRefetchTimer();
9915
9917
  }
9916
9918
  };
@@ -9929,6 +9931,7 @@ class ReactMapView extends React.Component {
9929
9931
  this.clearRefetchTimer();
9930
9932
  const autoFetchInterval = Number(shouldAutoFetch); // Default true -> 1 minute
9931
9933
  const refetch = () => {
9934
+ this.lastRefetched = new Date().getTime();
9932
9935
  const {
9933
9936
  mapId
9934
9937
  } = this.props;
@@ -10274,7 +10277,8 @@ class ReactMapView extends React.Component {
10274
10277
  listeners,
10275
10278
  srs,
10276
10279
  bbox,
10277
- onMapPinChangeLocation
10280
+ onMapPinChangeLocation,
10281
+ shouldDisablePrefetching
10278
10282
  } = this.props;
10279
10283
  /* Check if we have something to mount IWMJSMap on */
10280
10284
  if (this.adagucWebMapJSRef.current === null) {
@@ -10288,6 +10292,7 @@ class ReactMapView extends React.Component {
10288
10292
  webmapUtils.unRegisterWMJSMap(mapId);
10289
10293
  }
10290
10294
  const wmjsMap = new WMJSMap(this.adagucWebMapJSRef.current);
10295
+ wmjsMap.shouldPrefetch = !shouldDisablePrefetching;
10291
10296
  this.adaguc.currentChildren = [];
10292
10297
  this.adaguc.baseLayers = [];
10293
10298
  webmapUtils.registerWMJSMap(wmjsMap, mapId);
@@ -10829,6 +10834,7 @@ const MapView = _a => {
10829
10834
  children: jsx(ReactMapView, Object.assign({}, reactMapViewProps, {
10830
10835
  showLegend: false,
10831
10836
  displayTimeInMap: false,
10837
+ shouldDisablePrefetching: props.shouldDisablePrefetching,
10832
10838
  onWMJSMount: id => {
10833
10839
  const webMapJS = webmapUtils.getWMJSMapById(id);
10834
10840
  if (!webMapJS) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/webmap-react",
3
- "version": "9.26.0",
3
+ "version": "9.27.1",
4
4
  "description": "GeoWeb react wrapper for webmap",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  "@opengeoweb/shared": "*",
15
15
  "lodash": "^4.17.21",
16
16
  "proj4": "^2.9.2",
17
- "@turf/turf": "^6.5.0",
17
+ "@turf/turf": "^7.1.0",
18
18
  "immer": "^10.0.3",
19
19
  "react-resize-detector": "^9.1.0",
20
20
  "throttle-debounce": "^5.0.0",
@@ -23,7 +23,9 @@
23
23
  "react-i18next": "^14.1.2"
24
24
  },
25
25
  "peerDependencies": {
26
- "react": "18"
26
+ "react": "18",
27
+ "@emotion/react": "*",
28
+ "@emotion/styled": "*"
27
29
  },
28
30
  "module": "./index.esm.js",
29
31
  "type": "module",
package/src/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { WEBMAP_NAMESPACE, webmapTranslations } from '@opengeoweb/webmap';
1
2
  import webmapReactTranslations from '../locales/webmap-react.json';
2
3
  export * from './lib';
3
4
  export { webmapReactTranslations };
5
+ export { WEBMAP_NAMESPACE, webmapTranslations };
@@ -1,5 +1,4 @@
1
- import { Feature } from '@turf/turf';
2
- import { FeatureCollection, GeoJsonProperties, Point } from 'geojson';
1
+ import { Feature, FeatureCollection, GeoJsonProperties, Point } from 'geojson';
3
2
  import { Bbox } from '@opengeoweb/webmap';
4
3
  import { DrawMode, SelectionType } from './types';
5
4
  /**
@@ -22,10 +22,7 @@ export declare class ReactMapView extends React.Component<ReactMapViewProps, Rea
22
22
  adagucContainerRef: React.RefObject<HTMLDivElement>;
23
23
  adagucWebMapJSRef: React.RefObject<HTMLDivElement>;
24
24
  refetchTimer: NodeJS.Timeout | number | null;
25
- /**
26
- * Last epoch time the map was visible in millisecs. Null if the map is currently visible.
27
- */
28
- lastVisible: number | null;
25
+ lastRefetched: number | null;
29
26
  static defaultProps: {
30
27
  srs: "EPSG:3857";
31
28
  bbox: {
@@ -26,6 +26,7 @@ export interface ReactMapViewProps {
26
26
  showLayerInfo?: boolean;
27
27
  disableMapPin?: boolean;
28
28
  holdShiftToScroll?: boolean;
29
+ shouldDisablePrefetching?: boolean;
29
30
  onWMJSMount?: (mapId: string) => void;
30
31
  onWMJSUnMount?: (mapId: string) => void;
31
32
  onMapChangeDimension?: (payload: SetMapDimensionPayload) => void;