@opengeoweb/core 6.0.2 → 6.0.3

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,7 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { forwardRef, useContext, useCallback, useEffect, createElement, PureComponent, useState, Component, cloneElement, useRef, isValidElement, createRef, useLayoutEffect } from 'react';
3
3
  import { Grid, Box as Box$2, MenuItem, Typography, useTheme as useTheme$2, Button, Popper, ListItemText, ListItemIcon, FormControl, InputLabel, Paper, List, ListItemButton, CircularProgress, ListSubheader, Dialog, DialogTitle, DialogContent, DialogContentText, TextField, InputAdornment, DialogActions, LinearProgress, Backdrop, ListItem, ListItemSecondaryAction, Checkbox, Switch, styled as styled$1, Slider, Menu, Tooltip, IconButton, ButtonGroup, Divider, Snackbar } from '@mui/material';
4
- import { CustomIconButton, TooltipSelect, AlertIcon, useControlledTooltip, CustomTooltip, tooltipContainerStyles, sliderHeaderStyle, CustomSlider, ToggleMenu, AlertBanner, CustomAccordion, ToolContainerDraggable, calculateDialogSizeAndPosition, CustomToggleButton, SearchHighlight, useMakeSureContainerStaysInsideWindow, withEggs } from '@opengeoweb/shared';
4
+ import { CustomIconButton, TooltipSelect, AlertIcon, useControlledTooltip, CustomTooltip, tooltipContainerStyles, sliderHeaderStyle, CustomSlider, ToggleMenu, AlertBanner, CustomAccordion, ToolContainerDraggable, calculateDialogSizeAndPosition, CustomToggleButton, SearchHighlight, dateUtils, useMakeSureContainerStaysInsideWindow, withEggs } from '@opengeoweb/shared';
5
5
  import { CollapseSmall, CollapseMedium, CollapseLarge, CollapseWindow, ExpandWindow, Add, Copy, None, FastForward, AutoUpdateActive, Both, Visibility, VisibilityOff, Delete, DragHandle as DragHandle$1, Cached, Filter, Search, Clear, Info, DimensionsOther, DimensionsElevation, DimensionsRefTime, DimensionsTime, Edit, Close, Home, Minus, Layers, Equalizer, Link, LinkOff, AutoUpdateInActive, Speed, Clock, Now, Animation, Options, Pause, Play, StepForward, StepBackward, dragHandlePath, ChevronDown, ChevronUp, Location, DrawPolygon, DrawRegion, List as List$1, ChevronRight, ChevronLeft, Resize, ExitDomain, ThemeWrapper, lightTheme } from '@opengeoweb/theme';
6
6
  import { useDispatch, useSelector, connect, Provider } from 'react-redux';
7
7
  import { uiTypes, uiSelectors, uiActions, layerTypes, layerUtils, layerActions, layerSelectors, serviceSelectors, serviceActions, mapSelectors, mapActions, mapEnums, mapConstants, filterLayers, getUserAddedServices, layerSelectSelectors, layerSelectActions, storeUtils, snackbarActions, layerSelectTypes, mapUtils, genericActions, drawSelectors, drawActions, syncConstants, defaultLayers, syncGroupsSelectors, syncGroupsSelector, snackbarModuleConfig, snackbarSelectors, coreModuleConfig, routerUtils, routerModuleConfig, appModuleConfig, appActions } from '@opengeoweb/store';
@@ -16959,16 +16959,17 @@ var useCanvasTarget = function useCanvasTarget(eventType) {
16959
16959
  }, [eventType, pointerEventListener]); // Only add/remove event listener when listener really changes, that is, NOT necessarily between every re-render.
16960
16960
  return [isTargetNode, nodeRef];
16961
16961
  };
16962
- var needleGeom = {
16962
+ var timeBoxGeom = {
16963
16963
  smallWidth: 126,
16964
16964
  largeWidth: 167,
16965
16965
  height: 24,
16966
16966
  cornerRadius: 5,
16967
- lineWidth: 1
16967
+ lineWidth: 1,
16968
+ iconWidth: 25
16968
16969
  };
16969
16970
  var AUTO_MOVE_AREA_PADDING = 1;
16970
16971
  var getAutoMoveAreaWidth = function getAutoMoveAreaWidth(scale) {
16971
- return (scale === mapEnums.Scale.Year ? needleGeom.largeWidth : needleGeom.smallWidth) / 2 + AUTO_MOVE_AREA_PADDING;
16972
+ return (scale === mapEnums.Scale.Year ? timeBoxGeom.largeWidth + timeBoxGeom.iconWidth : timeBoxGeom.smallWidth + timeBoxGeom.iconWidth) / 2 + AUTO_MOVE_AREA_PADDING;
16972
16973
  };
16973
16974
  /** Reusable business logic for how to handle events that set time to now (closest).
16974
16975
  * Used in NowButton and TimeSliderLegend.
@@ -17102,7 +17103,7 @@ var timeSliderUtils = /*#__PURE__*/Object.freeze({
17102
17103
  getNewCenterOfFixedPointZoom: getNewCenterOfFixedPointZoom,
17103
17104
  moveRelativeToTimePoint: moveRelativeToTimePoint,
17104
17105
  useCanvasTarget: useCanvasTarget,
17105
- needleGeom: needleGeom,
17106
+ timeBoxGeom: timeBoxGeom,
17106
17107
  AUTO_MOVE_AREA_PADDING: AUTO_MOVE_AREA_PADDING,
17107
17108
  getAutoMoveAreaWidth: getAutoMoveAreaWidth,
17108
17109
  handleSetNowEvent: handleSetNowEvent,
@@ -19329,8 +19330,8 @@ var drawRoundedRectangle = function drawRoundedRectangle(ctx, x, y, width, heigh
19329
19330
  ctx.beginPath();
19330
19331
  ctx.strokeStyle = playerTimeMarkers.fill;
19331
19332
  ctx.fillStyle = playerTimeMarkers.fill;
19332
- ctx.lineWidth = needleGeom.lineWidth;
19333
- var halfLineWidth = needleGeom.lineWidth / 2;
19333
+ ctx.lineWidth = timeBoxGeom.lineWidth;
19334
+ var halfLineWidth = timeBoxGeom.lineWidth / 2;
19334
19335
  // Top left corner
19335
19336
  ctx.moveTo(halfLineWidth, height / 2);
19336
19337
  ctx.arcTo(halfLineWidth, halfLineWidth, width / 2, halfLineWidth, cornerRadius);
@@ -19376,18 +19377,18 @@ var drawTextAnnotation = function drawTextAnnotation(ctx, x, y, text, theme) {
19376
19377
  ctx.restore();
19377
19378
  };
19378
19379
  var drawNewCurrentTimeBox = function drawNewCurrentTimeBox(ctx, selectedTime, selectedPx, span, theme, isAutoUpdating) {
19379
- var iconWidth = 25;
19380
- var smallWidth = needleGeom.smallWidth,
19381
- largeWidth = needleGeom.largeWidth,
19382
- height = needleGeom.height;
19383
- var boxWidth = span > secondsInYear ? largeWidth : smallWidth;
19380
+ var smallWidth = timeBoxGeom.smallWidth,
19381
+ largeWidth = timeBoxGeom.largeWidth,
19382
+ height = timeBoxGeom.height,
19383
+ iconWidth = timeBoxGeom.iconWidth;
19384
+ var boxWidth = span >= secondsInYear ? largeWidth : smallWidth;
19384
19385
  var needleX = selectedPx - boxWidth / 2;
19385
- var needleY = needleGeom.lineWidth;
19386
- drawRoundedRectangle(ctx, needleX - iconWidth, needleY, boxWidth + iconWidth, height, needleGeom.cornerRadius, theme);
19387
- var timeFormat = span > secondsInYear ? 'Y ddd DD MMM HH:mm' : 'ddd DD MMM HH:mm';
19386
+ var needleY = timeBoxGeom.lineWidth;
19387
+ drawRoundedRectangle(ctx, needleX - iconWidth / 2, needleY, boxWidth + iconWidth, height, timeBoxGeom.cornerRadius, theme);
19388
+ var timeFormat = span >= secondsInYear ? 'Y ddd DD MMM HH:mm' : 'ddd DD MMM HH:mm';
19388
19389
  var timeText = moment.utc(selectedTime * 1000).format(timeFormat).toString();
19389
- drawTextAnnotation(ctx, needleX + boxWidth / 2 - iconWidth, needleY + height / 2, timeText, theme);
19390
- drawAutoUpdateIcon(ctx, needleX + boxWidth - iconWidth, needleY, theme, isAutoUpdating);
19390
+ drawTextAnnotation(ctx, needleX + boxWidth / 2 - iconWidth / 2, needleY + height / 2, timeText, theme);
19391
+ drawAutoUpdateIcon(ctx, needleX + boxWidth - iconWidth / 2, needleY, theme, isAutoUpdating);
19391
19392
  };
19392
19393
  var renderTimeSliderCurrentTimeBox = function renderTimeSliderCurrentTimeBox(ctx, theme, width, height, centerTime, selected, secondsPerPx, span, isAutoUpdating) {
19393
19394
  // map unix timestamps to pixel values
@@ -19414,7 +19415,8 @@ var TimeSliderCurrentTimeBox = function TimeSliderCurrentTimeBox(_ref) {
19414
19415
  unfilteredSelectedTime = _ref.unfilteredSelectedTime,
19415
19416
  isAutoUpdating = _ref.isAutoUpdating,
19416
19417
  onSetNewDate = _ref.onSetNewDate,
19417
- setUnfilteredSelectedTime = _ref.setUnfilteredSelectedTime;
19418
+ setUnfilteredSelectedTime = _ref.setUnfilteredSelectedTime,
19419
+ onSetCenterTime = _ref.onSetCenterTime;
19418
19420
  var TIME_BOX_WIDTH = 140;
19419
19421
  var theme = useTheme$2();
19420
19422
  var _useCanvasTarget = useCanvasTarget('mousedown'),
@@ -19432,6 +19434,20 @@ var TimeSliderCurrentTimeBox = function TimeSliderCurrentTimeBox(_ref) {
19432
19434
  _React$useState6 = _slicedToArray(_React$useState5, 2),
19433
19435
  canvasWidth = _React$useState6[0],
19434
19436
  setCanvasWidth = _React$useState6[1];
19437
+ // Move TimeBox back to view if it goes out of bounds
19438
+ useEffect(function () {
19439
+ if (!(onSetCenterTime && canvasWidth && !mouseDownInTimeBox)) {
19440
+ return;
19441
+ }
19442
+ var receivedTimePx = timestampToPixel(selectedTime || moment.utc().unix(), centerTime, canvasWidth, secondsPerPx);
19443
+ var moveWidth = getAutoMoveAreaWidth(getFundamentalScale$1(secondsPerPx));
19444
+ if (receivedTimePx < moveWidth) {
19445
+ onSetCenterTime(pixelToTimestamp(canvasWidth / 2 - (moveWidth - receivedTimePx), centerTime, canvasWidth, secondsPerPx));
19446
+ } else if (receivedTimePx > canvasWidth - moveWidth) {
19447
+ onSetCenterTime(pixelToTimestamp(canvasWidth / 2 + (receivedTimePx - (canvasWidth - moveWidth)), centerTime, canvasWidth, secondsPerPx));
19448
+ }
19449
+ // eslint-disable-next-line react-hooks/exhaustive-deps
19450
+ }, [selectedTime]);
19435
19451
  var isTimeBoxArea = function isTimeBoxArea(x, selectedTimePx) {
19436
19452
  return x > selectedTimePx - TIME_BOX_WIDTH / 2 && x < selectedTimePx + TIME_BOX_WIDTH / 2;
19437
19453
  };
@@ -20270,7 +20286,8 @@ var connectRedux = connect(function (store, props) {
20270
20286
  }, {
20271
20287
  setTimeSliderUnfilteredSelectedTime: mapActions.setTimeSliderUnfilteredSelectedTime,
20272
20288
  stopMapAnimation: mapActions.mapStopAnimation,
20273
- setTime: genericActions.setTime
20289
+ setTime: genericActions.setTime,
20290
+ setCenterTime: mapActions.setTimeSliderCenterTime
20274
20291
  });
20275
20292
  var TimeSliderCurrentTimeBoxConnectComponent = function TimeSliderCurrentTimeBoxConnectComponent(_ref) {
20276
20293
  var mapId = _ref.mapId,
@@ -20286,7 +20303,8 @@ var TimeSliderCurrentTimeBoxConnectComponent = function TimeSliderCurrentTimeBox
20286
20303
  stopMapAnimation = _ref.stopMapAnimation,
20287
20304
  unfilteredSelectedTime = _ref.unfilteredSelectedTime,
20288
20305
  setTimeSliderUnfilteredSelectedTime = _ref.setTimeSliderUnfilteredSelectedTime,
20289
- setTime = _ref.setTime;
20306
+ setTime = _ref.setTime,
20307
+ setCenterTime = _ref.setCenterTime;
20290
20308
  var _getTimeBounds = getTimeBounds(dimensions),
20291
20309
  selectedTime = _getTimeBounds.selectedTime;
20292
20310
  var _getDataLimitsFromLay = getDataLimitsFromLayers(layers),
@@ -20322,6 +20340,12 @@ var TimeSliderCurrentTimeBoxConnectComponent = function TimeSliderCurrentTimeBox
20322
20340
  origin: 'TimeSliderConnect, 139',
20323
20341
  value: handleMomentISOString(newDate)
20324
20342
  });
20343
+ },
20344
+ onSetCenterTime: function onSetCenterTime(newTime) {
20345
+ setCenterTime({
20346
+ mapId: mapId,
20347
+ timeSliderCenterTime: newTime
20348
+ });
20325
20349
  }
20326
20350
  });
20327
20351
  };
@@ -25413,6 +25437,7 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
25413
25437
  _this.addPointToMultiPointFeature = _this.addPointToMultiPointFeature.bind(_assertThisInitialized$1(_this));
25414
25438
  _this.addVerticesToPolygonFeature = _this.addVerticesToPolygonFeature.bind(_assertThisInitialized$1(_this));
25415
25439
  _this.checkIfFeatureIsBox = _this.checkIfFeatureIsBox.bind(_assertThisInitialized$1(_this));
25440
+ _this.handleGeoJSONUpdate = _this.handleGeoJSONUpdate.bind(_assertThisInitialized$1(_this));
25416
25441
  _this.handleDrawMode(props.drawMode);
25417
25442
  _this.textPositions = [];
25418
25443
  _this.mouseOverPolygonCoordinates = [];
@@ -25450,15 +25475,33 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
25450
25475
  key: "componentDidMount",
25451
25476
  value: function componentDidMount() {
25452
25477
  document.addEventListener('keydown', this.handleKeyDown);
25478
+ var _this$props = this.props,
25479
+ mapId = _this$props.mapId,
25480
+ isInDeleteMode = _this$props.isInDeleteMode;
25481
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
25482
+ if (this.disabled === undefined) {
25483
+ this.disabled = isInDeleteMode;
25484
+ }
25485
+ if (webmapjs !== undefined && this.listenersInitialized !== true) {
25486
+ this.listenersInitialized = true;
25487
+ webmapjs.addListener('beforecanvasdisplay', this.beforeDraw, true);
25488
+ webmapjs.addListener('beforemousemove', this.mouseMove, true);
25489
+ webmapjs.addListener('beforemousedown', this.mouseDown, true);
25490
+ webmapjs.addListener('beforemouseup', this.mouseUp, true);
25491
+ this.disabled = false;
25492
+ }
25493
+ if (webmapjs !== undefined) {
25494
+ webmapjs.draw();
25495
+ }
25453
25496
  }
25454
25497
  }, {
25455
25498
  key: "componentDidUpdate",
25456
25499
  value: function componentDidUpdate(prevProps) {
25457
- var _this$props = this.props,
25458
- geojson = _this$props.geojson,
25459
- isInEditMode = _this$props.isInEditMode,
25460
- isInDeleteMode = _this$props.isInDeleteMode,
25461
- drawMode = _this$props.drawMode;
25500
+ var _this$props2 = this.props,
25501
+ geojson = _this$props2.geojson,
25502
+ isInEditMode = _this$props2.isInEditMode,
25503
+ isInDeleteMode = _this$props2.isInDeleteMode,
25504
+ drawMode = _this$props2.drawMode;
25462
25505
  var prevGeojson = prevProps && prevProps.geojson;
25463
25506
  var prevIsInEditMode = prevProps && prevProps.isInEditMode;
25464
25507
  var prevIsInDeleteMode = prevProps && prevProps.isInDeleteMode;
@@ -25535,7 +25578,8 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
25535
25578
  }, {
25536
25579
  key: "getPixelCoordFromGeoCoord",
25537
25580
  value: function getPixelCoordFromGeoCoord(featureCoords) {
25538
- var webmapjs = this.props.webmapjs;
25581
+ var mapId = this.props.mapId;
25582
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
25539
25583
  var _webmapjs$getSize = webmapjs.getSize(),
25540
25584
  width = _webmapjs$getSize.width,
25541
25585
  height = _webmapjs$getSize.height;
@@ -25651,10 +25695,10 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
25651
25695
  key: "mouseMove",
25652
25696
  value: function mouseMove(event) {
25653
25697
  var _this2 = this;
25654
- var _this$props2 = this.props,
25655
- isInEditMode = _this$props2.isInEditMode,
25656
- featureNrToEdit = _this$props2.featureNrToEdit,
25657
- onHoverFeature = _this$props2.onHoverFeature;
25698
+ var _this$props3 = this.props,
25699
+ isInEditMode = _this$props3.isInEditMode,
25700
+ featureNrToEdit = _this$props3.featureNrToEdit,
25701
+ onHoverFeature = _this$props3.onHoverFeature;
25658
25702
  if (event && event.rightButton === true) {
25659
25703
  return undefined;
25660
25704
  }
@@ -25685,7 +25729,8 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
25685
25729
  } else {
25686
25730
  _this2.featureEvent = undefined;
25687
25731
  }
25688
- var webmapjs = _this2.props.webmapjs;
25732
+ var mapId = _this2.props.mapId;
25733
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
25689
25734
  webmapjs && webmapjs.draw('MapDraw::onHoverFeature');
25690
25735
  };
25691
25736
  window.clearTimeout(this.mouseStoppedTimer);
@@ -25698,7 +25743,8 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
25698
25743
  if (!feature) {
25699
25744
  return undefined;
25700
25745
  }
25701
- var webmapjs = this.props.webmapjs;
25746
+ var mapId = this.props.mapId;
25747
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
25702
25748
  this.mouseGeoCoord = webmapjs.getLatLongFromPixelCoord({
25703
25749
  x: mouseX,
25704
25750
  y: mouseY
@@ -25795,9 +25841,10 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
25795
25841
  value: function insertVertexInEdge(event) {
25796
25842
  var mouseX = event.mouseX,
25797
25843
  mouseY = event.mouseY;
25798
- var _this$props3 = this.props,
25799
- webmapjs = _this$props3.webmapjs,
25800
- featureNrToEdit = _this$props3.featureNrToEdit;
25844
+ var _this$props4 = this.props,
25845
+ mapId = _this$props4.mapId,
25846
+ featureNrToEdit = _this$props4.featureNrToEdit;
25847
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
25801
25848
  if (this.myDrawMode === DRAWMODE.POLYGON) {
25802
25849
  if (this.selectedEdge !== EDGE.NONE && this.myEditMode !== EDITMODE.DELETE_FEATURES) {
25803
25850
  this.mouseGeoCoord = webmapjs.getLatLongFromPixelCoord({
@@ -25846,9 +25893,10 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
25846
25893
  value: function createNewFeature(event) {
25847
25894
  var mouseX = event.mouseX,
25848
25895
  mouseY = event.mouseY;
25849
- var _this$props4 = this.props,
25850
- webmapjs = _this$props4.webmapjs,
25851
- featureNrToEdit = _this$props4.featureNrToEdit;
25896
+ var _this$props5 = this.props,
25897
+ mapId = _this$props5.mapId,
25898
+ featureNrToEdit = _this$props5.featureNrToEdit;
25899
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
25852
25900
  if (this.myEditMode === EDITMODE.EMPTY) {
25853
25901
  this.myEditMode = EDITMODE.ADD_FEATURE;
25854
25902
  var feature = this.geojson.features[featureNrToEdit];
@@ -25960,9 +26008,10 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
25960
26008
  value: function addPointToMultiPointFeature(event) {
25961
26009
  var mouseX = event.mouseX,
25962
26010
  mouseY = event.mouseY;
25963
- var _this$props5 = this.props,
25964
- webmapjs = _this$props5.webmapjs,
25965
- featureNrToEdit = _this$props5.featureNrToEdit;
26011
+ var _this$props6 = this.props,
26012
+ mapId = _this$props6.mapId,
26013
+ featureNrToEdit = _this$props6.featureNrToEdit;
26014
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
25966
26015
  if (this.myDrawMode === DRAWMODE.MULTIPOINT) {
25967
26016
  if (this.myEditMode === EDITMODE.ADD_FEATURE && this.snappedPolygonIndex !== SNAPPEDFEATURE.NONE) {
25968
26017
  this.mouseGeoCoord = webmapjs.getLatLongFromPixelCoord({
@@ -25985,9 +26034,10 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
25985
26034
  value: function addVerticesToPolygonFeature(event) {
25986
26035
  var mouseX = event.mouseX,
25987
26036
  mouseY = event.mouseY;
25988
- var _this$props6 = this.props,
25989
- webmapjs = _this$props6.webmapjs,
25990
- featureNrToEdit = _this$props6.featureNrToEdit;
26037
+ var _this$props7 = this.props,
26038
+ mapId = _this$props7.mapId,
26039
+ featureNrToEdit = _this$props7.featureNrToEdit;
26040
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
25991
26041
  if (this.myDrawMode === DRAWMODE.POLYGON) {
25992
26042
  if (this.myEditMode === EDITMODE.ADD_FEATURE && this.snappedPolygonIndex !== SNAPPEDFEATURE.NONE) {
25993
26043
  this.mouseGeoCoord = webmapjs.getLatLongFromPixelCoord({
@@ -26010,9 +26060,10 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
26010
26060
  value: function addPointToLineStringFeature(event) {
26011
26061
  var mouseX = event.mouseX,
26012
26062
  mouseY = event.mouseY;
26013
- var _this$props7 = this.props,
26014
- webmapjs = _this$props7.webmapjs,
26015
- featureNrToEdit = _this$props7.featureNrToEdit;
26063
+ var _this$props8 = this.props,
26064
+ mapId = _this$props8.mapId,
26065
+ featureNrToEdit = _this$props8.featureNrToEdit;
26066
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
26016
26067
  if (this.myDrawMode === DRAWMODE.LINESTRING) {
26017
26068
  if (this.myEditMode === EDITMODE.ADD_FEATURE) {
26018
26069
  this.mouseGeoCoord = webmapjs.getLatLongFromPixelCoord({
@@ -26084,9 +26135,9 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
26084
26135
  }, {
26085
26136
  key: "deletePolygon",
26086
26137
  value: function deletePolygon(index) {
26087
- var _this$props8 = this.props,
26088
- featureNrToEdit = _this$props8.featureNrToEdit,
26089
- deletePolygonCallback = _this$props8.deletePolygonCallback;
26138
+ var _this$props9 = this.props,
26139
+ featureNrToEdit = _this$props9.featureNrToEdit,
26140
+ deletePolygonCallback = _this$props9.deletePolygonCallback;
26090
26141
  var feature = this.geojson.features[featureNrToEdit];
26091
26142
  feature.geometry.coordinates.splice(index, 1);
26092
26143
  if (deletePolygonCallback) {
@@ -26099,9 +26150,10 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
26099
26150
  key: "deleteFeature",
26100
26151
  value: function deleteFeature() {
26101
26152
  /* Deletes any features under the mousecursor */
26102
- var _this$props9 = this.props,
26103
- webmapjs = _this$props9.webmapjs,
26104
- featureNrToEdit = _this$props9.featureNrToEdit;
26153
+ var _this$props10 = this.props,
26154
+ mapId = _this$props10.mapId,
26155
+ featureNrToEdit = _this$props10.featureNrToEdit;
26156
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
26105
26157
  if (this.mouseIsOverVertexNr === VERTEX.NONE) {
26106
26158
  return;
26107
26159
  }
@@ -26137,9 +26189,9 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
26137
26189
  key: "mouseUp",
26138
26190
  value: function mouseUp(event) {
26139
26191
  var _this4 = this;
26140
- var _this$props10 = this.props,
26141
- isInEditMode = _this$props10.isInEditMode,
26142
- onClickFeature = _this$props10.onClickFeature;
26192
+ var _this$props11 = this.props,
26193
+ isInEditMode = _this$props11.isInEditMode,
26194
+ onClickFeature = _this$props11.onClickFeature;
26143
26195
  if (event && event.rightButton === true) {
26144
26196
  return;
26145
26197
  }
@@ -26190,13 +26242,14 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
26190
26242
  }, {
26191
26243
  key: "cancelEdit",
26192
26244
  value: function cancelEdit(cancelLastPoint) {
26193
- var _this$props11 = this.props,
26194
- isInEditMode = _this$props11.isInEditMode,
26195
- featureNrToEdit = _this$props11.featureNrToEdit;
26245
+ var _this$props12 = this.props,
26246
+ isInEditMode = _this$props12.isInEditMode,
26247
+ featureNrToEdit = _this$props12.featureNrToEdit;
26196
26248
  if (isInEditMode === false) {
26197
26249
  return;
26198
26250
  }
26199
- var webmapjs = this.props.webmapjs;
26251
+ var mapId = this.props.mapId;
26252
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
26200
26253
  /* When in addpolygon mode, finish the polygon */
26201
26254
  if (this.myEditMode === EDITMODE.ADD_FEATURE) {
26202
26255
  this.myEditMode = EDITMODE.EMPTY;
@@ -26383,7 +26436,8 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
26383
26436
  value: function componentCleanup() {
26384
26437
  // this will hold the cleanup code
26385
26438
  document.removeEventListener('keydown', this.handleKeyDown);
26386
- var webmapjs = this.props.webmapjs;
26439
+ var mapId = this.props.mapId;
26440
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
26387
26441
  if (webmapjs !== undefined && this.listenersInitialized === true) {
26388
26442
  this.listenersInitialized = undefined;
26389
26443
  webmapjs.removeListener('beforecanvasdisplay', this.beforeDraw);
@@ -26483,9 +26537,9 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
26483
26537
  just before viewer will flip the back canvas buffer to the front.
26484
26538
  You are free to draw anything you like on the canvas.
26485
26539
  */
26486
- var _this$props12 = this.props,
26487
- featureNrToEdit = _this$props12.featureNrToEdit,
26488
- isInEditMode = _this$props12.isInEditMode;
26540
+ var _this$props13 = this.props,
26541
+ featureNrToEdit = _this$props13.featureNrToEdit,
26542
+ isInEditMode = _this$props13.isInEditMode;
26489
26543
  if (!this.geojson || !this.geojson.features || !this.geojson.features.length) {
26490
26544
  return;
26491
26545
  }
@@ -26888,9 +26942,9 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
26888
26942
  }, {
26889
26943
  key: "drawLine",
26890
26944
  value: function drawLine(ctx, XYCoords, featureIndex, lineStringIndex) {
26891
- var _this$props13 = this.props,
26892
- isInEditMode = _this$props13.isInEditMode,
26893
- featureNrToEdit = _this$props13.featureNrToEdit;
26945
+ var _this$props14 = this.props,
26946
+ isInEditMode = _this$props14.isInEditMode,
26947
+ featureNrToEdit = _this$props14.featureNrToEdit;
26894
26948
  var feature = this.geojson.features[featureIndex];
26895
26949
  if (!feature || !feature.geometry) {
26896
26950
  return;
@@ -26963,9 +27017,9 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
26963
27017
  }, {
26964
27018
  key: "drawPolygon",
26965
27019
  value: function drawPolygon(ctx, XYCoords, featureIndex, polygonIndex) {
26966
- var _this$props14 = this.props,
26967
- isInEditMode = _this$props14.isInEditMode,
26968
- featureNrToEdit = _this$props14.featureNrToEdit;
27020
+ var _this$props15 = this.props,
27021
+ isInEditMode = _this$props15.isInEditMode,
27022
+ featureNrToEdit = _this$props15.featureNrToEdit;
26969
27023
  var feature = this.geojson.features[featureIndex];
26970
27024
  if (!feature || !feature.geometry) {
26971
27025
  return;
@@ -27039,7 +27093,8 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
27039
27093
  }, {
27040
27094
  key: "convertGeoCoordsToScreenCoords",
27041
27095
  value: function convertGeoCoordsToScreenCoords(featureCoords) {
27042
- var webmapjs = this.props.webmapjs;
27096
+ var mapId = this.props.mapId;
27097
+ var webmapjs = webmapUtils.getWMJSMapById(mapId);
27043
27098
  var XYCoords = [];
27044
27099
  for (var j = 0; j < featureCoords.length; j += 1) {
27045
27100
  if (featureCoords[j].length < 2) {
@@ -27134,23 +27189,6 @@ var MapDraw = /*#__PURE__*/function (_React$PureComponent) {
27134
27189
  }, {
27135
27190
  key: "render",
27136
27191
  value: function render() {
27137
- var _this$props15 = this.props,
27138
- webmapjs = _this$props15.webmapjs,
27139
- isInDeleteMode = _this$props15.isInDeleteMode;
27140
- if (this.disabled === undefined) {
27141
- this.disabled = isInDeleteMode;
27142
- }
27143
- if (webmapjs !== undefined && this.listenersInitialized !== true) {
27144
- this.listenersInitialized = true;
27145
- webmapjs.addListener('beforecanvasdisplay', this.beforeDraw, true);
27146
- webmapjs.addListener('beforemousemove', this.mouseMove, true);
27147
- webmapjs.addListener('beforemousedown', this.mouseDown, true);
27148
- webmapjs.addListener('beforemouseup', this.mouseUp, true);
27149
- this.disabled = false;
27150
- }
27151
- if (webmapjs !== undefined) {
27152
- webmapjs.draw();
27153
- }
27154
27192
  return /*#__PURE__*/React.createElement("div", null);
27155
27193
  }
27156
27194
  }]);
@@ -27181,7 +27219,7 @@ MapDraw.defaultProps = {
27181
27219
  * */
27182
27220
  var MapDrawContainer = function MapDrawContainer(_ref) {
27183
27221
  var featureLayers = _ref.featureLayers,
27184
- webMapJS = _ref.webMapJS;
27222
+ mapId = _ref.mapId;
27185
27223
  return /*#__PURE__*/React.createElement(React.Fragment, null, featureLayers.map(function (layer) {
27186
27224
  return /*#__PURE__*/React.createElement("div", {
27187
27225
  "data-testid": "featureLayer-".concat(layer.id),
@@ -27194,7 +27232,7 @@ var MapDrawContainer = function MapDrawContainer(_ref) {
27194
27232
  isInEditMode: layer.isInEditMode,
27195
27233
  isInDeleteMode: layer.isInDeleteMode,
27196
27234
  drawMode: layer.drawMode,
27197
- webmapjs: webMapJS,
27235
+ mapId: mapId,
27198
27236
  onHoverFeature: function onHoverFeature(hoverInfo) {
27199
27237
  if (layer.onHoverFeature) {
27200
27238
  layer.onHoverFeature(hoverInfo);
@@ -27684,6 +27722,9 @@ var DrawingTool = function DrawingTool(_ref) {
27684
27722
  };
27685
27723
 
27686
27724
  var opacityOptions = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0];
27725
+ var getAreaName = function getAreaName(areaName) {
27726
+ return areaName || "".concat(dateUtils.dateToString(new Date(), 'dd/MM/yyyy HH:mm', true), " UTC");
27727
+ };
27687
27728
  var SAVE_AREA_BUTTON = 'Save area';
27688
27729
  var INPUT_AREA = 'Area name';
27689
27730
  var INPUT_OPACITY = 'Opacity';
@@ -27869,15 +27910,15 @@ var DrawingToolForm = function DrawingToolForm(_ref) {
27869
27910
  var Wrapper = function Wrapper(props) {
27870
27911
  var _props$id = props.id,
27871
27912
  id = _props$id === void 0 ? '' : _props$id,
27872
- areaName = props.areaName,
27913
+ _props$areaName = props.areaName,
27914
+ areaName = _props$areaName === void 0 ? '' : _props$areaName,
27873
27915
  area = props.area;
27874
27916
  return /*#__PURE__*/React.createElement(ReactHookFormProvider, {
27875
27917
  options: Object.assign(Object.assign({}, defaultFormOptions), {
27876
27918
  defaultValues: {
27877
27919
  id: id,
27878
27920
  area: area,
27879
- // TODO https://gitlab.com/opengeoweb/opengeoweb/-/issues/3954: use date as default name
27880
- areaName: areaName || 'Area 51'
27921
+ areaName: getAreaName(areaName)
27881
27922
  }
27882
27923
  })
27883
27924
  }, /*#__PURE__*/React.createElement(DrawingToolForm, Object.assign({}, props)));
@@ -28644,7 +28685,6 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
28644
28685
  mapId = _this$props5.mapId;
28645
28686
  var adagucInitialised = this.state.adagucInitialised;
28646
28687
  var featureLayers = getFeatureLayers(children);
28647
- var wmjsMap = webmapUtils.getWMJSMapById(mapId);
28648
28688
  return /*#__PURE__*/React.createElement("div", {
28649
28689
  className: "MapView",
28650
28690
  style: {
@@ -28688,7 +28728,7 @@ var ReactMapView = /*#__PURE__*/function (_React$Component) {
28688
28728
  }
28689
28729
  }, /*#__PURE__*/React.createElement("div", null, children), adagucInitialised && featureLayers && featureLayers.length ? /*#__PURE__*/React.createElement(MapDrawContainer, {
28690
28730
  featureLayers: featureLayers,
28691
- webMapJS: wmjsMap
28731
+ mapId: mapId
28692
28732
  }) : null), passiveMap &&
28693
28733
  /*#__PURE__*/
28694
28734
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/control-has-associated-label, jsx-a11y/interactive-supports-focus
@@ -33973,12 +34013,13 @@ var componentsLookUp = function componentsLookUp(_ref) {
33973
34013
  case 'Map':
33974
34014
  {
33975
34015
  var mapPreset = initialProps.mapPreset,
33976
- mapControls = initialProps.mapControls;
34016
+ mapControls = initialProps.mapControls,
34017
+ shouldDisplayDrawControls = initialProps.shouldDisplayDrawControls;
33977
34018
  return /*#__PURE__*/React__default.createElement(ConfigurableMapConnect, Object.assign({}, mapPreset, {
33978
34019
  id: id,
33979
34020
  "data-testid": "coreConfigurableMapConnect",
33980
34021
  displayGetFeatureInfoButtonInMap: true,
33981
- shouldDisplayDrawControls: true,
34022
+ shouldDisplayDrawControls: shouldDisplayDrawControls,
33982
34023
  mapControls: mapControls
33983
34024
  }));
33984
34025
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/core",
3
- "version": "6.0.2",
3
+ "version": "6.0.3",
4
4
  "description": "GeoWeb Core library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,12 +14,12 @@
14
14
  "peerDependencies": {
15
15
  "@mui/material": "5.12.0",
16
16
  "@mui/system": "5.14.5",
17
- "@opengeoweb/api": "6.0.2",
18
- "@opengeoweb/form-fields": "6.0.2",
19
- "@opengeoweb/shared": "6.0.2",
20
- "@opengeoweb/store": "6.0.2",
21
- "@opengeoweb/theme": "6.0.2",
22
- "@opengeoweb/webmap": "6.0.2",
17
+ "@opengeoweb/api": "6.0.3",
18
+ "@opengeoweb/form-fields": "6.0.3",
19
+ "@opengeoweb/shared": "6.0.3",
20
+ "@opengeoweb/store": "6.0.3",
21
+ "@opengeoweb/theme": "6.0.3",
22
+ "@opengeoweb/webmap": "6.0.3",
23
23
  "@redux-eggs/redux-toolkit": "2.2.0",
24
24
  "@redux-eggs/saga-extension": "2.2.0",
25
25
  "@reduxjs/toolkit": "1.9.5",
@@ -11,6 +11,7 @@ export interface InitialMapProps {
11
11
  mapPreset: mapTypes.MapPreset;
12
12
  syncGroupsIds: string[];
13
13
  mapControls?: React.ReactNode;
14
+ shouldDisplayDrawControls?: boolean;
14
15
  }
15
16
  interface InitialSliderProps {
16
17
  sliderPreset: {
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  export declare const opacityOptions: number[];
3
+ export declare const getAreaName: (areaName: string) => string;
3
4
  export declare const SAVE_AREA_BUTTON = "Save area";
4
5
  export declare const INPUT_AREA = "Area name";
5
6
  export declare const INPUT_OPACITY = "Opacity";
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { GeoJsonProperties, GeometryObject, Position } from 'geojson';
3
- import { WMJSMap } from '@opengeoweb/webmap';
4
3
  import { GeoJsonFeatureType, GeoJsonFeature, GeoFeatureStyle, Coordinate } from './geojsonShapes';
5
4
  type DrawStyle = {
6
5
  x: number;
@@ -23,7 +22,7 @@ export interface FeatureEvent {
23
22
  feature: GeoJsonFeature;
24
23
  }
25
24
  export interface MapDrawProps {
26
- webmapjs: WMJSMap;
25
+ mapId: string;
27
26
  geojson: GeoJSON.FeatureCollection;
28
27
  drawMode: string;
29
28
  deletePolygonCallback?: string;
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { GeometryObject } from 'geojson';
3
- import { WMJSMap } from '@opengeoweb/webmap';
4
3
  import { DrawModeExitCallback, FeatureEvent } from './MapDraw';
5
4
  export type FeatureLayer = {
6
5
  id: string;
@@ -18,7 +17,7 @@ export type FeatureLayer = {
18
17
  };
19
18
  interface MapDrawContainerProps {
20
19
  featureLayers: FeatureLayer[];
21
- webMapJS: WMJSMap;
20
+ mapId: string;
22
21
  }
23
22
  declare const MapDrawContainer: React.FC<MapDrawContainerProps>;
24
23
  export default MapDrawContainer;
@@ -11,6 +11,7 @@ export interface TimeSliderCurrentTimeBoxProps {
11
11
  isAutoUpdating?: boolean;
12
12
  setUnfilteredSelectedTime: (unfilteredSelectedTime: number) => void;
13
13
  onSetNewDate?: (newDate: string) => void;
14
+ onSetCenterTime?: (newTime: number) => void;
14
15
  }
15
16
  declare const TimeSliderCurrentTimeBox: React.FC<TimeSliderCurrentTimeBoxProps>;
16
17
  export default TimeSliderCurrentTimeBox;
@@ -15,6 +15,7 @@ interface TimeSliderCurrentTimeBoxConnectComponentProps {
15
15
  setTimeSliderUnfilteredSelectedTime?: typeof mapActions.setTimeSliderUnfilteredSelectedTime;
16
16
  stopMapAnimation?: typeof mapActions.mapStopAnimation;
17
17
  setTime?: typeof genericActions.setTime;
18
+ setCenterTime?: typeof mapActions.setTimeSliderCenterTime;
18
19
  }
19
20
  declare const TimeSliderCurrentTimeBoxConnect: import("react-redux").ConnectedComponent<React.FC<TimeSliderCurrentTimeBoxConnectComponentProps>, {
20
21
  mapId: string;
@@ -31,6 +32,7 @@ declare const TimeSliderCurrentTimeBoxConnect: import("react-redux").ConnectedCo
31
32
  setTimeSliderUnfilteredSelectedTime?: import("@reduxjs/toolkit").ActionCreatorWithPayload<mapTypes.SetTimeSliderUnfilteredSelectedTimePayload, "mapReducer/setTimeSliderUnfilteredSelectedTime"> | undefined;
32
33
  stopMapAnimation?: import("@reduxjs/toolkit").ActionCreatorWithPayload<mapTypes.SetMapAnimationStopPayload, "mapReducer/mapStopAnimation"> | undefined;
33
34
  setTime?: import("@reduxjs/toolkit").ActionCreatorWithPayload<import("dist/libs/store/src/store/generic/types").SetTimePayload, string> | undefined;
35
+ setCenterTime?: import("@reduxjs/toolkit").ActionCreatorWithPayload<mapTypes.SetTimeSliderCenterTimePayload, "mapReducer/setTimeSliderCenterTime"> | undefined;
34
36
  context?: React.Context<import("react-redux").ReactReduxContextValue<any, import("redux").AnyAction>> | undefined;
35
37
  store?: import("redux").Store<any, import("redux").AnyAction> | undefined;
36
38
  }>;
@@ -69,12 +69,13 @@ export declare const moveRelativeToTimePoint: (timePoint: number, timePointPx: n
69
69
  * ...
70
70
  */
71
71
  export declare const useCanvasTarget: (eventType: string) => [boolean, React.RefObject<CanvasComponent>];
72
- export declare const needleGeom: {
72
+ export declare const timeBoxGeom: {
73
73
  smallWidth: number;
74
74
  largeWidth: number;
75
75
  height: number;
76
76
  cornerRadius: number;
77
77
  lineWidth: number;
78
+ iconWidth: number;
78
79
  };
79
80
  export declare const AUTO_MOVE_AREA_PADDING = 1;
80
81
  export declare const getAutoMoveAreaWidth: (scale: mapEnums.Scale) => number;