@opengeoweb/webmap-react 9.22.0 → 9.24.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
@@ -60,51 +60,53 @@ var en = {
60
60
  "webmap-react-point": "Point",
61
61
  "webmap-react-polygon": "Polygon",
62
62
  "webmap-react-box": "Box",
63
- "webmap-react-linestring": "LineString"
63
+ "webmap-react-linestring": "LineString",
64
+ "webmap-react-delete": "Delete"
64
65
  };
65
66
  var fi = {
66
- "webmap-react-event": "ei käännetty",
67
- "webmap-react-sent": "ei käännetty",
68
- "webmap-react-utc": "ei käännetty",
69
- "webmap-react-expires": "ei käännetty",
70
- "webmap-react-sender": "ei käännetty",
71
- "webmap-react-identifier": "ei käännetty",
72
- "webmap-react-no-layers": "ei käännetty",
73
- "webmap-react-legend": "ei käännetty",
74
- "webmap-react-title": "ei käännetty",
75
- "webmap-react-name": "ei käännetty",
76
- "webmap-react-service": "ei käännetty",
77
- "webmap-react-abstract": "ei käännetty",
78
- "webmap-react-dimensions": "ei käännetty",
79
- "webmap-react-styles": "ei käännetty",
80
- "webmap-react-bounding-box": "ei käännetty",
81
- "webmap-react-groups": "ei käännetty",
82
- "webmap-react-keywords": "ei käännetty",
83
- "webmap-react-zoom-reset": "ei käännetty",
84
- "webmap-react-zoom-in": "ei käännetty",
85
- "webmap-react-zoom-out": "ei käännetty",
86
- "webmap-react-show": "ei käännetty",
87
- "webmap-react-click-disconnect": "ei käännetty",
88
- "webmap-react-click-connect": "ei käännetty",
89
- "webmap-react-layer-info": "ei käännetty",
90
- "webmap-react-vertical-level": "ei käännetty",
91
- "webmap-react-hpa": "ei käännetty",
92
- "webmap-react-ensemble-member": "ei käännetty",
93
- "webmap-react-member": "ei käännetty",
94
- "webmap-react-probability": "ei käännetty",
95
- "webmap-react-percent": "ei käännetty",
96
- "webmap-react-level": "ei käännetty",
97
- "webmap-react-west": "ei käännetty",
98
- "webmap-react-east": "ei käännetty",
99
- "webmap-react-north": "ei käännetty",
100
- "webmap-react-south": "ei käännetty",
101
- "webmap-react-new-linestring-created": "ei käännetty",
102
- "webmap-react-new-feature": "ei käännetty",
103
- "webmap-react-new-point": "ei käännetty",
104
- "webmap-react-point": "ei käännetty",
105
- "webmap-react-polygon": "ei käännetty",
106
- "webmap-react-box": "ei käännetty",
107
- "webmap-react-linestring": "ei käännetty"
67
+ "webmap-react-event": "tapahtuma:",
68
+ "webmap-react-sent": "Lähetetty:",
69
+ "webmap-react-utc": "UTC",
70
+ "webmap-react-expires": "Vanhentunut",
71
+ "webmap-react-sender": "Lähettäjä:",
72
+ "webmap-react-identifier": "Tunniste",
73
+ "webmap-react-no-layers": "Ei karttatasoja",
74
+ "webmap-react-legend": "Selite",
75
+ "webmap-react-title": "Titteli",
76
+ "webmap-react-name": "Nimi",
77
+ "webmap-react-service": "Palvelu",
78
+ "webmap-react-abstract": "Tiivistelmä",
79
+ "webmap-react-dimensions": "Dimensiot",
80
+ "webmap-react-styles": "Tyylit",
81
+ "webmap-react-bounding-box": "Rajaava-alue",
82
+ "webmap-react-groups": "Ryhmät",
83
+ "webmap-react-keywords": "Avainsanat",
84
+ "webmap-react-zoom-reset": "Resetoi zoom",
85
+ "webmap-react-zoom-in": "Zoomaa sisään",
86
+ "webmap-react-zoom-out": "Zoomaa ulos",
87
+ "webmap-react-show": "Näytä",
88
+ "webmap-react-click-disconnect": "Irroita karttataso napsauttamalla",
89
+ "webmap-react-click-connect": "Yhdistä karttataso napsauttamalla",
90
+ "webmap-react-layer-info": "Karttatason tiedot",
91
+ "webmap-react-vertical-level": "pystytaso",
92
+ "webmap-react-hpa": "hPa",
93
+ "webmap-react-ensemble-member": "Yhdistelmämallijäsen",
94
+ "webmap-react-member": "jäsen",
95
+ "webmap-react-probability": "Todennäköisyys",
96
+ "webmap-react-percent": "%",
97
+ "webmap-react-level": "Taso",
98
+ "webmap-react-west": "länsi",
99
+ "webmap-react-east": "itä",
100
+ "webmap-react-north": "pohjoinen",
101
+ "webmap-react-south": "etelä",
102
+ "webmap-react-new-linestring-created": "Viivajonoon luotiin uusi piste",
103
+ "webmap-react-new-feature": "uusi kohde luotu",
104
+ "webmap-react-new-point": "uusi piste luotu",
105
+ "webmap-react-point": "Piste",
106
+ "webmap-react-polygon": "Monikulmio",
107
+ "webmap-react-box": "Laatikko",
108
+ "webmap-react-linestring": "Viivajono",
109
+ "webmap-react-delete": "Poista"
108
110
  };
109
111
  var no = {
110
112
  "webmap-react-event": "hendelse:",
@@ -148,7 +150,8 @@ var no = {
148
150
  "webmap-react-point": "Punkt",
149
151
  "webmap-react-polygon": "Polygon",
150
152
  "webmap-react-box": "Boks",
151
- "webmap-react-linestring": "Linje"
153
+ "webmap-react-linestring": "Linje",
154
+ "webmap-react-delete": "Fjerne"
152
155
  };
153
156
  var nl = {
154
157
  "webmap-react-event": "event:",
@@ -192,7 +195,8 @@ var nl = {
192
195
  "webmap-react-point": "Punt",
193
196
  "webmap-react-polygon": "Polygoon",
194
197
  "webmap-react-box": "Rechthoek",
195
- "webmap-react-linestring": "Lijn"
198
+ "webmap-react-linestring": "Lijn",
199
+ "webmap-react-delete": "Verwijder"
196
200
  };
197
201
  var webmapReactTranslations = {
198
202
  en: en,
@@ -6132,7 +6136,7 @@ const getIcon = selectionType => {
6132
6136
  const defaultPoint = {
6133
6137
  drawModeId: 'drawtools-point',
6134
6138
  value: DRAWMODE.POINT,
6135
- title: 'Point',
6139
+ title: `${WEBMAP_REACT_NAMESPACE}:webmap-react-point`,
6136
6140
  shape: emptyPoint,
6137
6141
  isSelectable: true,
6138
6142
  selectionType: 'point'
@@ -6140,7 +6144,7 @@ const defaultPoint = {
6140
6144
  const defaultPolygon = {
6141
6145
  drawModeId: 'drawtools-polygon',
6142
6146
  value: DRAWMODE.POLYGON,
6143
- title: 'Polygon',
6147
+ title: `${WEBMAP_REACT_NAMESPACE}:webmap-react-polygon`,
6144
6148
  shape: emptyPolygon,
6145
6149
  isSelectable: true,
6146
6150
  selectionType: 'poly'
@@ -6148,7 +6152,7 @@ const defaultPolygon = {
6148
6152
  const defaultBox = {
6149
6153
  drawModeId: 'drawtools-box',
6150
6154
  value: DRAWMODE.BOX,
6151
- title: 'Box',
6155
+ title: `${WEBMAP_REACT_NAMESPACE}:webmap-react-box`,
6152
6156
  shape: emptyBox,
6153
6157
  isSelectable: true,
6154
6158
  selectionType: 'box'
@@ -6156,7 +6160,7 @@ const defaultBox = {
6156
6160
  const defaultLineString = {
6157
6161
  drawModeId: 'drawtools-linestring',
6158
6162
  value: DRAWMODE.LINESTRING,
6159
- title: 'LineString',
6163
+ title: `${WEBMAP_REACT_NAMESPACE}:webmap-react-linestring`,
6160
6164
  shape: emptyLineString,
6161
6165
  isSelectable: true,
6162
6166
  selectionType: 'linestring'
@@ -6164,7 +6168,7 @@ const defaultLineString = {
6164
6168
  const defaultDelete = {
6165
6169
  drawModeId: 'drawtools-delete',
6166
6170
  value: 'DELETE',
6167
- title: 'Delete',
6171
+ title: `${WEBMAP_REACT_NAMESPACE}:webmap-react-delete`,
6168
6172
  shape: emptyGeoJSON,
6169
6173
  isSelectable: false,
6170
6174
  selectionType: 'delete'
@@ -9814,26 +9818,49 @@ class ReactMapView extends React.Component {
9814
9818
  currentChildren: []
9815
9819
  };
9816
9820
  this.refetchTimer = null;
9817
- this.onStartRefetchTimer = () => {
9821
+ /**
9822
+ * Last epoch time the map was visible in millisecs. Null if the map is currently visible.
9823
+ */
9824
+ this.lastVisible = null;
9825
+ this.handleVisibilityChange = () => {
9826
+ const {
9827
+ shouldAutoFetch
9828
+ } = this.props;
9829
+ const autoFetchInterval = Number(shouldAutoFetch); // Default true -> 1 minute
9830
+ const autoFetchIntervalMilliSeconds = Math.abs(autoFetchInterval) * MINUTE_TO_MILLISECOND;
9831
+ if (document.visibilityState === 'visible') {
9832
+ if (this.lastVisible &&
9833
+ // skip if last visibility change was within 1 minute (or the autoFetchInterval)
9834
+ new Date().getTime() - this.lastVisible > autoFetchIntervalMilliSeconds) {
9835
+ this.onStartRefetchTimer(true);
9836
+ }
9837
+ this.lastVisible = null;
9838
+ } else {
9839
+ this.lastVisible = new Date().getTime();
9840
+ this.clearRefetchTimer();
9841
+ }
9842
+ };
9843
+ /**
9844
+ * Start the refetch timer
9845
+ * @param force - Force a fetch and wmLayer parse immediately
9846
+ */
9847
+ this.onStartRefetchTimer = force => {
9818
9848
  const {
9819
9849
  shouldAutoFetch
9820
9850
  } = this.props;
9821
- /* TODO, Maarten Plieger, 2021-09-02, https://gitlab.com/opengeoweb/opengeoweb/-/issues/1159:
9851
+ /* TODO, Maarten Plieger, 2021-09-02
9822
9852
  This causes many issues, we should improve the update strategy.
9823
9853
  Certain presets have >20 layers. This causes 20 times parsing the GetCapabilities for a minor update of the store.
9824
9854
  */
9825
9855
  this.clearRefetchTimer();
9826
9856
  const autoFetchInterval = Number(shouldAutoFetch); // Default true -> 1 minute
9827
- this.refetchTimer = setInterval(() => {
9857
+ const refetch = () => {
9828
9858
  const {
9829
9859
  mapId
9830
9860
  } = this.props;
9831
9861
  const wmjsMap = webmapUtils.getWMJSMapById(mapId);
9832
- if (!wmjsMap) {
9833
- return;
9834
- }
9835
- const layers = wmjsMap.getLayers();
9836
- layers.forEach(layer => {
9862
+ const layers = wmjsMap === null || wmjsMap === void 0 ? void 0 : wmjsMap.getLayers();
9863
+ layers === null || layers === void 0 ? void 0 : layers.forEach(layer => {
9837
9864
  if (layer.enabled !== false) {
9838
9865
  parseWMJSLayer(layer, true).then(wmLayer => {
9839
9866
  const {
@@ -9850,7 +9877,11 @@ class ReactMapView extends React.Component {
9850
9877
  });
9851
9878
  }
9852
9879
  });
9853
- }, Math.abs(autoFetchInterval) * MINUTE_TO_MILLISECOND);
9880
+ };
9881
+ this.refetchTimer = setInterval(refetch, Math.abs(autoFetchInterval) * MINUTE_TO_MILLISECOND);
9882
+ if (force) {
9883
+ refetch();
9884
+ }
9854
9885
  };
9855
9886
  this.clearRefetchTimer = () => {
9856
9887
  if (this.refetchTimer) {
@@ -9865,6 +9896,7 @@ class ReactMapView extends React.Component {
9865
9896
  this.drawDebounced = debounce(600, this.drawDebounced);
9866
9897
  this.updateWMJSMapProps = this.updateWMJSMapProps.bind(this);
9867
9898
  this.mountWMJSMap = this.mountWMJSMap.bind(this);
9899
+ this.handleVisibilityChange = this.handleVisibilityChange.bind(this);
9868
9900
  this.onAfterSetBBoxListener = this.onAfterSetBBoxListener.bind(this);
9869
9901
  this.onUpdateBBoxListener = this.onUpdateBBoxListener.bind(this);
9870
9902
  this.onDimChangeListener = this.onDimChangeListener.bind(this);
@@ -9885,6 +9917,7 @@ class ReactMapView extends React.Component {
9885
9917
  this.mountWMJSMap();
9886
9918
  if (shouldAutoFetch) {
9887
9919
  this.onStartRefetchTimer();
9920
+ document.addEventListener('visibilitychange', this.handleVisibilityChange);
9888
9921
  }
9889
9922
  onWMJSMount(mapId);
9890
9923
  }
@@ -9898,6 +9931,7 @@ class ReactMapView extends React.Component {
9898
9931
  } = this.props;
9899
9932
  window.removeEventListener('resize', this.handleWindowResize);
9900
9933
  this.clearRefetchTimer();
9934
+ document.removeEventListener('visibilitychange', this.handleVisibilityChange);
9901
9935
  webmapUtils.unRegisterWMJSMap(mapId);
9902
9936
  /* Reset adaguc properties */
9903
9937
  this.adaguc.initialized = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/webmap-react",
3
- "version": "9.22.0",
3
+ "version": "9.24.0",
4
4
  "description": "GeoWeb react wrapper for webmap",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -22,6 +22,10 @@ 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
29
  static defaultProps: {
26
30
  srs: string;
27
31
  bbox: {
@@ -47,7 +51,12 @@ export declare class ReactMapView extends React.Component<ReactMapViewProps, Rea
47
51
  onDimChangeListener(): void;
48
52
  onAfterSetBBoxListener(): void;
49
53
  onUpdateBBoxListener(newBbox: WMBBOX): void;
50
- onStartRefetchTimer: () => void;
54
+ handleVisibilityChange: () => void;
55
+ /**
56
+ * Start the refetch timer
57
+ * @param force - Force a fetch and wmLayer parse immediately
58
+ */
59
+ onStartRefetchTimer: (force?: boolean) => void;
51
60
  clearRefetchTimer: () => void;
52
61
  updateWMJSMapProps(prevProps: ReactMapViewProps, props: ReactMapViewProps): void;
53
62
  drawDebounced(): void;
@@ -1 +1,2 @@
1
+ export declare const SECOND_TO_MILLISECOND = 1000;
1
2
  export declare const mockGeoJSON: GeoJSON.FeatureCollection;