@opengeoweb/core 11.1.0 → 12.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/index.esm.js CHANGED
@@ -1,26 +1,29 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
- import React__default, { useState, useCallback, useEffect, useMemo } from 'react';
3
+ import React__default, { useState, useCallback, useEffect, useContext, useMemo } from 'react';
4
4
  import { Grid2, Box, MenuItem, Typography, useTheme, Popper, Fade, Tooltip, styled, LinearProgress, FormControl, InputLabel, Paper, List, ListItemButton, ListItemText, CircularProgress, ListSubheader, Dialog, DialogTitle, DialogContent, DialogContentText, TextField, InputAdornment, DialogActions, Button, Autocomplete, ListItemIcon, Checkbox, Switch, Select } from '@mui/material';
5
5
  import { SHARED_NAMESPACE, sharedTranslations, CustomIconButton, CustomTooltip, TooltipSelect, AlertIcon, sliderHeaderStyle, CustomSlider, ToggleMenu, tooltipContainerStyles, renderCounter, AlertBanner, CustomAccordion, PROJECTION, calculateStartSize, useWheelStopPropagation, ToolContainerDraggable, useDebounce, dateUtils, ErrorBoundary } from '@opengeoweb/shared';
6
6
  import { CollapseSmall, CollapseMedium, CollapseLarge, CollapseWindow, ExpandWindow, LayersAdd, CloudLoading, ColumnCollapsed, ColumnCollapse, Copy, None, FastForward, AutoUpdateActive, Both, Visibility, VisibilityOff, Delete, DragHandle as DragHandle$1, Cached, Add, MapAdd, WorldMapProjection, Layers, Search, Exclamation, MyLocation, Close, ExitDomain, Info, ThemeWrapper, lightTheme, FlagBritain, FlagNetherlands, FlagFinland, FlagNorway } from '@opengeoweb/theme';
7
7
  import i18n from 'i18next';
8
8
  import { initReactI18next, useTranslation, I18nextProvider } from 'react-i18next';
9
9
  import { TIMESLIDER_NAMESPACE, timesliderTranslations, defaultTimeSpan, TIME_SLIDER_LEGEND_HEIGHT, SpeedButton, TimeStepButton, AnimationLengthButton, AnimationLength, TimeSpanButton, secondsPerPxFromCanvasWidth, getNewCenterOfFixedPointZoom, OptionsMenuButton, PlayButton, defaultTimeStep, BackwardForwardStepButton, AutoUpdateButton, NowButton, handleSetNowEvent, TimeSliderButtons, TimeSliderCurrentTimeBox, TimeSliderLegend, onsetNewDateDebounced, defaultSecondsPerPx, moveSelectedTimePx, TimeSlider, getFilteredTime, ControlButtons, OptionsMenu, TimeSliderClock } from '@opengeoweb/timeslider';
10
- import { WEBMAP_REACT_NAMESPACE, webmapReactTranslations, WEBMAP_NAMESPACE, webmapTranslations, LayerInfoButton, LayerInfoDialog, MapControlButton, MapDimensionSelect, dimensionConfig, DimensionSelectDialog, DimensionSelectButton, emptyGeoJSON, registerDrawFunction, ZoomControls, LegendDialog, LegendButton, MapView, MapViewLayer, MapControls, publicLayers } from '@opengeoweb/webmap-react';
10
+ import { WEBMAP_REACT_NAMESPACE, webmapReactTranslations, WEBMAP_NAMESPACE, webmapTranslations, LayerInfoButton, LayerInfoDialog, MapControlButton, MapDimensionSelect, dimensionConfig, DimensionSelectDialog, DimensionSelectButton, MapContext, emptyGeoJSON, registerDrawFunction, MapFeatureClass, setMapCenter, ZoomControls, LegendDialog, LegendButton, MapView, MapViewLayer, MapControls, OpenLayersFeatureLayer, OpenLayersMapDraw, getIsInsideAcceptanceTime, OpenLayersLayer, useSetIntervalWhenVisible, openLayersGetMapImageStore, TimeContext, OpenLayersMapView, WMSLayer, genericOpenLayersFeatureStyle, OpenLayersGetFeatureInfo, OpenLayersZoomControl, getLayerUpdateInfo, isOpenLayersEnabled, publicLayers } from '@opengeoweb/webmap-react';
11
11
  import { useDispatch, useSelector, connect, useStore, Provider } from 'react-redux';
12
12
  import { ReactSortable } from 'react-sortablejs';
13
13
  import Sortable from 'sortablejs';
14
- import { layerTypes, layerUtils, mapSelectors, layerActions, layerSelectors, serviceSelectors, serviceActions, mapActions, mapEnums, uiSelectors, uiTypes, useSetupDialog, filterLayers, getUserAddedServices, uiActions, genericSelectors, genericActions, drawingToolSelectors, syncConstants, loadingIndicatorActions, syncGroupsSelectors, defaultLayers, getSingularDrawtoolDrawLayerId, syncGroupsSelector, syncGroupsActions, routerUtils } from '@opengeoweb/store';
14
+ import { layerTypes, layerUtils, mapSelectors, layerActions, layerSelectors, serviceSelectors, serviceActions, mapActions, mapEnums, uiSelectors, uiTypes, useSetupDialog, filterLayers, getUserAddedServices, uiActions, genericSelectors, genericActions, drawingToolSelectors, syncConstants, loadingIndicatorActions, syncGroupsSelectors, getViewObjectForSyncGroup, getViewObjectForMapId, defaultLayers, getSingularDrawtoolDrawLayerId, syncGroupsSelector, syncGroupsActions, routerUtils } from '@opengeoweb/store';
15
15
  import _, { isArray, isEqual, debounce, range } from 'lodash';
16
- import { webmapUtils, queryWMSServiceInfo, queryWMSLayers, queryWMSLayersTree, invalidateWMSGetCapabilities, LayerType, getWMSServiceId, generateLayerId, getWMJSMapById, getWMSGetFeatureInfoRequestURL, handleDateUtilsISOString, wmServiceListener, EVENT_GETCAPABILITIES_START, EVENT_GETCAPABILITIES_READY, WMLayer } from '@opengeoweb/webmap';
16
+ import { webmapUtils, queryWMSServiceInfo, queryWMSLayers, queryWMSLayersTree, invalidateWMSGetCapabilities, LayerType, getWMSServiceId, generateLayerId, getWMJSMapById, getWMSGetFeatureInfoRequestURL, getMapDimURL, handleDateUtilsISOString, wmServiceListener, EVENT_GETCAPABILITIES_START, EVENT_GETCAPABILITIES_READY, WMJSDimension, getWMLayerById, WMLayer } from '@opengeoweb/webmap';
17
17
  import { Box as Box$1, styled as styled$1 } from '@mui/system';
18
18
  import { LayerSelectButtonConnect, LayerSelectConnect } from '@opengeoweb/layer-select';
19
19
  import { useQuery, QueryClient, QueryClientProvider } from '@tanstack/react-query';
20
20
  import { getConfig } from '@opengeoweb/authentication';
21
21
  import { handleResponse } from '@opengeoweb/api';
22
22
  import axios from 'axios';
23
+ import { ImageWMS } from 'ol/source';
23
24
  import DOMPurify from 'dompurify';
25
+ import { unByKey } from 'ol/Observable';
26
+ import { toLonLat } from 'ol/proj';
24
27
  import { snackbarTypes, snackbarActions, SnackbarWrapperConnect } from '@opengeoweb/snackbar';
25
28
  import { useNavigate } from 'react-router-dom';
26
29
  import * as Sentry from '@sentry/react';
@@ -5987,7 +5990,7 @@ var geometryStyling = {
5987
5990
  'stroke-opacity': 1,
5988
5991
  'stroke-width': 4
5989
5992
  };
5990
- var makeGeoJSONFeatureFromLocation = function makeGeoJSONFeatureFromLocation(location, drawFunctionId, hoverDrawFunctionId) {
5993
+ var makeGeoJSONFeatureFromLocation = function makeGeoJSONFeatureFromLocation(location, drawFunctionId, hoverDrawFunctionId, mapFeatureClass) {
5991
5994
  var _location$geometry;
5992
5995
  var collection = {
5993
5996
  type: 'FeatureCollection',
@@ -6004,7 +6007,8 @@ var makeGeoJSONFeatureFromLocation = function makeGeoJSONFeatureFromLocation(loc
6004
6007
  properties: {
6005
6008
  name: location.name,
6006
6009
  drawFunctionId: drawFunctionId,
6007
- hoverDrawFunctionId: hoverDrawFunctionId
6010
+ hoverDrawFunctionId: hoverDrawFunctionId,
6011
+ mapFeatureClass: mapFeatureClass
6008
6012
  },
6009
6013
  geometry: {
6010
6014
  type: 'Point',
@@ -6070,14 +6074,20 @@ var hoverDrawFunction = function hoverDrawFunction(args) {
6070
6074
  };
6071
6075
  var useDrawOnMap = function useDrawOnMap(mapId, drawFunction) {
6072
6076
  var dispatch = useDispatch();
6073
- var layerId = React__default.useRef(generateLayerId()).current;
6077
+ var _useContext = useContext(MapContext),
6078
+ map = _useContext.map;
6079
+ var layerIdRef = React__default.useRef();
6080
+ React__default.useEffect(function () {
6081
+ layerIdRef.current = generateLayerId();
6082
+ }, []);
6083
+ var layerId = layerIdRef.current;
6074
6084
  var isMapPresent = useSelector(function (store) {
6075
6085
  return mapSelectors.getIsMapPresent(store, mapId);
6076
6086
  });
6077
6087
  var isLayerPresent = useSelector(function (store) {
6078
- return layerSelectors.getIsLayerPresent(store, layerId);
6088
+ return layerSelectors.getIsLayerPresent(store, layerIdRef.current);
6079
6089
  });
6080
- var shouldAddLayer = isMapPresent && !isLayerPresent;
6090
+ var shouldAddLayer = isMapPresent && !isLayerPresent && layerId;
6081
6091
  React__default.useEffect(function () {
6082
6092
  if (shouldAddLayer) {
6083
6093
  dispatch(layerActions.addLayer({
@@ -6094,7 +6104,8 @@ var useDrawOnMap = function useDrawOnMap(mapId, drawFunction) {
6094
6104
  var drawFunctionId = React__default.useRef(registerDrawFunction(drawFunction)).current;
6095
6105
  var hoverDrawFunctionId = React__default.useRef(registerDrawFunction(hoverDrawFunction)).current;
6096
6106
  var updateGeoJSON = React__default.useCallback(function (location) {
6097
- var geojson = location ? makeGeoJSONFeatureFromLocation(location, drawFunctionId, hoverDrawFunctionId) : emptyGeoJSON;
6107
+ var mapFeatureClass = (location == null ? void 0 : location.source) === 'MyMapLocation' ? MapFeatureClass.MyLocation : MapFeatureClass.GenericMarker;
6108
+ var geojson = location ? makeGeoJSONFeatureFromLocation(location, drawFunctionId, hoverDrawFunctionId, mapFeatureClass) : emptyGeoJSON;
6098
6109
  dispatch(layerActions.updateFeature({
6099
6110
  layerId: layerId,
6100
6111
  geojson: geojson
@@ -6104,8 +6115,10 @@ var useDrawOnMap = function useDrawOnMap(mapId, drawFunction) {
6104
6115
  var webMap = getWMJSMapById(mapId);
6105
6116
  if (webMap) {
6106
6117
  webMap.calculateBoundingBoxAndZoom(location.lat, location.lon);
6118
+ } else if (map) {
6119
+ setMapCenter(map, location.lon, location.lat);
6107
6120
  }
6108
- }, [mapId]);
6121
+ }, [mapId, map]);
6109
6122
  var onUpdateLocation = React__default.useCallback(function (location) {
6110
6123
  updateGeoJSON(location);
6111
6124
  if (location) {
@@ -6295,30 +6308,50 @@ var getTitle = function getTitle(layerId) {
6295
6308
  var wmjsLayer = webmapUtils.getWMLayerById(layerId);
6296
6309
  return wmjsLayer ? wmjsLayer.title || wmjsLayer.name : layerId;
6297
6310
  };
6311
+ var getFeatureInfoUrl = function getFeatureInfoUrl(layer, wmjsMap, mapPinLocation) {
6312
+ /*
6313
+ We need a wmjsLayer to build the getfeatureinfo url (getWMSGetFeatureInfoRequestURL function).
6314
+ But it seems that its dimension are lazely updated (by ReactMapView).
6315
+ Therefore make a clone of this layer and set its dimensions based on the layer object.
6316
+ Otherwise we risk making a getfeatureinfo call with outdated dimension values.
6317
+ */
6318
+ var wmjsLayer = webmapUtils.getWMLayerById(layer.id).cloneLayer();
6319
+ if (wmjsMap) {
6320
+ // WebMapJS version
6321
+ return getWMSGetFeatureInfoRequestURL(wmjsLayer, wmjsMap.getMapPin().getXY().x, wmjsMap.getMapPin().getXY().y, 'text/html');
6322
+ }
6323
+ if (mapPinLocation) {
6324
+ // OpenLayers WMS version
6325
+ var source = new ImageWMS({
6326
+ url: wmjsLayer.getmapURL,
6327
+ params: {
6328
+ LAYERS: wmjsLayer.getLayerName()
6329
+ }
6330
+ });
6331
+ return source.getFeatureInfoUrl([mapPinLocation.projectionX, mapPinLocation.projectionY], mapPinLocation.resolution, mapPinLocation.srs, {
6332
+ INFO_FORMAT: 'text/html'
6333
+ }) + "&" + getMapDimURL(wmjsLayer).toString();
6334
+ }
6335
+ return undefined;
6336
+ };
6298
6337
  /**
6299
6338
  * Make a list of GFI Layers to display.
6300
6339
  * @param layers
6301
6340
  * @param mapId
6302
6341
  * @returns
6303
6342
  */
6304
- var getLayersToUpdate = function getLayersToUpdate(layers, mapId) {
6343
+ var getLayersToUpdate = function getLayersToUpdate(mapPinLocation, layers, mapId) {
6305
6344
  var wmjsMap = webmapUtils.getWMJSMapById(mapId);
6306
- if (!wmjsMap || !layers || layers.length === 0) {
6345
+ if (!layers || layers.length === 0 || !wmjsMap && !mapPinLocation) {
6307
6346
  return [];
6308
6347
  }
6309
6348
  return layers.filter(function (layer) {
6310
6349
  return layer && layer.enabled && !!webmapUtils.getWMLayerById(layer.id);
6311
6350
  }).map(function (layer) {
6312
- /*
6313
- We need a wmjsLayer to build the getfeatureinfo url (getWMSGetFeatureInfoRequestURL function).
6314
- But it seems that its dimension are lazely updated (by ReactMapView).
6315
- Therefore make a clone of this layer and set its dimensions based on the layer object.
6316
- Otherwise we risk making a getfeatureinfo call with outdated dimension values.
6317
- */
6318
- var wmjsLayer = webmapUtils.getWMLayerById(layer.id).cloneLayer();
6351
+ var url = getFeatureInfoUrl(layer, wmjsMap, mapPinLocation);
6319
6352
  return {
6320
6353
  layerId: layer.id,
6321
- url: getWMSGetFeatureInfoRequestURL(wmjsLayer, wmjsMap.getMapPin().getXY().x, wmjsMap.getMapPin().getXY().y, 'text/html'),
6354
+ url: url,
6322
6355
  title: getTitle(layer.id)
6323
6356
  };
6324
6357
  });
@@ -6386,7 +6419,7 @@ var GetFeatureInfoDialog = function GetFeatureInfoDialog(_ref) {
6386
6419
  triggerRerender("" + layerId + isLoading);
6387
6420
  };
6388
6421
  /* Build a layerlist array with a set of arguments per layer to do the query for */
6389
- var layerToUpdateList = isOpen ? getLayersToUpdate(layers, mapId) : [];
6422
+ var layerToUpdateList = isOpen && mapPinLocation ? getLayersToUpdate(mapPinLocation, layers, mapId) : [];
6390
6423
  /*
6391
6424
  Build a string based on the GFI urls. If this changes for whatever reason we need to update.
6392
6425
  These strings can change very often, therefore they need to be debounced and only use the most recent result must be used.
@@ -6629,7 +6662,7 @@ var GetFeatureInfoButtonConnect = function GetFeatureInfoButtonConnect(_ref) {
6629
6662
  });
6630
6663
  };
6631
6664
 
6632
- var _excluded$1 = ["mapId", "children", "controls"];
6665
+ var _excluded$1 = ["mapId", "children", "controls", "initialBbox"];
6633
6666
  var ORIGIN_REACTMAPVIEWCONNECT_ONMAPCHANGEDIMENSION = 'ORIGIN_REACTMAPVIEWCONNECT_ONMAPCHANGEDIMENSION';
6634
6667
  /**
6635
6668
  * Connected component used to display the map and selected layers.
@@ -6651,8 +6684,9 @@ var MapViewConnect = function MapViewConnect(_ref) {
6651
6684
  controls = _ref$controls === void 0 ? {
6652
6685
  mapControlsPositionTop: 0,
6653
6686
  zoomControls: true
6654
- } : _ref$controls,
6655
- props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
6687
+ } : _ref$controls;
6688
+ _ref.initialBbox;
6689
+ var props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
6656
6690
  var mapRef = React.useRef(null);
6657
6691
  var store = useStore();
6658
6692
  var mapDimensions = useSelector(function (store) {
@@ -6894,10 +6928,10 @@ var MapViewConnect = function MapViewConnect(_ref) {
6894
6928
  },
6895
6929
  onUpdateLayerInformation: updateLayerInformation,
6896
6930
  onMapPinChangeLocation: mapPinChangeLocation,
6897
- onMapZoomEnd: function onMapZoomEnd(a) {
6931
+ onMapZoomEnd: function onMapZoomEnd(onZoomedCRS) {
6898
6932
  genericSetBbox({
6899
- bbox: a.bbox,
6900
- srs: a.srs,
6933
+ bbox: onZoomedCRS.bbox,
6934
+ srs: onZoomedCRS.srs,
6901
6935
  sourceId: mapId,
6902
6936
  origin: mapEnums.MapActionOrigin.map,
6903
6937
  mapId: mapId
@@ -7060,6 +7094,610 @@ var MapViewConnect = function MapViewConnect(_ref) {
7060
7094
  });
7061
7095
  };
7062
7096
 
7097
+ /* *
7098
+ * Licensed under the Apache License, Version 2.0 (the "License");
7099
+ * you may not use this file except in compliance with the License.
7100
+ * You may obtain a copy of the License at
7101
+ *
7102
+ * http://www.apache.org/licenses/LICENSE-2.0
7103
+ *
7104
+ * Unless required by applicable law or agreed to in writing, software
7105
+ * distributed under the License is distributed on an "AS IS" BASIS,
7106
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7107
+ * See the License for the specific language governing permissions and
7108
+ * limitations under the License.
7109
+ *
7110
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
7111
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
7112
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
7113
+ * */
7114
+ var useGetOpenLayersView = function useGetOpenLayersView(mapId, store) {
7115
+ var _useState = useState(),
7116
+ view = _useState[0],
7117
+ setView = _useState[1];
7118
+ var _useState2 = useState(),
7119
+ name = _useState2[0],
7120
+ setName = _useState2[1];
7121
+ var syncGroupState = syncGroupsSelectors.getSynchronizationGroupState(store.getState());
7122
+ var syncGroupView = useMemo(function () {
7123
+ var thisAreaSyncGroupId = syncGroupState.groups.allIds.find(function (id) {
7124
+ var group = syncGroupState.groups.byId[id];
7125
+ return group.type === syncConstants.SYNCGROUPS_TYPE_SETBBOX && group.targets.allIds.indexOf(mapId) !== -1;
7126
+ });
7127
+ return thisAreaSyncGroupId ? getViewObjectForSyncGroup(thisAreaSyncGroupId) : null;
7128
+ }, [mapId, syncGroupState.groups]);
7129
+ useEffect(function () {
7130
+ var mapBbox = mapSelectors.getBbox(store.getState(), mapId);
7131
+ var storedView = syncGroupView || getViewObjectForMapId(mapId);
7132
+ if (storedView.view.getCenter() === undefined && mapBbox.left !== undefined) {
7133
+ storedView.view.fit([mapBbox.left, mapBbox.bottom, mapBbox.right, mapBbox.top]);
7134
+ }
7135
+ setName(storedView.name);
7136
+ var setViewFromStoredView = function setViewFromStoredView() {
7137
+ setView(storedView.view);
7138
+ };
7139
+ setViewFromStoredView();
7140
+ var eventKey = storedView.on('change', setViewFromStoredView);
7141
+ return function () {
7142
+ unByKey(eventKey);
7143
+ };
7144
+ }, [syncGroupView, mapId, store]);
7145
+ return {
7146
+ view: view,
7147
+ name: name
7148
+ };
7149
+ };
7150
+
7151
+ /* *
7152
+ * Licensed under the Apache License, Version 2.0 (the "License");
7153
+ * you may not use this file except in compliance with the License.
7154
+ * You may obtain a copy of the License at
7155
+ *
7156
+ * http://www.apache.org/licenses/LICENSE-2.0
7157
+ *
7158
+ * Unless required by applicable law or agreed to in writing, software
7159
+ * distributed under the License is distributed on an "AS IS" BASIS,
7160
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7161
+ * See the License for the specific language governing permissions and
7162
+ * limitations under the License.
7163
+ *
7164
+ * Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
7165
+ * Copyright 2025 - Finnish Meteorological Institute (FMI)
7166
+ * Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
7167
+ * */
7168
+ var makePrefetchTimeSpan = function makePrefetchTimeSpan(timeSliderStartCenterEndTime, animationStartTime, animationEndTime, isAnimating) {
7169
+ var timeSliderTimeStepInS = timeSliderStartCenterEndTime.step * 60;
7170
+ var animationTimeStartInS = dateUtils.parseISO(animationStartTime).getTime() / 1000;
7171
+ var animationTimeEndInS = dateUtils.parseISO(animationEndTime).getTime() / 1000;
7172
+ var prefetchStart = isAnimating ? animationTimeStartInS : timeSliderStartCenterEndTime.start;
7173
+ var prefetchEnd = isAnimating ? animationTimeEndInS : timeSliderStartCenterEndTime.end;
7174
+ if (!prefetchStart || !prefetchEnd) {
7175
+ return {
7176
+ timespan: {
7177
+ start: 0,
7178
+ end: 0,
7179
+ step: 0
7180
+ },
7181
+ isAnimating: isAnimating
7182
+ };
7183
+ }
7184
+ var roundStart = Math.round(prefetchStart / timeSliderTimeStepInS) * timeSliderTimeStepInS;
7185
+ var roundEnd = Math.round(prefetchEnd / timeSliderTimeStepInS) * timeSliderTimeStepInS;
7186
+ // eslint-disable-next-line no-constant-condition
7187
+ return {
7188
+ timespan: {
7189
+ start: roundStart * 1000,
7190
+ end: roundEnd * 1000,
7191
+ step: timeSliderTimeStepInS * 1000
7192
+ },
7193
+ isAnimating: isAnimating
7194
+ };
7195
+ };
7196
+ var makeLayerInfoPayload = function makeLayerInfoPayload(payload, mapDimensions, mapId) {
7197
+ // During intialization, try to base the layer dimension on the current map dimension value.
7198
+ var updatedPayLoad = {
7199
+ origin: 'OnInitializeLayerProps in MapViewConnect',
7200
+ layerDimensions: {
7201
+ layerId: payload.layerId,
7202
+ origin: 'OnInitializeLayerProps in MapViewConnect',
7203
+ dimensions: (payload.dimensions || []).map(function (layerDim) {
7204
+ var _find;
7205
+ var currentMapDim = ((_find = (mapDimensions || []).find(function (mapDim) {
7206
+ return mapDim.name === layerDim.name;
7207
+ })) == null ? void 0 : _find.currentValue) || layerDim.currentValue;
7208
+ var wmDim = new WMJSDimension(layerDim);
7209
+ return Object.assign({}, layerDim, {
7210
+ currentValue: wmDim.getClosestValue(currentMapDim)
7211
+ });
7212
+ })
7213
+ },
7214
+ mapDimensions: {
7215
+ mapId: mapId,
7216
+ origin: 'OnInitializeLayerProps in MapViewConnect',
7217
+ dimensions: (payload.dimensions || []).map(function (layerDim) {
7218
+ var _find2;
7219
+ var currentMapDim = ((_find2 = (mapDimensions || []).find(function (mapDim) {
7220
+ return mapDim.name === layerDim.name;
7221
+ })) == null ? void 0 : _find2.currentValue) || layerDim.currentValue;
7222
+ var wmDim = new WMJSDimension(layerDim);
7223
+ return Object.assign({}, layerDim, {
7224
+ currentValue: wmDim.getClosestValue(currentMapDim)
7225
+ });
7226
+ })
7227
+ }
7228
+ };
7229
+ return updatedPayLoad;
7230
+ };
7231
+ var getCenterOfLinkedFeature = function getCenterOfLinkedFeature(feature, srs) {
7232
+ var _feature$getGeometry;
7233
+ if (feature && ((_feature$getGeometry = feature.getGeometry()) == null ? void 0 : _feature$getGeometry.getType()) === 'Point') {
7234
+ var _feature$getId;
7235
+ var projectionCoords = feature.getGeometry().getCoordinates();
7236
+ var coords = toLonLat(projectionCoords, srs);
7237
+ var id = (feature == null || (_feature$getId = feature.getId()) == null ? void 0 : _feature$getId.toString()) || '';
7238
+ return {
7239
+ lon: coords[0],
7240
+ lat: coords[1],
7241
+ id: id,
7242
+ serviceId: feature.getProperties().serviceId,
7243
+ collectionId: feature.getProperties().collectionId
7244
+ };
7245
+ }
7246
+ return null;
7247
+ };
7248
+
7249
+ var OpenLayersFeatureLayerConnect = function OpenLayersFeatureLayerConnect(_ref) {
7250
+ var layer = _ref.layer,
7251
+ layerId = _ref.layerId,
7252
+ zIndex = _ref.zIndex,
7253
+ style = _ref.style,
7254
+ hoverSelect = _ref.hoverSelect;
7255
+ var store = useStore();
7256
+ var dispatch = useDispatch();
7257
+ var updateFeature = React__default.useCallback(function (geojson, reason) {
7258
+ if (!layerId) {
7259
+ window.console.error('updateFeature without layerId');
7260
+ return;
7261
+ }
7262
+ var activeDrawToolId = drawingToolSelectors.getActiveDrawToolId(store.getState());
7263
+ var activeDrawMode = drawingToolSelectors.getActiveDrawMode(store.getState(), activeDrawToolId);
7264
+ dispatch(layerActions.updateFeature({
7265
+ geojson: geojson,
7266
+ reason: reason,
7267
+ layerId: layerId,
7268
+ shouldAllowMultipleShapes: drawingToolSelectors.getShouldAllowMultipleShapes(store.getState(), activeDrawToolId),
7269
+ geoJSONIntersectionLayerId: drawingToolSelectors.getGeoJSONIntersectionLayerId(store.getState(), activeDrawToolId),
7270
+ geoJSONIntersectionBoundsLayerId: drawingToolSelectors.getGeoJSONIntersectionBoundsLayerId(store.getState(), activeDrawToolId),
7271
+ selectionType: activeDrawMode == null ? void 0 : activeDrawMode.selectionType
7272
+ }));
7273
+ }, [dispatch, store, layerId]);
7274
+ var exitFeatureDrawMode = React__default.useCallback(function (reason) {
7275
+ if (!layerId) {
7276
+ window.console.error('exitFeatureDrawMode without layerId');
7277
+ return;
7278
+ }
7279
+ var activeDrawToolId = drawingToolSelectors.getActiveDrawToolId(store.getState());
7280
+ dispatch(layerActions.exitFeatureDrawMode({
7281
+ reason: reason,
7282
+ layerId: layerId,
7283
+ shouldAllowMultipleShapes: drawingToolSelectors.getShouldAllowMultipleShapes(store.getState(), activeDrawToolId)
7284
+ }));
7285
+ }, [dispatch, store, layerId]);
7286
+ return jsxs(Fragment, {
7287
+ children: [jsx(OpenLayersFeatureLayer, {
7288
+ featureCollection: !layer.isInEditMode ? layer.geojson : undefined,
7289
+ zIndex: zIndex,
7290
+ style: style,
7291
+ hoverSelect: hoverSelect
7292
+ }), jsx(OpenLayersMapDraw, {
7293
+ drawMode: layer.drawMode,
7294
+ viewOnlyStyle: style,
7295
+ exitDrawModeCallback: exitFeatureDrawMode,
7296
+ geojson: layer.geojson,
7297
+ isInEditMode: layer.isInEditMode || false,
7298
+ selectedFeatureIndex: layer.selectedFeatureIndex || 0,
7299
+ updateGeojson: updateFeature
7300
+ })]
7301
+ });
7302
+ };
7303
+
7304
+ var OlMapViewLayerConnect = function OlMapViewLayerConnect(layerProps) {
7305
+ var layerId = layerProps.layerId,
7306
+ mapId = layerProps.mapId,
7307
+ zIndex = layerProps.zIndex,
7308
+ debugMode = layerProps.debugMode;
7309
+ var layer = useSelector(function (store) {
7310
+ return layerSelectors.getLayerById(store, layerId);
7311
+ });
7312
+ var mapDimensions = useSelector(function (store) {
7313
+ return mapSelectors.getMapDimensions(store, mapId);
7314
+ });
7315
+ var dispatch = useDispatch();
7316
+ var onInitializeLayer = useCallback(function (initProps) {
7317
+ var updatedPayLoad = makeLayerInfoPayload(initProps, mapDimensions || [], mapId);
7318
+ dispatch(layerActions.onUpdateLayerInformation(updatedPayLoad));
7319
+ }, [dispatch, mapDimensions, mapId]);
7320
+ if (!layerId || !layer) {
7321
+ return null;
7322
+ }
7323
+ var isInsideAcceptanceTime = getIsInsideAcceptanceTime(layer.acceptanceTimeInMinutes, mapDimensions, layer.dimensions);
7324
+ return jsx(OpenLayersLayer, Object.assign({
7325
+ id: "layer-" + (layer == null ? void 0 : layer.id),
7326
+ zIndex: zIndex
7327
+ }, layer, {
7328
+ enabled: isInsideAcceptanceTime && layer.enabled,
7329
+ onInitializeLayer: onInitializeLayer,
7330
+ debugMode: debugMode
7331
+ }), "layer-" + (layer == null ? void 0 : layer.id));
7332
+ };
7333
+
7334
+ /**
7335
+ * Connected component used to display the map and selected layers.
7336
+ * Includes options to disable the map controls and legend.
7337
+ *
7338
+ * Expects the following props:
7339
+ * @param {string} mapId mapId: string - Id of the map
7340
+ * @param {object} [controls.zoomControls] **optional** controls: object - toggle the map controls, zoomControls defaults to true
7341
+ * @param {boolean} [displayTimeInMap] **optional** displayTimeInMap: boolean, toggles the mapTime, defaults to true
7342
+ * @param {boolean} [showScaleBar] **optional** showScaleBar: boolean, toggles the scaleBar, defaults to true
7343
+ * @example
7344
+ * ```<MapViewConnect mapId={mapId} controls={{ zoomControls: false }} displayTimeInMap={false} showScaleBar={false}/>```
7345
+ */
7346
+ var OlMapViewConnect = function OlMapViewConnect(_ref) {
7347
+ var mapId = _ref.mapId,
7348
+ _ref$controls = _ref.controls,
7349
+ controls = _ref$controls === void 0 ? {
7350
+ mapControlsPositionTop: 0,
7351
+ zoomControls: true
7352
+ } : _ref$controls,
7353
+ initialBbox = _ref.initialBbox,
7354
+ children = _ref.children,
7355
+ holdShiftToScroll = _ref.holdShiftToScroll;
7356
+ var store = useStore();
7357
+ var mapRef = React.useRef(null);
7358
+ var _useGetOpenLayersView = useGetOpenLayersView(mapId, store),
7359
+ view = _useGetOpenLayersView.view;
7360
+ var _React$useState = React.useState(),
7361
+ hoverLinkedFeature = _React$useState[0],
7362
+ setHoverLinkedFeature = _React$useState[1];
7363
+ var linkedPanelId = useSelector(function (store) {
7364
+ return genericSelectors.selectLinkedPanelId(store, mapId);
7365
+ });
7366
+ var mapLayerIds = useSelector(function (store) {
7367
+ return mapSelectors.getMapLayerIdsEnabled(store, mapId);
7368
+ });
7369
+ var baseLayers = useSelector(function (store) {
7370
+ return mapSelectors.getMapBaseLayers(store, mapId);
7371
+ });
7372
+ var overLayers = useSelector(function (store) {
7373
+ return mapSelectors.getMapOverLayers(store, mapId);
7374
+ });
7375
+ var featureLayers = useSelector(function (store) {
7376
+ return mapSelectors.getMapFeatureLayers(store, mapId);
7377
+ });
7378
+ var linkedFeaturesFromState = useSelector(function (store) {
7379
+ var _store$syncGroups;
7380
+ return genericSelectors.selectLinkedFeatures((_store$syncGroups = store.syncGroups) == null ? void 0 : _store$syncGroups.linkedState, mapId);
7381
+ });
7382
+ var linkedFeatures = React.useMemo(function () {
7383
+ return {
7384
+ type: 'FeatureCollection',
7385
+ features: linkedFeaturesFromState.flatMap(function (feature) {
7386
+ return feature.geoJSON.features;
7387
+ })
7388
+ };
7389
+ }, [linkedFeaturesFromState]);
7390
+ var srs = useSelector(function (store) {
7391
+ return mapSelectors.getSrs(store, mapId);
7392
+ });
7393
+ var timeSliderStartCenterEndTime = useSelector(function (store) {
7394
+ return mapSelectors.getMapTimeSliderStartCenterEndAndStep(store, mapId);
7395
+ });
7396
+ var animationStartTime = useSelector(function (store) {
7397
+ return mapSelectors.getAnimationStartTime(store, mapId);
7398
+ });
7399
+ var animationEndTime = useSelector(function (store) {
7400
+ return mapSelectors.getAnimationEndTime(store, mapId);
7401
+ });
7402
+ var isTimeScrollingEnabled = useSelector(syncGroupsSelectors.isTimeScrollingEnabled);
7403
+ var isAnimating = useSelector(function (store) {
7404
+ return mapSelectors.isAnimating(store, mapId);
7405
+ });
7406
+ var dispatch = useDispatch();
7407
+ var updateLayerInformation = React.useCallback(function (payload) {
7408
+ var _payload$layerDimensi, _payload$layerDimensi2;
7409
+ var updatedPayLoad = Object.assign({}, payload, {
7410
+ origin: 'OnInitializeLayerProps in MapViewConnect',
7411
+ layerDimensions: {
7412
+ layerId: ((_payload$layerDimensi = payload.layerDimensions) == null ? void 0 : _payload$layerDimensi.layerId) || '',
7413
+ origin: 'OnInitializeLayerProps in MapViewConnect',
7414
+ dimensions: (((_payload$layerDimensi2 = payload.layerDimensions) == null ? void 0 : _payload$layerDimensi2.dimensions) || []).map(function (layerDim) {
7415
+ return Object.assign({}, layerDim);
7416
+ })
7417
+ }
7418
+ });
7419
+ dispatch(layerActions.onUpdateLayerInformation(updatedPayLoad));
7420
+ }, [dispatch]);
7421
+ var registerMap = React.useCallback(function (payload) {
7422
+ dispatch(mapActions.registerMap(payload));
7423
+ }, [dispatch]);
7424
+ var syncGroupsAddSource = React.useCallback(function (payload) {
7425
+ dispatch(genericActions.syncGroupAddSource(payload));
7426
+ }, [dispatch]);
7427
+ var hoverSelect = React.useMemo(function () {
7428
+ return {
7429
+ active: true,
7430
+ onHover: setHoverLinkedFeature
7431
+ };
7432
+ }, []);
7433
+ var displayMapPin = useSelector(function (store) {
7434
+ return mapSelectors.getDisplayMapPin(store, mapId);
7435
+ });
7436
+ var mapPinLocation = useSelector(function (store) {
7437
+ return mapSelectors.getPinLocation(store, mapId);
7438
+ });
7439
+ var mapPinChangeLocation = React.useCallback(function (clickedLocation) {
7440
+ var _hoverLinkedFeature$g;
7441
+ var mapPinLocation = getCenterOfLinkedFeature(hoverLinkedFeature, srs) || clickedLocation;
7442
+ var selectedFeatureId = (hoverLinkedFeature == null || (_hoverLinkedFeature$g = hoverLinkedFeature.getId()) == null ? void 0 : _hoverLinkedFeature$g.toString()) || '';
7443
+ if (hoverLinkedFeature) {
7444
+ var selectedFeatureIndex = linkedFeatures.features.findIndex(function (feature) {
7445
+ return feature.id === selectedFeatureId;
7446
+ });
7447
+ dispatch(layerActions.setSelectedFeature({
7448
+ layerId: "drawlayer-" + mapId,
7449
+ selectedFeatureIndex: selectedFeatureIndex
7450
+ }));
7451
+ }
7452
+ dispatch(genericActions.addSharedData({
7453
+ panelId: linkedPanelId,
7454
+ data: {
7455
+ selectedFeatureId: selectedFeatureId
7456
+ }
7457
+ }));
7458
+ dispatch(mapActions.setMapPinLocation({
7459
+ mapId: mapId,
7460
+ mapPinLocation: mapPinLocation
7461
+ }));
7462
+ }, [dispatch, hoverLinkedFeature, linkedFeatures.features, linkedPanelId, mapId, srs]);
7463
+ var isActiveWindowId = useSelector(function (store) {
7464
+ return uiSelectors.getIsActiveWindowId(store, mapId);
7465
+ });
7466
+ useKeyboardZoomAndPan(isActiveWindowId, mapId, mapRef.current);
7467
+ useTouchZoomPan(isActiveWindowId, mapId);
7468
+ React.useEffect(function () {
7469
+ registerMap({
7470
+ mapId: mapId
7471
+ });
7472
+ syncGroupsAddSource({
7473
+ id: mapId,
7474
+ type: [syncConstants.SYNCGROUPS_TYPE_SETTIME, syncConstants.SYNCGROUPS_TYPE_SETBBOX]
7475
+ });
7476
+ dispatch(loadingIndicatorActions.setGetMapIsLoading({
7477
+ id: mapId,
7478
+ isGetMapLoading: false
7479
+ }));
7480
+ }, [dispatch, mapId, registerMap, syncGroupsAddSource]);
7481
+ var onGetMapLoadStart = React.useCallback(function () {
7482
+ dispatch(loadingIndicatorActions.setGetMapIsLoading({
7483
+ id: mapId,
7484
+ isGetMapLoading: true
7485
+ }));
7486
+ }, [dispatch, mapId]);
7487
+ var onGetMapLoadReady = React.useCallback(function () {
7488
+ dispatch(loadingIndicatorActions.setGetMapIsLoading({
7489
+ id: mapId,
7490
+ isGetMapLoading: false
7491
+ }));
7492
+ }, [dispatch, mapId]);
7493
+ React.useEffect(function () {
7494
+ if (!view) {
7495
+ return function () {};
7496
+ }
7497
+ var eventKey = view.on('change', function () {
7498
+ var _view$getViewStateAnd = view.getViewStateAndExtent(),
7499
+ extent = _view$getViewStateAnd.extent;
7500
+ dispatch(genericActions.setBbox({
7501
+ bbox: {
7502
+ left: extent[0],
7503
+ bottom: extent[1],
7504
+ right: extent[2],
7505
+ top: extent[3]
7506
+ },
7507
+ sourceId: mapId,
7508
+ srs: srs
7509
+ }));
7510
+ });
7511
+ return function () {
7512
+ unByKey(eventKey);
7513
+ };
7514
+ }, [view, mapId, srs, dispatch]);
7515
+ var prefetchTimespan = makePrefetchTimeSpan(timeSliderStartCenterEndTime, animationStartTime, animationEndTime, isAnimating);
7516
+ var layerIds = mapLayerIds.join();
7517
+ var refetchLayers = React.useCallback(function () {
7518
+ mapLayerIds == null || mapLayerIds.forEach( /*#__PURE__*/function () {
7519
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(layerId) {
7520
+ var wmLayer, layerInfo;
7521
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
7522
+ while (1) switch (_context.prev = _context.next) {
7523
+ case 0:
7524
+ if (!layerId) {
7525
+ _context.next = 15;
7526
+ break;
7527
+ }
7528
+ _context.prev = 1;
7529
+ wmLayer = getWMLayerById(layerId);
7530
+ if (!wmLayer) {
7531
+ console.warn('No wmLayer exists for layer id', layerId);
7532
+ }
7533
+ _context.next = 6;
7534
+ return wmLayer.parseLayer(true);
7535
+ case 6:
7536
+ layerInfo = getLayerUpdateInfo(wmLayer, mapId);
7537
+ updateLayerInformation && updateLayerInformation(layerInfo);
7538
+ _context.next = 13;
7539
+ break;
7540
+ case 10:
7541
+ _context.prev = 10;
7542
+ _context.t0 = _context["catch"](1);
7543
+ window.console.error(_context.t0);
7544
+ case 13:
7545
+ _context.next = 16;
7546
+ break;
7547
+ case 15:
7548
+ console.warn('Not updating layer, something is wrong.', layerId);
7549
+ case 16:
7550
+ case "end":
7551
+ return _context.stop();
7552
+ }
7553
+ }, _callee, null, [[1, 10]]);
7554
+ }));
7555
+ return function (_x) {
7556
+ return _ref2.apply(this, arguments);
7557
+ };
7558
+ }());
7559
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7560
+ }, [mapId, updateLayerInformation, layerIds]);
7561
+ useSetIntervalWhenVisible(refetchLayers, 60000);
7562
+ var isLoading = React.useRef(false);
7563
+ // UseEffect for loading indicator
7564
+ React.useEffect(function () {
7565
+ openLayersGetMapImageStore.addImageEventCallback(function () {
7566
+ var checkLoading = !!(openLayersGetMapImageStore.getNumImagesLoading() > 0);
7567
+ if (checkLoading !== isLoading.current) {
7568
+ if (checkLoading === true) {
7569
+ onGetMapLoadStart && onGetMapLoadStart();
7570
+ } else {
7571
+ onGetMapLoadReady && onGetMapLoadReady();
7572
+ }
7573
+ isLoading.current = checkLoading;
7574
+ }
7575
+ }, mapId);
7576
+ return function () {
7577
+ openLayersGetMapImageStore.removeEventCallback(mapId);
7578
+ };
7579
+ }, [mapId, onGetMapLoadReady, onGetMapLoadStart]);
7580
+ var _React$useState2 = React.useState(false),
7581
+ debugMode = _React$useState2[0],
7582
+ setDebugMode = _React$useState2[1];
7583
+ React.useEffect(function () {
7584
+ var handleKeyPress = function handleKeyPress(event) {
7585
+ if (event.isTrusted && event.key === 'd' && document.activeElement === document.body) {
7586
+ setDebugMode(function (prev) {
7587
+ return !prev;
7588
+ });
7589
+ }
7590
+ };
7591
+ document.addEventListener('keyup', handleKeyPress);
7592
+ return function () {
7593
+ document.removeEventListener('keyup', handleKeyPress);
7594
+ };
7595
+ }, [debugMode]);
7596
+ var homeExtent = React.useMemo(function () {
7597
+ return initialBbox && [initialBbox.left, initialBbox.bottom, initialBbox.right, initialBbox.top];
7598
+ }, [initialBbox]);
7599
+ var dialogType = uiTypes.DialogTypes.Search + "-" + mapId;
7600
+ var _useSetupDialog = useSetupDialog(dialogType),
7601
+ isSearchDialogOpen = _useSetupDialog.isDialogOpen;
7602
+ var layerDivStyle = React.useMemo(function () {
7603
+ var style = {
7604
+ position: 'absolute',
7605
+ zIndex: 1
7606
+ };
7607
+ if (isSearchDialogOpen) {
7608
+ style.top = 8 + 40 + "px";
7609
+ }
7610
+ return style;
7611
+ }, [isSearchDialogOpen]);
7612
+ return jsx(TimeContext.Provider, {
7613
+ value: prefetchTimespan,
7614
+ children: jsxs(OpenLayersMapView, {
7615
+ view: view,
7616
+ isFocused: isActiveWindowId,
7617
+ isMouseWheelZoomEnabled: !isTimeScrollingEnabled,
7618
+ holdShiftToScroll: holdShiftToScroll,
7619
+ children: [jsxs("div", {
7620
+ style: layerDivStyle,
7621
+ children: [baseLayers.map(function (layer, zIndex) {
7622
+ return jsx(OpenLayersLayer, Object.assign({
7623
+ id: "baselayer-" + (layer == null ? void 0 : layer.id),
7624
+ zIndex: baseLayers.length - zIndex + 10
7625
+ }, layer), "baselayer-" + (layer == null ? void 0 : layer.id));
7626
+ }), mapLayerIds.map(function (layerId, zIndex) {
7627
+ return jsx(OlMapViewLayerConnect, {
7628
+ layerId: layerId,
7629
+ zIndex: mapLayerIds.length - zIndex + 1000,
7630
+ debugMode: debugMode,
7631
+ mapId: mapId
7632
+ }, "layer-" + layerId);
7633
+ }), overLayers.map(function (layer, zIndex) {
7634
+ return jsx(WMSLayer, {
7635
+ url: layer.service,
7636
+ layerName: layer.name,
7637
+ styleName: layer.style,
7638
+ layerOptions: {
7639
+ zIndex: overLayers.length - zIndex + 2000
7640
+ }
7641
+ }, "overlayer-" + (layer == null ? void 0 : layer.id));
7642
+ }), featureLayers.map(function (layer, zIndex) {
7643
+ return jsx(OpenLayersFeatureLayerConnect, {
7644
+ layerId: layer == null ? void 0 : layer.id,
7645
+ layer: layer,
7646
+ zIndex: featureLayers.length - zIndex + 3000,
7647
+ style: genericOpenLayersFeatureStyle,
7648
+ hoverSelect: {
7649
+ active: true
7650
+ }
7651
+ }, "featurelayer-" + (layer == null ? void 0 : layer.id));
7652
+ }), jsx(OpenLayersFeatureLayer, {
7653
+ style: genericOpenLayersFeatureStyle,
7654
+ featureCollection: linkedFeatures,
7655
+ zIndex: 4000,
7656
+ hoverSelect: hoverSelect
7657
+ }), jsx(OpenLayersGetFeatureInfo, {
7658
+ mapPinLocation: mapPinLocation,
7659
+ displayMapPin: displayMapPin,
7660
+ selectLocation: mapPinChangeLocation
7661
+ })]
7662
+ }), jsxs(MapControls, {
7663
+ "data-testid": "mapControls",
7664
+ style: {
7665
+ top: controls == null ? void 0 : controls.mapControlsPositionTop
7666
+ },
7667
+ children: [(controls == null ? void 0 : controls.search) && jsx(SearchControlButtonConnect, {
7668
+ mapId: mapId
7669
+ }), (controls == null ? void 0 : controls.zoomControls) && jsx(OpenLayersZoomControl, {
7670
+ homeExtent: homeExtent
7671
+ }), (controls == null ? void 0 : controls.layerManagerAndLegend) && jsxs(Fragment, {
7672
+ children: [jsx(LayerManagerMapButtonConnect, {
7673
+ mapId: mapId
7674
+ }), jsx(LegendMapButtonConnect, {
7675
+ mapId: mapId,
7676
+ multiLegend: controls == null ? void 0 : controls.multiLegend
7677
+ })]
7678
+ }), (controls == null ? void 0 : controls.dimensionSelect) && jsx(MultiDimensionSelectMapButtonsConnect, {
7679
+ mapId: mapId
7680
+ }), (controls == null ? void 0 : controls.getFeatureInfo) && jsx(GetFeatureInfoButtonConnect, {
7681
+ mapId: mapId
7682
+ }), controls == null ? void 0 : controls.additionalMapControls]
7683
+ }), (controls == null ? void 0 : controls.multiLegend) && jsx(LegendConnect, {
7684
+ showMapId: true,
7685
+ mapId: mapId,
7686
+ multiLegend: controls == null ? void 0 : controls.multiLegend
7687
+ }), (controls == null ? void 0 : controls.search) && jsx(SearchDialogConnect, {
7688
+ mapId: mapId
7689
+ }), (controls == null ? void 0 : controls.getFeatureInfo) && jsx(GetFeatureInfoConnect, {
7690
+ showMapId: true,
7691
+ mapId: mapId
7692
+ }), jsx(LayerManagerConnect, {
7693
+ mapId: mapId,
7694
+ bounds: "parent",
7695
+ isDocked: true
7696
+ }), children]
7697
+ })
7698
+ });
7699
+ };
7700
+
7063
7701
  /* *
7064
7702
  * Licensed under the Apache License, Version 2.0 (the "License");
7065
7703
  * you may not use this file except in compliance with the License.
@@ -8042,7 +8680,7 @@ var TimeSliderClockConnect = function TimeSliderClockConnect(_ref) {
8042
8680
  });
8043
8681
  };
8044
8682
 
8045
- var _excluded = ["id", "dockedLayerManagerSize", "title", "layers", "dimensions", "shouldAutoUpdate", "shouldAnimate", "shouldAutoFetch", "bbox", "srs", "shouldShowZoomControls", "displayMapPin", "showTimeSlider", "disableTimeSlider", "displayTimeInMap", "displayLayerManagerAndLegendButtonInMap", "displayDimensionSelectButtonInMap", "multiLegend", "shouldShowLayerManager", "shouldShowDockedLayerManager", "showClock", "displayGetFeatureInfoButtonInMap", "shouldDisplayDrawControls", "displaySearchButtonInMap", "mapControls", "children", "shouldDisablePrefetching", "tileServerSettings"];
8683
+ var _excluded = ["id", "dockedLayerManagerSize", "title", "layers", "dimensions", "shouldAutoUpdate", "shouldAnimate", "shouldAutoFetch", "initialBbox", "srs", "shouldShowZoomControls", "displayMapPin", "showTimeSlider", "disableTimeSlider", "displayTimeInMap", "displayLayerManagerAndLegendButtonInMap", "displayDimensionSelectButtonInMap", "multiLegend", "shouldShowLayerManager", "shouldShowDockedLayerManager", "showClock", "displayGetFeatureInfoButtonInMap", "shouldDisplayDrawControls", "displaySearchButtonInMap", "useOl", "mapControls", "children", "shouldDisablePrefetching", "tileServerSettings"];
8046
8684
  var titleStyle = function titleStyle(theme) {
8047
8685
  return {
8048
8686
  position: 'absolute',
@@ -8077,8 +8715,8 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_ref) {
8077
8715
  shouldAnimate = _ref$shouldAnimate === void 0 ? false : _ref$shouldAnimate,
8078
8716
  _ref$shouldAutoFetch = _ref.shouldAutoFetch,
8079
8717
  shouldAutoFetch = _ref$shouldAutoFetch === void 0 ? true : _ref$shouldAutoFetch,
8080
- _ref$bbox = _ref.bbox,
8081
- bbox = _ref$bbox === void 0 ? defaultBbox.bbox : _ref$bbox,
8718
+ _ref$initialBbox = _ref.initialBbox,
8719
+ initialBbox = _ref$initialBbox === void 0 ? defaultBbox.bbox : _ref$initialBbox,
8082
8720
  _ref$srs = _ref.srs,
8083
8721
  srs = _ref$srs === void 0 ? defaultBbox.srs : _ref$srs,
8084
8722
  _ref$shouldShowZoomCo = _ref.shouldShowZoomControls,
@@ -8107,6 +8745,8 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_ref) {
8107
8745
  shouldDisplayDrawControls = _ref$shouldDisplayDra === void 0 ? false : _ref$shouldDisplayDra,
8108
8746
  _ref$displaySearchBut = _ref.displaySearchButtonInMap,
8109
8747
  displaySearchButtonInMap = _ref$displaySearchBut === void 0 ? false : _ref$displaySearchBut,
8748
+ _ref$useOl = _ref.useOl,
8749
+ useOl = _ref$useOl === void 0 ? isOpenLayersEnabled() : _ref$useOl,
8110
8750
  mapControls = _ref.mapControls,
8111
8751
  children = _ref.children,
8112
8752
  shouldDisablePrefetching = _ref.shouldDisablePrefetching,
@@ -8135,7 +8775,7 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_ref) {
8135
8775
  var mapPreset = Object.assign({
8136
8776
  layers: updatedLayers,
8137
8777
  proj: {
8138
- bbox: bbox,
8778
+ bbox: initialBbox,
8139
8779
  srs: srs
8140
8780
  },
8141
8781
  dimensions: dimensions,
@@ -8184,6 +8824,13 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_ref) {
8184
8824
  origin: 'ConfigurableMapConnect'
8185
8825
  }));
8186
8826
  }
8827
+ if (initialBbox) {
8828
+ dispatch(genericActions.setBbox({
8829
+ bbox: initialBbox,
8830
+ sourceId: mapId,
8831
+ srs: srs
8832
+ }));
8833
+ }
8187
8834
  // eslint-disable-next-line react-hooks/exhaustive-deps
8188
8835
  }, []);
8189
8836
  var mapControlConfig = useMemo(function () {
@@ -8226,7 +8873,17 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_ref) {
8226
8873
  sourceId: id,
8227
8874
  mapWindowRef: mapWindowRef
8228
8875
  })
8229
- }), jsx(MapViewConnect, {
8876
+ }), useOl ? jsx(OlMapViewConnect, {
8877
+ controls: mapControlConfig,
8878
+ displayTimeInMap: displayTimeInMap,
8879
+ showScaleBar: false,
8880
+ shouldAutoFetch: shouldAutoFetch,
8881
+ mapId: mapId,
8882
+ initialBbox: initialBbox,
8883
+ shouldDisablePrefetching: shouldDisablePrefetching,
8884
+ tileServerSettings: tileServerSettings,
8885
+ children: children
8886
+ }) : jsx(MapViewConnect, {
8230
8887
  controls: mapControlConfig,
8231
8888
  displayTimeInMap: displayTimeInMap,
8232
8889
  showScaleBar: false,
@@ -8239,7 +8896,7 @@ var ConfigurableMapConnect = function ConfigurableMapConnect(_ref) {
8239
8896
  mapId: mapId
8240
8897
  })]
8241
8898
  });
8242
- }, [mapId, title, id, mapControlConfig, tileServerSettings, disableTimeSlider, displayTimeInMap, shouldAutoFetch, shouldDisablePrefetching, children, showClock]);
8899
+ }, [mapId, title, id, useOl, initialBbox, mapControlConfig, tileServerSettings, disableTimeSlider, displayTimeInMap, shouldAutoFetch, shouldDisablePrefetching, children, showClock]);
8243
8900
  };
8244
8901
 
8245
8902
  var mapBoxStyle = function mapBoxStyle(theme) {
@@ -8335,7 +8992,7 @@ var MultiMapViewConnect = function MultiMapViewConnect(_ref) {
8335
8992
  layers: map.layers || [],
8336
8993
  autoTimeStepLayerId: map.autoTimeStepLayerId,
8337
8994
  autoUpdateLayerId: map.autoUpdateLayerId,
8338
- bbox: map.bbox,
8995
+ initialBbox: map.bbox,
8339
8996
  srs: map.srs,
8340
8997
  dimensions: map.dimensions || [],
8341
8998
  displayTimeInMap: map.displayTimeInMap || false,
@@ -8567,11 +9224,13 @@ var componentsLookUp = function componentsLookUp(_ref) {
8567
9224
  switch (componentType) {
8568
9225
  case 'Map':
8569
9226
  {
9227
+ var _mapPreset$proj;
8570
9228
  var mapPreset = initialProps.mapPreset,
8571
9229
  mapControls = initialProps.mapControls,
8572
9230
  shouldDisplayDrawControls = initialProps.shouldDisplayDrawControls,
8573
9231
  displaySearchButtonInMap = initialProps.displaySearchButtonInMap;
8574
9232
  return jsx(ConfigurableMapConnect, Object.assign({}, mapPreset, {
9233
+ initialBbox: mapPreset == null || (_mapPreset$proj = mapPreset.proj) == null ? void 0 : _mapPreset$proj.bbox,
8575
9234
  id: id,
8576
9235
  "data-testid": "coreConfigurableMapConnect",
8577
9236
  displayGetFeatureInfoButtonInMap: true,
@@ -8768,7 +9427,7 @@ var SyncGroupViewer = function SyncGroupViewer(_ref) {
8768
9427
  React.useEffect(function () {
8769
9428
  var handleKeyDown = function handleKeyDown(event) {
8770
9429
  var target = event.target;
8771
- if (target.tagName !== 'INPUT' && target.tagName !== 'TEXTAREA' && event.key === 's') {
9430
+ if (target.tagName !== 'INPUT' && target.tagName !== 'TEXTAREA' && (event.key === 's' || event.key === 'S') && !event.getModifierState('Control') && !event.getModifierState('Alt') && !event.getModifierState('AltGraph') && !event.getModifierState('Meta')) {
8772
9431
  toggleTimeScroll({
8773
9432
  isTimeScrollingEnabled: !isTimeScrollingEnabled
8774
9433
  });
@@ -9362,4 +10021,4 @@ var LanguageSelect = function LanguageSelect(_ref) {
9362
10021
  });
9363
10022
  };
9364
10023
 
9365
- export { CORE_NAMESPACE, ConfigurableMapConnect, CoreI18nProvider, CoreThemeProvider, CoreThemeStoreProvider, DemoWrapper, DemoWrapperConnect, HarmonieTempAndPrecipPreset, LanguageSelect, LayerInfoButtonConnect, LayerInfoDialogConnect, LayerManager, BaseLayerRow as LayerManagerBaseLayerRow, LayerManagerConnect, DescriptionRow as LayerManagerDescriptionRow, HeaderOptions as LayerManagerHeaderOptions, LayerContainerRow as LayerManagerLayerContainerRow, LayerManagerMapButtonConnect, LegendConnect, LegendMapButtonConnect, MapViewConnect, MultiDimensionSelectMapButtonsConnect, MultiMapMultiDimensionSelectConnect as MultiMapDimensionSelectConnect, MultiMapViewConnect, MyMapLocation, RouterWrapperConnect, SearchControlButtonConnect, SearchDialog, SearchDialogConnect, SentryRecordButton, SyncGroupViewerConnect, TimeSliderConnect, ZoomControlConnect, componentsLookUp, coreTranslations, defaultBbox, defaultConfigurations, filterMapPresets, filterServices, filterTimeSeriesServices, getLanguageFromLocalStorage, languageLocalStorageKey, saveLanguageToLocalStorage, testLayers, useFetchServices, useUpdateTimeSpan, useUpdateTimestep };
10024
+ export { CORE_NAMESPACE, ConfigurableMapConnect, CoreI18nProvider, CoreThemeProvider, CoreThemeStoreProvider, DemoWrapper, DemoWrapperConnect, HarmonieTempAndPrecipPreset, LanguageSelect, LayerInfoButtonConnect, LayerInfoDialogConnect, LayerManager, BaseLayerRow as LayerManagerBaseLayerRow, LayerManagerConnect, DescriptionRow as LayerManagerDescriptionRow, HeaderOptions as LayerManagerHeaderOptions, LayerContainerRow as LayerManagerLayerContainerRow, LayerManagerMapButtonConnect, LegendConnect, LegendMapButtonConnect, MapViewConnect, MultiDimensionSelectMapButtonsConnect, MultiMapMultiDimensionSelectConnect as MultiMapDimensionSelectConnect, MultiMapViewConnect, MyMapLocation, OlMapViewConnect, RouterWrapperConnect, SearchControlButtonConnect, SearchDialog, SearchDialogConnect, SentryRecordButton, SyncGroupViewerConnect, TimeSliderConnect, ZoomControlConnect, componentsLookUp, coreTranslations, defaultBbox, defaultConfigurations, filterMapPresets, filterServices, filterTimeSeriesServices, getLanguageFromLocalStorage, languageLocalStorageKey, saveLanguageToLocalStorage, testLayers, useFetchServices, useUpdateTimeSpan, useUpdateTimestep };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/core",
3
- "version": "11.1.0",
3
+ "version": "12.0.0",
4
4
  "description": "GeoWeb Core library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,36 +8,44 @@
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
10
  "dependencies": {
11
- "@opengeoweb/shared": "*",
12
- "react-redux": "^8.1.3",
13
- "@opengeoweb/store": "*",
14
- "@opengeoweb/timeslider": "*",
11
+ "@emotion/react": "11.14.0",
12
+ "@emotion/styled": "11.14.0",
13
+ "@mui/material": "^6.1.1",
14
+ "@mui/system": "^6.1.1",
15
+ "@mui/x-date-pickers": "7.27.1",
15
16
  "@reduxjs/toolkit": "^1.9.7",
16
- "@opengeoweb/webmap-react": "*",
17
- "@opengeoweb/webmap": "*",
18
- "@opengeoweb/theme": "*",
17
+ "@sentry/react": "^8.34.0",
18
+ "@storybook/core-events": "8.4.2",
19
+ "@storybook/preview-api": "8.4.2",
20
+ "@storybook/react": "8.4.2",
21
+ "@tanstack/query-core": "5.67.1",
22
+ "@tanstack/react-query": "^5.62.7",
23
+ "@testing-library/react": "16.0.1",
24
+ "@testing-library/user-event": "14.5.2",
25
+ "@turf/turf": "7.2.0",
19
26
  "axios": "^1.7.7",
20
- "@opengeoweb/layer-select": "*",
27
+ "date-fns": "4.1.0",
28
+ "dompurify": "^3.0.6",
29
+ "i18next": "^23.11.5",
30
+ "immer": "10.1.1",
31
+ "jest-canvas-mock": "2.5.2",
32
+ "jest-date-mock": "1.0.10",
21
33
  "lodash": "^4.17.21",
22
- "react-sortablejs": "^6.1.4",
23
- "sortablejs": "^1.15.1",
24
- "@mui/system": "^6.1.1",
25
- "@opengeoweb/snackbar": "*",
26
- "react-router-dom": "^6.21.0",
34
+ "msw": "2.7.3",
35
+ "msw-storybook-addon": "2.0.4",
36
+ "ol": "^10.4.0",
37
+ "proj4": "2.15.0",
38
+ "re-resizable": "6.11.2",
39
+ "react": "18.3.1",
27
40
  "react-draggable": "^4.4.6",
28
- "i18next": "^23.11.5",
41
+ "react-hook-form": "7.50.1",
29
42
  "react-i18next": "^15.1.1",
30
- "dompurify": "^3.0.6",
31
- "@mui/material": "^6.1.1",
32
- "@sentry/react": "^8.34.0",
33
- "@opengeoweb/authentication": "*",
34
- "@tanstack/react-query": "^5.62.7",
35
- "@opengeoweb/api": "*"
36
- },
37
- "peerDependencies": {
38
- "react": "18",
39
- "@emotion/react": "*",
40
- "@emotion/styled": "*"
43
+ "react-redux": "^8.1.3",
44
+ "react-resize-detector": "9.1.1",
45
+ "react-router-dom": "^6.21.0",
46
+ "react-sortablejs": "^6.1.4",
47
+ "react-window": "1.8.10",
48
+ "sortablejs": "^1.15.1"
41
49
  },
42
50
  "module": "./index.esm.js",
43
51
  "type": "module",
@@ -21,7 +21,7 @@ export interface ConfigurableMapConnectProps {
21
21
  tileServerSettings?: TileServerSettings;
22
22
  autoUpdateLayerId?: string;
23
23
  autoTimeStepLayerId?: string;
24
- bbox?: mapTypes.Bbox;
24
+ initialBbox?: mapTypes.Bbox;
25
25
  srs?: string;
26
26
  dimensions?: mapTypes.Dimension[];
27
27
  animationPayload?: mapTypes.AnimationPayloadType;
@@ -43,5 +43,6 @@ export interface ConfigurableMapConnectProps {
43
43
  children?: React.ReactNode;
44
44
  mapControls?: React.ReactNode;
45
45
  shouldDisablePrefetching?: boolean;
46
+ useOl?: boolean;
46
47
  }
47
48
  export declare const ConfigurableMapConnect: React.FC<ConfigurableMapConnectProps>;
@@ -1,4 +1,6 @@
1
1
  import { layerTypes } from '@opengeoweb/store';
2
+ import { IWMJSMap } from '@opengeoweb/webmap';
3
+ import { MapLocation } from '@opengeoweb/webmap-react';
2
4
  export interface GFIResult {
3
5
  data: string;
4
6
  isLoading: boolean;
@@ -8,10 +10,11 @@ export interface GFILayer {
8
10
  url: string;
9
11
  title: string;
10
12
  }
13
+ export declare const getFeatureInfoUrl: (layer: layerTypes.Layer, wmjsMap: IWMJSMap | undefined, mapPinLocation: MapLocation | null) => string | undefined;
11
14
  /**
12
15
  * Make a list of GFI Layers to display.
13
16
  * @param layers
14
17
  * @param mapId
15
18
  * @returns
16
19
  */
17
- export declare const getLayersToUpdate: (layers: layerTypes.Layer[], mapId: string) => GFILayer[];
20
+ export declare const getLayersToUpdate: (mapPinLocation: MapLocation | null, layers: layerTypes.Layer[], mapId: string) => GFILayer[];
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { layerTypes } from '@opengeoweb/store';
3
+ import { StyleLike } from 'ol/style/Style';
4
+ import { HoverSelect } from '@opengeoweb/webmap-react';
5
+ interface OpenLayersFeatureLayerConnectProps {
6
+ layer: layerTypes.FeatureLayer;
7
+ layerId?: string;
8
+ zIndex: number;
9
+ style: StyleLike;
10
+ hoverSelect?: HoverSelect;
11
+ }
12
+ export declare const OpenLayersFeatureLayerConnect: React.FC<OpenLayersFeatureLayerConnectProps>;
13
+ export {};
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
+ import { Bbox } from '@opengeoweb/webmap';
2
3
  import { MapViewProps } from '@opengeoweb/webmap-react';
3
- export interface MapControls {
4
+ export interface MapControlsProps {
4
5
  mapControlsPositionTop?: number;
5
6
  search?: boolean;
6
7
  zoomControls?: boolean;
@@ -13,11 +14,12 @@ export interface MapControls {
13
14
  export interface MapViewConnectProps extends MapViewProps {
14
15
  mapId: string;
15
16
  displayTimeInMap?: boolean;
16
- controls?: MapControls;
17
+ controls?: MapControlsProps;
17
18
  showScaleBar?: boolean;
18
19
  children?: React.ReactNode;
19
20
  showLayerInfo?: boolean;
20
21
  passiveMap?: boolean;
22
+ initialBbox?: Bbox;
21
23
  }
22
24
  export declare const ORIGIN_REACTMAPVIEWCONNECT_ONMAPCHANGEDIMENSION = "ORIGIN_REACTMAPVIEWCONNECT_ONMAPCHANGEDIMENSION";
23
25
  export declare const ORIGIN_REACTMAPVIEWCONNECT_ONUPDATELAYERINFO = "ORIGIN_REACTMAPVIEWCONNECT_ONUPDATELAYERINFO";
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { MapViewConnectProps } from './MapViewConnect';
3
+ /**
4
+ * Connected component used to display the map and selected layers.
5
+ * Includes options to disable the map controls and legend.
6
+ *
7
+ * Expects the following props:
8
+ * @param {string} mapId mapId: string - Id of the map
9
+ * @param {object} [controls.zoomControls] **optional** controls: object - toggle the map controls, zoomControls defaults to true
10
+ * @param {boolean} [displayTimeInMap] **optional** displayTimeInMap: boolean, toggles the mapTime, defaults to true
11
+ * @param {boolean} [showScaleBar] **optional** showScaleBar: boolean, toggles the scaleBar, defaults to true
12
+ * @example
13
+ * ```<MapViewConnect mapId={mapId} controls={{ zoomControls: false }} displayTimeInMap={false} showScaleBar={false}/>```
14
+ */
15
+ declare const OlMapViewConnect: React.FC<MapViewConnectProps>;
16
+ export default OlMapViewConnect;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export interface OlMapViewLayerConnectProps {
3
+ layerId: string | undefined;
4
+ mapId: string;
5
+ zIndex: number;
6
+ debugMode: boolean;
7
+ }
8
+ export declare const OlMapViewLayerConnect: (layerProps: OlMapViewLayerConnectProps) => React.ReactElement | null;
@@ -1 +1,2 @@
1
1
  export { default as MapViewConnect } from './MapViewConnect';
2
+ export { default as OlMapViewConnect } from './OlMapViewConnect';
@@ -0,0 +1,7 @@
1
+ import { TimeSliderStartCenterEndTime } from '@opengeoweb/store';
2
+ import { Dimension } from '@opengeoweb/webmap';
3
+ import { MapLocation, OnInitializeLayerProps, TimeContextType, UpdateLayerInfoPayload } from '@opengeoweb/webmap-react';
4
+ import { Feature } from 'ol';
5
+ export declare const makePrefetchTimeSpan: (timeSliderStartCenterEndTime: TimeSliderStartCenterEndTime, animationStartTime: string | undefined, animationEndTime: string | undefined, isAnimating: boolean) => TimeContextType;
6
+ export declare const makeLayerInfoPayload: (payload: OnInitializeLayerProps, mapDimensions: Dimension[], mapId: string) => UpdateLayerInfoPayload;
7
+ export declare const getCenterOfLinkedFeature: (feature: Feature | undefined, srs: string) => MapLocation | null;
@@ -0,0 +1,9 @@
1
+ import { CoreAppStore } from '@opengeoweb/store';
2
+ import { Store } from '@reduxjs/toolkit';
3
+ import { View } from 'ol';
4
+ interface UseGetOpenLayersViewValue {
5
+ view?: View;
6
+ name?: string;
7
+ }
8
+ export declare const useGetOpenLayersView: (mapId: string, store: Store<CoreAppStore>) => UseGetOpenLayersViewValue;
9
+ export {};