@evergis/react 3.1.1 → 3.1.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/dist/components/ErrorBoundary/index.d.ts +12 -0
- package/dist/components/ErrorBoundary/styled.d.ts +1 -0
- package/dist/components/ErrorBoundary/types.d.ts +7 -0
- package/dist/components/Map/Map.d.ts +5 -0
- package/dist/components/Map/components/BuildingsLayer/BuildingsLayer.d.ts +3 -0
- package/dist/components/Map/components/BuildingsLayer/index.d.ts +2 -0
- package/dist/components/Map/components/BuildingsLayer/types.d.ts +4 -0
- package/dist/components/Map/components/Layer/Layer.d.ts +3 -0
- package/dist/components/Map/components/Layer/RasterLayer.d.ts +3 -0
- package/dist/components/Map/components/Layer/VectorLayer.d.ts +3 -0
- package/dist/components/Map/components/Layer/constants.d.ts +137 -0
- package/dist/components/Map/components/Layer/index.d.ts +2 -0
- package/dist/components/Map/components/Layer/types.d.ts +12 -0
- package/dist/components/Map/components/Layer/utils/getClientStyleItemPrefixSuffix.d.ts +3 -0
- package/dist/components/Map/components/index.d.ts +2 -0
- package/dist/components/Map/index.d.ts +3 -0
- package/dist/components/Map/styled.d.ts +4 -0
- package/dist/components/Map/types.d.ts +10 -0
- package/dist/components/MapContext/MapContext.d.ts +2 -0
- package/dist/components/MapContext/MapProvider.d.ts +3 -0
- package/dist/components/MapContext/index.d.ts +3 -0
- package/dist/components/MapContext/types.d.ts +138 -0
- package/dist/components/ResizablePanel/ResizablePanel.d.ts +3 -0
- package/dist/components/ResizablePanel/index.d.ts +2 -0
- package/dist/components/ResizablePanel/styled.d.ts +11 -0
- package/dist/components/ResizablePanel/types.d.ts +14 -0
- package/dist/components/ServerNotificationsContext/ServerNotificationsContext.d.ts +2 -0
- package/dist/components/ServerNotificationsContext/ServerNotificationsProvider.d.ts +3 -0
- package/dist/components/ServerNotificationsContext/index.d.ts +3 -0
- package/dist/components/ServerNotificationsContext/types.d.ts +12 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/core/classification/findAttributeInExpression.d.ts +2 -0
- package/dist/core/classification/getActualExtrusionHeight.d.ts +2 -0
- package/dist/core/classification/index.d.ts +3 -0
- package/dist/core/classification/parseClientStyle.d.ts +2 -0
- package/dist/core/feature/convertSpToTurfFeature.d.ts +3 -0
- package/dist/core/feature/index.d.ts +1 -0
- package/dist/core/geometrySelection/drawModeToGeometrySelectionType.d.ts +3 -0
- package/dist/core/geometrySelection/getGeometrySelectionTurfFeature.d.ts +3 -0
- package/dist/core/geometrySelection/index.d.ts +2 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/types/index.d.ts +2 -0
- package/dist/core/types/map.d.ts +5 -0
- package/dist/core/types/styling.d.ts +15 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/map/index.d.ts +22 -0
- package/dist/hooks/map/useCurrentSelectedFeature.d.ts +2 -0
- package/dist/hooks/map/useEditingFeature.d.ts +1 -0
- package/dist/hooks/map/useEwktGeometry.d.ts +1 -0
- package/dist/hooks/map/useGeometryEditor.d.ts +2 -0
- package/dist/hooks/map/useGeometrySelection.d.ts +2 -0
- package/dist/hooks/map/useGeometrySelectionBuffer.d.ts +1 -0
- package/dist/hooks/map/useMapContext.d.ts +1 -0
- package/dist/hooks/map/useMapDraw/customModes.d.ts +2 -0
- package/dist/hooks/map/useMapDraw/customStyles.d.ts +58 -0
- package/dist/hooks/map/useMapDraw/index.d.ts +1 -0
- package/dist/hooks/map/useRedrawLayer.d.ts +1 -0
- package/dist/hooks/map/useSelectFeaturesCount.d.ts +1 -0
- package/dist/hooks/map/useSelectFeaturesCurrentIndex.d.ts +1 -0
- package/dist/hooks/map/useSelectFeaturesGeometryMasking.d.ts +1 -0
- package/dist/hooks/map/useSelectFeaturesInitialized.d.ts +1 -0
- package/dist/hooks/map/useSelectFeaturesLayerName.d.ts +1 -0
- package/dist/hooks/map/useSelectFeaturesPagination.d.ts +4 -0
- package/dist/hooks/map/useSelectFeaturesStatisticsActive.d.ts +1 -0
- package/dist/hooks/map/useSelectFeaturesTotalCounts.d.ts +1 -0
- package/dist/hooks/map/useSelectedFeatures.d.ts +2 -0
- package/dist/hooks/map/useUpdateCurrentFeature.d.ts +2 -0
- package/dist/hooks/map/useZoomToFeatures.d.ts +2 -0
- package/dist/hooks/map/useZoomToLayer.d.ts +7 -0
- package/dist/hooks/map/useZoomToPoint.d.ts +1 -0
- package/dist/hooks/serverNotifications/index.d.ts +2 -0
- package/dist/hooks/serverNotifications/useServerNotifications.d.ts +2 -0
- package/dist/hooks/serverNotifications/useServerNotificationsContext.d.ts +1 -0
- package/dist/hooks/useResizer.d.ts +28 -0
- package/dist/hooks/useToggle.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/jest.config.d.ts +11 -0
- package/dist/react.cjs.development.js +1653 -5
- package/dist/react.cjs.development.js.map +1 -1
- package/dist/react.cjs.production.min.js +1 -1
- package/dist/react.cjs.production.min.js.map +1 -1
- package/dist/react.esm.js +1624 -6
- package/dist/react.esm.js.map +1 -1
- package/dist/utils/date.d.ts +2 -2
- package/dist/utils/geometryToWkt.d.ts +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +30 -23
package/dist/react.esm.js
CHANGED
|
@@ -1,10 +1,501 @@
|
|
|
1
|
-
import { useState, useCallback } from 'react';
|
|
1
|
+
import React, { Component, useContext, useMemo, createContext, useRef, useState, useCallback, useEffect, useLayoutEffect } from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import MapGL, { Layer as Layer$1, Source } from 'react-map-gl/mapbox';
|
|
4
|
+
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
|
|
5
|
+
import { changeProps } from 'find-and';
|
|
6
|
+
import { isEmpty, isNil } from 'lodash-es';
|
|
2
7
|
import { isValid, toDate, format, parseJSON, parseISO } from 'date-fns';
|
|
8
|
+
import { stringify } from 'wkt';
|
|
9
|
+
import MapboxDraw from '@mapbox/mapbox-gl-draw';
|
|
10
|
+
import { polygon, multiLineString, multiPoint, point, toWgs84, lineString, toMercator, bbox } from '@turf/turf';
|
|
11
|
+
import { GeometryType } from '@evergis/api';
|
|
12
|
+
import { HubConnectionBuilder, LogLevel } from '@microsoft/signalr';
|
|
13
|
+
import 'mapbox-gl/dist/mapbox-gl.css';
|
|
3
14
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
15
|
+
function _classCallCheck(instance, Constructor) {
|
|
16
|
+
if (!(instance instanceof Constructor)) {
|
|
17
|
+
throw new TypeError("Cannot call a class as a function");
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _defineProperties(target, props) {
|
|
22
|
+
for (var i = 0; i < props.length; i++) {
|
|
23
|
+
var descriptor = props[i];
|
|
24
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
25
|
+
descriptor.configurable = true;
|
|
26
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
27
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
32
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
33
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
34
|
+
return Constructor;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function _extends() {
|
|
38
|
+
_extends = Object.assign || function (target) {
|
|
39
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
40
|
+
var source = arguments[i];
|
|
41
|
+
|
|
42
|
+
for (var key in source) {
|
|
43
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
44
|
+
target[key] = source[key];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return target;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return _extends.apply(this, arguments);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _inherits(subClass, superClass) {
|
|
56
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
57
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
61
|
+
constructor: {
|
|
62
|
+
value: subClass,
|
|
63
|
+
writable: true,
|
|
64
|
+
configurable: true
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function _getPrototypeOf(o) {
|
|
71
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
72
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
73
|
+
};
|
|
74
|
+
return _getPrototypeOf(o);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function _setPrototypeOf(o, p) {
|
|
78
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
79
|
+
o.__proto__ = p;
|
|
80
|
+
return o;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return _setPrototypeOf(o, p);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
87
|
+
if (source == null) return {};
|
|
88
|
+
var target = {};
|
|
89
|
+
var sourceKeys = Object.keys(source);
|
|
90
|
+
var key, i;
|
|
91
|
+
|
|
92
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
93
|
+
key = sourceKeys[i];
|
|
94
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
95
|
+
target[key] = source[key];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function _assertThisInitialized(self) {
|
|
102
|
+
if (self === void 0) {
|
|
103
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return self;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function _possibleConstructorReturn(self, call) {
|
|
110
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
111
|
+
return call;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return _assertThisInitialized(self);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function _taggedTemplateLiteralLoose(strings, raw) {
|
|
118
|
+
if (!raw) {
|
|
119
|
+
raw = strings.slice(0);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
strings.raw = raw;
|
|
123
|
+
return strings;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
var _templateObject;
|
|
127
|
+
const ErrorBoundaryContainer = /*#__PURE__*/styled.div(_templateObject || (_templateObject = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100vh;\n"])));
|
|
128
|
+
|
|
129
|
+
function _callSuper(_this, derived, args) {
|
|
130
|
+
function isNativeReflectConstruct() {
|
|
131
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
132
|
+
if (Reflect.construct.sham) return false;
|
|
133
|
+
if (typeof Proxy === "function") return true;
|
|
134
|
+
|
|
135
|
+
try {
|
|
136
|
+
return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
137
|
+
} catch (e) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
derived = _getPrototypeOf(derived);
|
|
143
|
+
return _possibleConstructorReturn(_this, isNativeReflectConstruct() ? Reflect.construct(derived, args || [], _getPrototypeOf(_this).constructor) : derived.apply(_this, args));
|
|
144
|
+
}
|
|
145
|
+
let ErrorBoundary = /*#__PURE__*/function (_Component) {
|
|
146
|
+
function ErrorBoundary() {
|
|
147
|
+
var _this2;
|
|
148
|
+
|
|
149
|
+
_classCallCheck(this, ErrorBoundary);
|
|
150
|
+
|
|
151
|
+
_this2 = _callSuper(this, ErrorBoundary, arguments);
|
|
152
|
+
_this2.state = {
|
|
153
|
+
hasError: false
|
|
154
|
+
};
|
|
155
|
+
return _this2;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
_inherits(ErrorBoundary, _Component);
|
|
159
|
+
|
|
160
|
+
return _createClass(ErrorBoundary, [{
|
|
161
|
+
key: "componentDidCatch",
|
|
162
|
+
value: function componentDidCatch(error) {
|
|
163
|
+
// eslint-disable-next-line no-console
|
|
164
|
+
console.error(error);
|
|
165
|
+
}
|
|
166
|
+
}, {
|
|
167
|
+
key: "render",
|
|
168
|
+
value: function render() {
|
|
169
|
+
const {
|
|
170
|
+
children,
|
|
171
|
+
errorContents
|
|
172
|
+
} = this.props;
|
|
173
|
+
const {
|
|
174
|
+
hasError
|
|
175
|
+
} = this.state;
|
|
176
|
+
return !hasError ? React.createElement(React.Fragment, null, children) : React.createElement(ErrorBoundaryContainer, null, errorContents);
|
|
177
|
+
}
|
|
178
|
+
}], [{
|
|
179
|
+
key: "getDerivedStateFromError",
|
|
180
|
+
value: function getDerivedStateFromError() {
|
|
181
|
+
return {
|
|
182
|
+
hasError: true
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}]);
|
|
186
|
+
}(Component);
|
|
187
|
+
|
|
188
|
+
var _templateObject$1;
|
|
189
|
+
const MapWrapper = /*#__PURE__*/styled.div(_templateObject$1 || (_templateObject$1 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: relative;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n z-index: ", ";\n\n .mapbox-gl-draw_trash {\n display: none;\n }\n\n .mapboxgl-ctrl-logo {\n display: none;\n }\n\n .mapboxgl-ctrl.mapboxgl-ctrl-attrib {\n display: none;\n }\n\n .mapboxgl-ctrl-geocoder.mapboxgl-ctrl {\n width: 350px;\n }\n"])), (_ref) => {
|
|
190
|
+
let {
|
|
191
|
+
$zIndex
|
|
192
|
+
} = _ref;
|
|
193
|
+
return $zIndex != null ? $zIndex : 1;
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const useMapContext = () => {
|
|
197
|
+
return useContext(MapContext);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const useCurrentSelectedFeature = () => {
|
|
201
|
+
const {
|
|
202
|
+
selectFeatures
|
|
203
|
+
} = useMapContext();
|
|
204
|
+
return useMemo(() => {
|
|
205
|
+
var _selectFeatures$featu;
|
|
206
|
+
|
|
207
|
+
return (_selectFeatures$featu = selectFeatures.features) == null || (_selectFeatures$featu = _selectFeatures$featu[selectFeatures.layerName]) == null ? void 0 : _selectFeatures$featu.find(item => item.id === selectFeatures.currentId);
|
|
208
|
+
}, [selectFeatures]);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const MapContext = /*#__PURE__*/createContext({});
|
|
212
|
+
|
|
213
|
+
var BaseMapTheme;
|
|
214
|
+
|
|
215
|
+
(function (BaseMapTheme) {
|
|
216
|
+
BaseMapTheme["Light"] = "light";
|
|
217
|
+
BaseMapTheme["Dark"] = "dark";
|
|
218
|
+
})(BaseMapTheme || (BaseMapTheme = {}));
|
|
219
|
+
|
|
220
|
+
var GeometrySelectionTypes;
|
|
221
|
+
|
|
222
|
+
(function (GeometrySelectionTypes) {
|
|
223
|
+
GeometrySelectionTypes["Point"] = "select_point";
|
|
224
|
+
GeometrySelectionTypes["Line"] = "select_line";
|
|
225
|
+
GeometrySelectionTypes["Circle"] = "select_circle";
|
|
226
|
+
GeometrySelectionTypes["Rect"] = "select_rect";
|
|
227
|
+
GeometrySelectionTypes["Polygon"] = "select_polygon";
|
|
228
|
+
GeometrySelectionTypes["Zones"] = "zones_selection";
|
|
229
|
+
GeometrySelectionTypes["Coordinates"] = "xy";
|
|
230
|
+
GeometrySelectionTypes["Route"] = "selection_route";
|
|
231
|
+
})(GeometrySelectionTypes || (GeometrySelectionTypes = {}));
|
|
232
|
+
|
|
233
|
+
var GeometrySelectionToolTypes;
|
|
234
|
+
|
|
235
|
+
(function (GeometrySelectionToolTypes) {
|
|
236
|
+
GeometrySelectionToolTypes["Replace"] = "Replace";
|
|
237
|
+
GeometrySelectionToolTypes["Unite"] = "Unite";
|
|
238
|
+
GeometrySelectionToolTypes["Crop"] = "Crop";
|
|
239
|
+
GeometrySelectionToolTypes["Edit"] = "Edit";
|
|
240
|
+
})(GeometrySelectionToolTypes || (GeometrySelectionToolTypes = {}));
|
|
241
|
+
|
|
242
|
+
var GeometrySelectionZoneTypes;
|
|
243
|
+
|
|
244
|
+
(function (GeometrySelectionZoneTypes) {
|
|
245
|
+
GeometrySelectionZoneTypes["Walking"] = "Walking";
|
|
246
|
+
GeometrySelectionZoneTypes["Car"] = "Car";
|
|
247
|
+
})(GeometrySelectionZoneTypes || (GeometrySelectionZoneTypes = {}));
|
|
248
|
+
|
|
249
|
+
var GeometrySelectionRouteTypes;
|
|
250
|
+
|
|
251
|
+
(function (GeometrySelectionRouteTypes) {
|
|
252
|
+
GeometrySelectionRouteTypes["Walking"] = "Walking";
|
|
253
|
+
GeometrySelectionRouteTypes["Car"] = "Car";
|
|
254
|
+
})(GeometrySelectionRouteTypes || (GeometrySelectionRouteTypes = {}));
|
|
255
|
+
|
|
256
|
+
var GeometryEditorMode;
|
|
257
|
+
|
|
258
|
+
(function (GeometryEditorMode) {
|
|
259
|
+
GeometryEditorMode[GeometryEditorMode["Create"] = 0] = "Create";
|
|
260
|
+
GeometryEditorMode[GeometryEditorMode["Edit"] = 1] = "Edit";
|
|
261
|
+
GeometryEditorMode[GeometryEditorMode["Transform"] = 2] = "Transform";
|
|
262
|
+
GeometryEditorMode[GeometryEditorMode["Expand"] = 3] = "Expand";
|
|
263
|
+
GeometryEditorMode[GeometryEditorMode["Unite"] = 4] = "Unite";
|
|
264
|
+
GeometryEditorMode[GeometryEditorMode["Subtract"] = 5] = "Subtract";
|
|
265
|
+
})(GeometryEditorMode || (GeometryEditorMode = {}));
|
|
266
|
+
|
|
267
|
+
const initialGeometrySelection = {
|
|
268
|
+
active: true,
|
|
269
|
+
loading: false,
|
|
270
|
+
type: GeometrySelectionTypes.Point,
|
|
271
|
+
currentTool: GeometrySelectionToolTypes.Replace,
|
|
272
|
+
history: {
|
|
273
|
+
features: [],
|
|
274
|
+
zones: [],
|
|
275
|
+
step: -1
|
|
276
|
+
},
|
|
277
|
+
editHistory: {
|
|
278
|
+
features: [],
|
|
279
|
+
step: -1
|
|
280
|
+
},
|
|
281
|
+
isBuffer: false,
|
|
282
|
+
settings: {
|
|
283
|
+
zoneDuration: 60,
|
|
284
|
+
zoneType: GeometrySelectionZoneTypes.Walking,
|
|
285
|
+
routeType: GeometrySelectionRouteTypes.Walking,
|
|
286
|
+
bufferRadius: "",
|
|
287
|
+
bufferMultiplier: "1",
|
|
288
|
+
bufferInclude: true,
|
|
289
|
+
selectOutside: false
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
const initialGeometryEditor = {
|
|
293
|
+
active: false
|
|
294
|
+
};
|
|
295
|
+
const initialSelectFeatures = {
|
|
296
|
+
initialized: false,
|
|
297
|
+
layerName: undefined,
|
|
298
|
+
currentId: null,
|
|
299
|
+
selectionOffset: 0,
|
|
300
|
+
features: {},
|
|
301
|
+
totalCounts: {},
|
|
302
|
+
statisticsActive: false,
|
|
303
|
+
geometryMasking: false
|
|
304
|
+
};
|
|
305
|
+
const MapProvider = (_ref) => {
|
|
306
|
+
let {
|
|
307
|
+
basemapItems,
|
|
308
|
+
defaultBasemap,
|
|
309
|
+
children
|
|
310
|
+
} = _ref;
|
|
311
|
+
const map = useRef();
|
|
312
|
+
const draw = useRef();
|
|
313
|
+
const [loaded, setLoaded] = useState(false);
|
|
314
|
+
const [basemapName, setBasemapName] = useState(defaultBasemap);
|
|
315
|
+
const [globeProjection, setGlobeProjection] = useState(false);
|
|
316
|
+
const [geometrySelection, setGeometrySelection] = useState(initialGeometrySelection);
|
|
317
|
+
const [geometryEditor, setGeometryEditor] = useState(initialGeometryEditor);
|
|
318
|
+
const [selectFeatures, setSelectFeatures] = useState(initialSelectFeatures);
|
|
319
|
+
const resetGeometrySelection = useCallback(() => {
|
|
320
|
+
setGeometrySelection(initialGeometrySelection);
|
|
321
|
+
}, []);
|
|
322
|
+
const resetGeometryEditor = useCallback(() => {
|
|
323
|
+
setGeometryEditor(initialGeometryEditor);
|
|
324
|
+
}, []);
|
|
325
|
+
const setNextFeature = useCallback(() => {
|
|
326
|
+
setSelectFeatures(state => {
|
|
327
|
+
var _features$layerName, _features$layerName2, _features$layerName3;
|
|
328
|
+
|
|
329
|
+
const {
|
|
330
|
+
layerName,
|
|
331
|
+
features,
|
|
332
|
+
currentId
|
|
333
|
+
} = state;
|
|
334
|
+
const currentIndex = features == null || (_features$layerName = features[layerName]) == null ? void 0 : _features$layerName.findIndex(item => item.id === currentId);
|
|
335
|
+
|
|
336
|
+
if (currentIndex === (features == null || (_features$layerName2 = features[layerName]) == null ? void 0 : _features$layerName2.length) - 1) {
|
|
337
|
+
return state;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const nextId = features == null || (_features$layerName3 = features[layerName]) == null || (_features$layerName3 = _features$layerName3[currentIndex + 1]) == null ? void 0 : _features$layerName3.id;
|
|
341
|
+
return _extends({}, state, {
|
|
342
|
+
currentId: nextId
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
}, []);
|
|
346
|
+
const setPrevFeature = useCallback(() => {
|
|
347
|
+
setSelectFeatures(state => {
|
|
348
|
+
var _features$layerName4, _features$layerName5;
|
|
349
|
+
|
|
350
|
+
const {
|
|
351
|
+
layerName,
|
|
352
|
+
features,
|
|
353
|
+
currentId
|
|
354
|
+
} = state;
|
|
355
|
+
const currentIndex = features == null || (_features$layerName4 = features[layerName]) == null ? void 0 : _features$layerName4.findIndex(item => item.id === currentId);
|
|
356
|
+
|
|
357
|
+
if (currentIndex === 0) {
|
|
358
|
+
return state;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const prevId = features == null || (_features$layerName5 = features[layerName]) == null || (_features$layerName5 = _features$layerName5[currentIndex - 1]) == null ? void 0 : _features$layerName5.id;
|
|
362
|
+
return _extends({}, state, {
|
|
363
|
+
currentId: prevId
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
}, []);
|
|
367
|
+
const setSelectedFeatures = useCallback((payload, currentId, offset) => {
|
|
368
|
+
setSelectFeatures(state => {
|
|
369
|
+
var _features$firstNotNul;
|
|
370
|
+
|
|
371
|
+
const features = payload != null ? payload : {};
|
|
372
|
+
const firstNotNullLayerName = Object.keys(features).find(key => features[key].length > 0);
|
|
373
|
+
const featureIdsToSelect = (_features$firstNotNul = features[firstNotNullLayerName]) == null ? void 0 : _features$firstNotNul.map((_ref2) => {
|
|
374
|
+
let {
|
|
375
|
+
id
|
|
376
|
+
} = _ref2;
|
|
377
|
+
return id;
|
|
378
|
+
});
|
|
379
|
+
return _extends({}, state, {
|
|
380
|
+
features,
|
|
381
|
+
layerName: firstNotNullLayerName,
|
|
382
|
+
currentId: currentId != null ? currentId : featureIdsToSelect == null ? void 0 : featureIdsToSelect[0],
|
|
383
|
+
selectionOffset: offset
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
}, []);
|
|
387
|
+
const setSelectedFeaturesTotalCounts = useCallback(payload => {
|
|
388
|
+
setSelectFeatures(state => _extends({}, state, {
|
|
389
|
+
totalCounts: payload
|
|
390
|
+
}));
|
|
391
|
+
}, []);
|
|
392
|
+
const setSelectFeaturesInitialized = useCallback(payload => {
|
|
393
|
+
setSelectFeatures(state => _extends({}, state, {
|
|
394
|
+
initialized: payload
|
|
395
|
+
}));
|
|
396
|
+
}, []);
|
|
397
|
+
const setSelectFeaturesLayerName = useCallback(payload => {
|
|
398
|
+
setSelectFeatures(state => {
|
|
399
|
+
var _state$features;
|
|
400
|
+
|
|
401
|
+
return _extends({}, state, {
|
|
402
|
+
layerName: payload,
|
|
403
|
+
currentId: (_state$features = state.features) == null || (_state$features = _state$features[payload]) == null || (_state$features = _state$features[0]) == null ? void 0 : _state$features.id,
|
|
404
|
+
selectionOffset: 0
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
}, []);
|
|
408
|
+
const setSelectFeaturesStatisticsActive = useCallback(payload => {
|
|
409
|
+
setSelectFeatures(state => _extends({}, state, {
|
|
410
|
+
statisticsActive: payload
|
|
411
|
+
}));
|
|
412
|
+
}, []);
|
|
413
|
+
const setSelectFeaturesGeometryMasking = useCallback(payload => {
|
|
414
|
+
setSelectFeatures(state => _extends({}, state, {
|
|
415
|
+
geometryMasking: payload
|
|
416
|
+
}));
|
|
417
|
+
}, []);
|
|
418
|
+
const updateCurrentFeature = useCallback(payload => {
|
|
419
|
+
setSelectFeatures(state => {
|
|
420
|
+
var _state$features$state, _state$features2;
|
|
421
|
+
|
|
422
|
+
return _extends({}, state, {
|
|
423
|
+
features: _extends({}, state.features, {
|
|
424
|
+
[state.layerName]: changeProps((_state$features$state = (_state$features2 = state.features) == null ? void 0 : _state$features2[state.layerName]) != null ? _state$features$state : [], {
|
|
425
|
+
id: state.currentId
|
|
426
|
+
}, payload)
|
|
427
|
+
})
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
}, []);
|
|
431
|
+
const resetSelectedFeatures = useCallback(() => {
|
|
432
|
+
setSelectFeatures(initialSelectFeatures);
|
|
433
|
+
}, []);
|
|
434
|
+
return React.createElement(MapContext.Provider, {
|
|
435
|
+
value: {
|
|
436
|
+
map,
|
|
437
|
+
draw,
|
|
438
|
+
loaded,
|
|
439
|
+
setLoaded,
|
|
440
|
+
basemapItems,
|
|
441
|
+
basemapName,
|
|
442
|
+
setBasemapName,
|
|
443
|
+
defaultBasemap,
|
|
444
|
+
globeProjection,
|
|
445
|
+
setGlobeProjection,
|
|
446
|
+
geometrySelection,
|
|
447
|
+
setGeometrySelection,
|
|
448
|
+
resetGeometrySelection,
|
|
449
|
+
geometryEditor,
|
|
450
|
+
setGeometryEditor,
|
|
451
|
+
resetGeometryEditor,
|
|
452
|
+
selectFeatures,
|
|
453
|
+
setNextFeature,
|
|
454
|
+
setPrevFeature,
|
|
455
|
+
setSelectedFeatures,
|
|
456
|
+
setSelectedFeaturesTotalCounts,
|
|
457
|
+
setSelectFeaturesInitialized,
|
|
458
|
+
setSelectFeaturesLayerName,
|
|
459
|
+
setSelectFeaturesStatisticsActive,
|
|
460
|
+
setSelectFeaturesGeometryMasking,
|
|
461
|
+
updateCurrentFeature,
|
|
462
|
+
resetSelectedFeatures
|
|
463
|
+
}
|
|
464
|
+
}, children);
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
const useGeometryEditor = () => {
|
|
468
|
+
const {
|
|
469
|
+
geometryEditor,
|
|
470
|
+
setGeometryEditor
|
|
471
|
+
} = useMapContext();
|
|
472
|
+
const update = useCallback(newState => {
|
|
473
|
+
setGeometryEditor(prevState => _extends({}, prevState, newState));
|
|
474
|
+
}, [setGeometryEditor]);
|
|
475
|
+
return [geometryEditor, update];
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
const useEditingFeature = () => {
|
|
479
|
+
const [{
|
|
480
|
+
layerName,
|
|
481
|
+
active,
|
|
482
|
+
mode
|
|
483
|
+
}] = useGeometryEditor();
|
|
484
|
+
const currentSelectedFeature = useCurrentSelectedFeature();
|
|
485
|
+
return useMemo(() => {
|
|
486
|
+
return active && (mode === GeometryEditorMode.Edit && layerName === (currentSelectedFeature == null ? void 0 : currentSelectedFeature.layer) || mode === GeometryEditorMode.Create);
|
|
487
|
+
}, [active, currentSelectedFeature, layerName, mode]);
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
const useGeometrySelection = () => {
|
|
491
|
+
const {
|
|
492
|
+
geometrySelection,
|
|
493
|
+
setGeometrySelection
|
|
494
|
+
} = useMapContext();
|
|
495
|
+
const updateGeometrySelection = useCallback(newState => {
|
|
496
|
+
setGeometrySelection(prevState => _extends({}, prevState, newState));
|
|
497
|
+
}, [setGeometrySelection]);
|
|
498
|
+
return [geometrySelection, updateGeometrySelection];
|
|
8
499
|
};
|
|
9
500
|
|
|
10
501
|
const NO_CONTENT_VALUE = "—";
|
|
@@ -50,11 +541,1138 @@ const formatDate = function formatDate(date, _temp) {
|
|
|
50
541
|
return defaultValue.toString();
|
|
51
542
|
};
|
|
52
543
|
|
|
544
|
+
const geometryToWkt = function geometryToWkt(features) {
|
|
545
|
+
if (features === void 0) {
|
|
546
|
+
features = [];
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
if (features.length === 0) {
|
|
550
|
+
return "";
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
return stringify(features[0]);
|
|
554
|
+
};
|
|
555
|
+
|
|
53
556
|
const isNumeric = number => !isNaN(parseFloat(number)) && isFinite(number);
|
|
54
557
|
|
|
55
558
|
function isObject(value) {
|
|
56
559
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
57
560
|
}
|
|
58
561
|
|
|
59
|
-
|
|
562
|
+
const useEwktGeometry = () => {
|
|
563
|
+
const [{
|
|
564
|
+
history,
|
|
565
|
+
type
|
|
566
|
+
}] = useGeometrySelection();
|
|
567
|
+
return useMemo(() => {
|
|
568
|
+
var _history$zones$histor, _history$zones$histor2;
|
|
569
|
+
|
|
570
|
+
if (history.step === -1) {
|
|
571
|
+
return "";
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return type === GeometrySelectionTypes.Zones ? !isEmpty((_history$zones$histor = history.zones[history.step]) == null ? void 0 : _history$zones$histor[0]) ? "SRID=3857;" + geometryToWkt((_history$zones$histor2 = history.zones[history.step]) == null ? void 0 : _history$zones$histor2[0]) : "SRID=3857;" + geometryToWkt(history.features[history.step]) : "SRID=3857;" + geometryToWkt(history.features[history.step]);
|
|
575
|
+
}, [history.features, history.step, history.zones, type]);
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
const useGeometrySelectionBuffer = () => {
|
|
579
|
+
const [{
|
|
580
|
+
settings: {
|
|
581
|
+
bufferRadius,
|
|
582
|
+
bufferMultiplier
|
|
583
|
+
},
|
|
584
|
+
isBuffer
|
|
585
|
+
}] = useGeometrySelection();
|
|
586
|
+
return useMemo(() => {
|
|
587
|
+
if (!isBuffer || !bufferRadius) {
|
|
588
|
+
return undefined;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
return Number((+bufferRadius || 0) * +bufferMultiplier).toFixed(2);
|
|
592
|
+
}, [isBuffer, bufferRadius, bufferMultiplier]);
|
|
593
|
+
};
|
|
594
|
+
|
|
595
|
+
const customModes = MapboxDraw.modes;
|
|
596
|
+
const StaticMode = {};
|
|
597
|
+
|
|
598
|
+
StaticMode.onSetup = function () {
|
|
599
|
+
this.setActionableState(undefined);
|
|
600
|
+
return {};
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
StaticMode.toDisplayFeatures = function (state, geojson, display) {
|
|
604
|
+
display(geojson);
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
customModes.static = StaticMode;
|
|
608
|
+
|
|
609
|
+
const customStyles = [{
|
|
610
|
+
id: "gl-draw-point",
|
|
611
|
+
type: "circle",
|
|
612
|
+
filter: ["all", ["==", "$type", "Point"]],
|
|
613
|
+
paint: {
|
|
614
|
+
"circle-radius": 5,
|
|
615
|
+
"circle-color": "#D20C0C",
|
|
616
|
+
"circle-stroke-color": "#FFFFFF",
|
|
617
|
+
"circle-stroke-width": 3,
|
|
618
|
+
"circle-stroke-opacity": 0.3
|
|
619
|
+
}
|
|
620
|
+
}, {
|
|
621
|
+
id: "highlight-inactive-points",
|
|
622
|
+
type: "circle",
|
|
623
|
+
filter: ["all", ["==", "$type", "Point"], ["==", "meta", "feature"], ["==", "active", "false"]],
|
|
624
|
+
paint: {
|
|
625
|
+
"circle-radius": 5,
|
|
626
|
+
"circle-color": "#D20C0C",
|
|
627
|
+
"circle-stroke-color": "#FFFFFF",
|
|
628
|
+
"circle-stroke-width": 3,
|
|
629
|
+
"circle-stroke-opacity": 0.3
|
|
630
|
+
}
|
|
631
|
+
}, {
|
|
632
|
+
id: "highlight-active-points",
|
|
633
|
+
type: "circle",
|
|
634
|
+
filter: ["all", ["==", "$type", "Point"], ["==", "meta", "feature"], ["==", "active", "true"]],
|
|
635
|
+
paint: {
|
|
636
|
+
"circle-radius": 3,
|
|
637
|
+
"circle-color": "#fbb03b",
|
|
638
|
+
"circle-stroke-color": "#FFFFFF",
|
|
639
|
+
"circle-stroke-width": 1,
|
|
640
|
+
"circle-stroke-opacity": 0.3
|
|
641
|
+
}
|
|
642
|
+
}, {
|
|
643
|
+
id: "gl-draw-polygon-fill-static",
|
|
644
|
+
type: "fill",
|
|
645
|
+
filter: ["all", ["==", "$type", "Polygon"]],
|
|
646
|
+
paint: {
|
|
647
|
+
"fill-color": "#D20C0C",
|
|
648
|
+
"fill-outline-color": "#D20C0C",
|
|
649
|
+
"fill-opacity": 0.1
|
|
650
|
+
}
|
|
651
|
+
}, {
|
|
652
|
+
id: "gl-draw-line",
|
|
653
|
+
type: "line",
|
|
654
|
+
filter: ["all", ["==", "$type", "LineString"]],
|
|
655
|
+
layout: {
|
|
656
|
+
"line-cap": "round",
|
|
657
|
+
"line-join": "round"
|
|
658
|
+
},
|
|
659
|
+
paint: {
|
|
660
|
+
"line-color": "#D20C0C",
|
|
661
|
+
"line-dasharray": [0.2, 2],
|
|
662
|
+
"line-width": 2
|
|
663
|
+
}
|
|
664
|
+
}, {
|
|
665
|
+
id: "gl-draw-polygon-fill",
|
|
666
|
+
type: "fill",
|
|
667
|
+
filter: ["all", ["==", "$type", "Polygon"]],
|
|
668
|
+
paint: {
|
|
669
|
+
"fill-color": "#D20C0C",
|
|
670
|
+
"fill-outline-color": "#D20C0C",
|
|
671
|
+
"fill-opacity": 0.1
|
|
672
|
+
}
|
|
673
|
+
}, {
|
|
674
|
+
id: "gl-draw-polygon-midpoint",
|
|
675
|
+
type: "circle",
|
|
676
|
+
filter: ["all", ["==", "$type", "Point"], ["==", "meta", "midpoint"]],
|
|
677
|
+
paint: {
|
|
678
|
+
"circle-radius": 3,
|
|
679
|
+
"circle-color": "#fbb03b",
|
|
680
|
+
"circle-stroke-color": "#FFFFFF",
|
|
681
|
+
"circle-stroke-width": 1,
|
|
682
|
+
"circle-stroke-opacity": 0.3
|
|
683
|
+
}
|
|
684
|
+
}, {
|
|
685
|
+
id: "gl-draw-polygon-stroke-active",
|
|
686
|
+
type: "line",
|
|
687
|
+
filter: ["all", ["==", "$type", "Polygon"]],
|
|
688
|
+
layout: {
|
|
689
|
+
"line-cap": "round",
|
|
690
|
+
"line-join": "round"
|
|
691
|
+
},
|
|
692
|
+
paint: {
|
|
693
|
+
"line-color": "#D20C0C",
|
|
694
|
+
"line-dasharray": [0.2, 2],
|
|
695
|
+
"line-width": 2
|
|
696
|
+
}
|
|
697
|
+
}, {
|
|
698
|
+
id: "gl-draw-polygon-and-line-vertex-active",
|
|
699
|
+
type: "circle",
|
|
700
|
+
filter: ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"]],
|
|
701
|
+
paint: {
|
|
702
|
+
"circle-radius": 3,
|
|
703
|
+
"circle-color": "#D20C0C",
|
|
704
|
+
"circle-stroke-color": "#FFFFFF",
|
|
705
|
+
"circle-stroke-width": 3,
|
|
706
|
+
"circle-stroke-opacity": 0.3
|
|
707
|
+
}
|
|
708
|
+
}];
|
|
709
|
+
|
|
710
|
+
const draw = /*#__PURE__*/new MapboxDraw({
|
|
711
|
+
displayControlsDefault: false,
|
|
712
|
+
styles: customStyles,
|
|
713
|
+
modes: customModes,
|
|
714
|
+
defaultMode: "draw_point",
|
|
715
|
+
controls: {
|
|
716
|
+
trash: true
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
const useMapDraw = function useMapDraw(triggerDeps) {
|
|
720
|
+
if (triggerDeps === void 0) {
|
|
721
|
+
triggerDeps = [];
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
const {
|
|
725
|
+
map,
|
|
726
|
+
draw: drawContext,
|
|
727
|
+
loaded,
|
|
728
|
+
basemapName
|
|
729
|
+
} = useMapContext();
|
|
730
|
+
useEffect(() => {
|
|
731
|
+
if (!loaded || !map.current) {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
drawContext.current = draw;
|
|
736
|
+
map.current.addControl(drawContext.current);
|
|
737
|
+
}, [loaded]); // eslint-disable-line
|
|
738
|
+
|
|
739
|
+
useEffect(() => {
|
|
740
|
+
if (map.current && map.current.hasControl(drawContext.current)) {
|
|
741
|
+
map.current.removeControl(drawContext.current);
|
|
742
|
+
map.current.addControl(drawContext.current);
|
|
743
|
+
}
|
|
744
|
+
}, [basemapName, ...triggerDeps]); // eslint-disable-line
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
const useRedrawLayer = () => {
|
|
748
|
+
const {
|
|
749
|
+
map
|
|
750
|
+
} = useMapContext();
|
|
751
|
+
return useCallback(layerName => {
|
|
752
|
+
const layerTileSource = map.current.getSource(layerName);
|
|
753
|
+
layerTileSource.setTiles(layerTileSource.tiles);
|
|
754
|
+
}, [map]);
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
const useSelectedFeatures = () => {
|
|
758
|
+
var _selectFeatures$featu;
|
|
759
|
+
|
|
760
|
+
const {
|
|
761
|
+
selectFeatures,
|
|
762
|
+
setSelectedFeatures
|
|
763
|
+
} = useMapContext();
|
|
764
|
+
const updatSelectedFeatures = useCallback(features => {
|
|
765
|
+
setSelectedFeatures(features);
|
|
766
|
+
}, [setSelectedFeatures]);
|
|
767
|
+
return [(_selectFeatures$featu = selectFeatures.features) != null ? _selectFeatures$featu : {}, updatSelectedFeatures];
|
|
768
|
+
};
|
|
769
|
+
|
|
770
|
+
const useSelectFeaturesCount = () => {
|
|
771
|
+
const {
|
|
772
|
+
selectFeatures
|
|
773
|
+
} = useMapContext();
|
|
774
|
+
return useMemo(() => {
|
|
775
|
+
var _selectFeatures$featu, _selectFeatures$featu2;
|
|
776
|
+
|
|
777
|
+
return (_selectFeatures$featu = (_selectFeatures$featu2 = selectFeatures.features) == null || (_selectFeatures$featu2 = _selectFeatures$featu2[selectFeatures.layerName]) == null ? void 0 : _selectFeatures$featu2.length) != null ? _selectFeatures$featu : 0;
|
|
778
|
+
}, [selectFeatures]);
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
const useSelectFeaturesCurrentIndex = () => {
|
|
782
|
+
const {
|
|
783
|
+
selectFeatures
|
|
784
|
+
} = useMapContext();
|
|
785
|
+
return useMemo(() => {
|
|
786
|
+
var _selectFeatures$featu, _selectFeatures$featu2;
|
|
787
|
+
|
|
788
|
+
return (_selectFeatures$featu = selectFeatures.features) != null && (_selectFeatures$featu = _selectFeatures$featu[selectFeatures.layerName]) != null && _selectFeatures$featu.length ? (_selectFeatures$featu2 = selectFeatures.features) == null || (_selectFeatures$featu2 = _selectFeatures$featu2[selectFeatures.layerName]) == null ? void 0 : _selectFeatures$featu2.findIndex(feature => feature.id === selectFeatures.currentId) : -1;
|
|
789
|
+
}, [selectFeatures]);
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
const useSelectFeaturesGeometryMasking = () => {
|
|
793
|
+
const {
|
|
794
|
+
selectFeatures,
|
|
795
|
+
setSelectFeaturesGeometryMasking
|
|
796
|
+
} = useMapContext();
|
|
797
|
+
const update = useCallback(state => {
|
|
798
|
+
setSelectFeaturesGeometryMasking(state);
|
|
799
|
+
}, [setSelectFeaturesGeometryMasking]);
|
|
800
|
+
return [selectFeatures.geometryMasking, update];
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
const useSelectFeaturesInitialized = () => {
|
|
804
|
+
const {
|
|
805
|
+
selectFeatures,
|
|
806
|
+
setSelectFeaturesInitialized
|
|
807
|
+
} = useMapContext();
|
|
808
|
+
const update = useCallback(state => {
|
|
809
|
+
setSelectFeaturesInitialized(state);
|
|
810
|
+
}, [setSelectFeaturesInitialized]);
|
|
811
|
+
return [selectFeatures.initialized, update];
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
const useSelectFeaturesLayerName = () => {
|
|
815
|
+
const {
|
|
816
|
+
selectFeatures,
|
|
817
|
+
setSelectFeaturesLayerName
|
|
818
|
+
} = useMapContext();
|
|
819
|
+
const update = useCallback(name => {
|
|
820
|
+
setSelectFeaturesLayerName(name);
|
|
821
|
+
}, [setSelectFeaturesLayerName]);
|
|
822
|
+
return [selectFeatures.layerName, update];
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
const useSelectFeaturesPagination = () => {
|
|
826
|
+
const {
|
|
827
|
+
setNextFeature,
|
|
828
|
+
setPrevFeature
|
|
829
|
+
} = useMapContext();
|
|
830
|
+
const onNext = useCallback(() => {
|
|
831
|
+
setNextFeature();
|
|
832
|
+
}, [setNextFeature]);
|
|
833
|
+
const onPrev = useCallback(() => {
|
|
834
|
+
setPrevFeature();
|
|
835
|
+
}, [setPrevFeature]);
|
|
836
|
+
return {
|
|
837
|
+
onNext,
|
|
838
|
+
onPrev
|
|
839
|
+
};
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
const useSelectFeaturesStatisticsActive = () => {
|
|
843
|
+
const {
|
|
844
|
+
selectFeatures,
|
|
845
|
+
setSelectFeaturesStatisticsActive
|
|
846
|
+
} = useMapContext();
|
|
847
|
+
const update = useCallback(state => {
|
|
848
|
+
setSelectFeaturesStatisticsActive(state);
|
|
849
|
+
}, [setSelectFeaturesStatisticsActive]);
|
|
850
|
+
return [selectFeatures.statisticsActive, update];
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
const useSelectFeaturesTotalCounts = () => {
|
|
854
|
+
var _selectFeatures$total;
|
|
855
|
+
|
|
856
|
+
const {
|
|
857
|
+
selectFeatures,
|
|
858
|
+
setSelectedFeaturesTotalCounts
|
|
859
|
+
} = useMapContext();
|
|
860
|
+
const update = useCallback(totalCounts => {
|
|
861
|
+
setSelectedFeaturesTotalCounts(totalCounts);
|
|
862
|
+
}, [setSelectedFeaturesTotalCounts]);
|
|
863
|
+
return [(_selectFeatures$total = selectFeatures.totalCounts) != null ? _selectFeatures$total : {}, update];
|
|
864
|
+
};
|
|
865
|
+
|
|
866
|
+
const useUpdateCurrentFeature = () => {
|
|
867
|
+
const {
|
|
868
|
+
updateCurrentFeature
|
|
869
|
+
} = useMapContext();
|
|
870
|
+
return useCallback(values => {
|
|
871
|
+
updateCurrentFeature(values);
|
|
872
|
+
}, [updateCurrentFeature]);
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
const findAttributeInExpression = expression => {
|
|
876
|
+
if (Array.isArray(expression) && expression.length === 2 && expression[0] === "get") {
|
|
877
|
+
return [expression[1]];
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
return expression.reduce((acc, curr) => {
|
|
881
|
+
if (!Array.isArray(curr)) {
|
|
882
|
+
return acc;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
if (curr[0] === "get") {
|
|
886
|
+
return [...new Set([...acc, curr[1]])];
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
return [...new Set([...acc, ...findAttributeInExpression(curr)])];
|
|
890
|
+
}, []);
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
const getActualExtrusionHeight = paint => {
|
|
894
|
+
return Array.isArray(paint == null ? void 0 : paint["fill-extrusion-height"]) && (paint == null ? void 0 : paint["fill-extrusion-height"][0]) === "+" ? paint == null ? void 0 : paint["fill-extrusion-height"][1] : paint == null ? void 0 : paint["fill-extrusion-height"];
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
const parseClientStyle = style => {
|
|
898
|
+
var _style$items;
|
|
899
|
+
|
|
900
|
+
if (!style) {
|
|
901
|
+
return [];
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
return style == null || (_style$items = style.items) == null ? void 0 : _style$items.reduce((acc, curr) => {
|
|
905
|
+
var _Object$entries;
|
|
906
|
+
|
|
907
|
+
if (!curr.paint || isEmpty(curr.paint)) {
|
|
908
|
+
return acc;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
return (_Object$entries = Object.entries(curr.paint)) == null ? void 0 : _Object$entries.reduce((paintAcc, _ref) => {
|
|
912
|
+
let [, value] = _ref;
|
|
913
|
+
|
|
914
|
+
if (!Array.isArray(value)) {
|
|
915
|
+
return paintAcc;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
return [...new Set([...paintAcc, ...findAttributeInExpression(value)])];
|
|
919
|
+
}, []);
|
|
920
|
+
}, []);
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
const convertSpToTurfFeature = geometry => {
|
|
924
|
+
if (!geometry) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
switch (geometry.type) {
|
|
929
|
+
case GeometryType.Point:
|
|
930
|
+
return point(geometry.coordinates);
|
|
931
|
+
|
|
932
|
+
case GeometryType.Multipoint:
|
|
933
|
+
return multiPoint(geometry.coordinates);
|
|
934
|
+
|
|
935
|
+
case GeometryType.Polyline:
|
|
936
|
+
return multiLineString(geometry.coordinates);
|
|
937
|
+
|
|
938
|
+
case GeometryType.Polygon:
|
|
939
|
+
case GeometryType.Envelope:
|
|
940
|
+
return polygon(geometry.coordinates);
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
|
|
944
|
+
const drawModeToGeometrySelectionType = mode => {
|
|
945
|
+
switch (mode) {
|
|
946
|
+
case "draw_point":
|
|
947
|
+
return GeometrySelectionTypes.Point;
|
|
948
|
+
|
|
949
|
+
case "draw_polygon":
|
|
950
|
+
return GeometrySelectionTypes.Polygon;
|
|
951
|
+
|
|
952
|
+
case "draw_line_string":
|
|
953
|
+
return GeometrySelectionTypes.Line;
|
|
954
|
+
|
|
955
|
+
default:
|
|
956
|
+
return GeometrySelectionTypes.Point;
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
const getGeometrySelectionTurfFeature = (coordinates, selectionType, toWgs) => {
|
|
961
|
+
if (toWgs) {
|
|
962
|
+
switch (selectionType) {
|
|
963
|
+
case GeometrySelectionTypes.Point:
|
|
964
|
+
return toWgs84(point(coordinates));
|
|
965
|
+
|
|
966
|
+
case GeometrySelectionTypes.Polygon:
|
|
967
|
+
return toWgs84(polygon(coordinates));
|
|
968
|
+
|
|
969
|
+
case GeometrySelectionTypes.Line:
|
|
970
|
+
return toWgs84(lineString(coordinates));
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
switch (selectionType) {
|
|
975
|
+
case GeometrySelectionTypes.Point:
|
|
976
|
+
return toMercator(point(coordinates));
|
|
977
|
+
|
|
978
|
+
case GeometrySelectionTypes.Polygon:
|
|
979
|
+
return toMercator(polygon(coordinates));
|
|
980
|
+
|
|
981
|
+
case GeometrySelectionTypes.Line:
|
|
982
|
+
return toMercator(lineString(coordinates));
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
|
|
986
|
+
const useZoomToFeatures = () => {
|
|
987
|
+
const {
|
|
988
|
+
map
|
|
989
|
+
} = useMapContext();
|
|
990
|
+
return useCallback((features, padding) => {
|
|
991
|
+
if (!features) {
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
const currentFeatureCenter = bbox({
|
|
996
|
+
type: "FeatureCollection",
|
|
997
|
+
features: features.map(feature => convertSpToTurfFeature(feature.geometry))
|
|
998
|
+
});
|
|
999
|
+
map.current.fitBounds(currentFeatureCenter, {
|
|
1000
|
+
padding: padding != null ? padding : 150
|
|
1001
|
+
});
|
|
1002
|
+
}, [map]);
|
|
1003
|
+
};
|
|
1004
|
+
|
|
1005
|
+
const DEFAULT_PADDING = 50;
|
|
1006
|
+
const useZoomToLayer = () => {
|
|
1007
|
+
const {
|
|
1008
|
+
map
|
|
1009
|
+
} = useMapContext();
|
|
1010
|
+
return useCallback(async (bulkExtent, options) => {
|
|
1011
|
+
var _options$padding;
|
|
1012
|
+
|
|
1013
|
+
if (!bulkExtent || !bulkExtent.overall) {
|
|
1014
|
+
return;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
map.current.fitBounds([...bulkExtent.overall.coordinates[0], ...bulkExtent.overall.coordinates[1]], {
|
|
1018
|
+
padding: (_options$padding = options == null ? void 0 : options.padding) != null ? _options$padding : DEFAULT_PADDING
|
|
1019
|
+
});
|
|
1020
|
+
}, [map]);
|
|
1021
|
+
};
|
|
1022
|
+
|
|
1023
|
+
const useZoomToPoint = () => {
|
|
1024
|
+
const {
|
|
1025
|
+
map
|
|
1026
|
+
} = useMapContext();
|
|
1027
|
+
return useCallback((options, callback) => {
|
|
1028
|
+
if (map.current) {
|
|
1029
|
+
if (callback) {
|
|
1030
|
+
map.current.once("moveend", () => {
|
|
1031
|
+
callback();
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
map.current.flyTo(options);
|
|
1036
|
+
} else {
|
|
1037
|
+
callback == null || callback();
|
|
1038
|
+
}
|
|
1039
|
+
}, [map]);
|
|
1040
|
+
};
|
|
1041
|
+
|
|
1042
|
+
const useServerNotifications = (url, initialized) => {
|
|
1043
|
+
const hubConnection = useRef(null);
|
|
1044
|
+
const [connection, setConnection] = useState(null);
|
|
1045
|
+
useEffect(() => {
|
|
1046
|
+
if (!initialized) {
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
hubConnection.current = new HubConnectionBuilder().withUrl(url, {
|
|
1051
|
+
withCredentials: true
|
|
1052
|
+
}).configureLogging(LogLevel.Information).build();
|
|
1053
|
+
hubConnection.current.start().then(() => console.info("Серверные нотификации подключены")).catch(err => console.info("Ошибка:", err)).finally(() => setConnection(hubConnection.current));
|
|
1054
|
+
}, [initialized]); // eslint-disable-line
|
|
1055
|
+
|
|
1056
|
+
useEffect(() => {
|
|
1057
|
+
if (!connection || connection.state !== "Connected") {
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
connection.invoke("SubscribeNotifications", []).then(() => console.info("Подписка `SubscribeNotifications` оформлена")).catch(err => console.info("Ошибка подписки `SubscribeNotifications`:", err));
|
|
1062
|
+
}, [connection]);
|
|
1063
|
+
return connection;
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
const ServerNotificationsContext = /*#__PURE__*/createContext({});
|
|
1067
|
+
|
|
1068
|
+
const useServerNotificationsContext = () => {
|
|
1069
|
+
return useContext(ServerNotificationsContext);
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1072
|
+
var VerticalPosition;
|
|
1073
|
+
|
|
1074
|
+
(function (VerticalPosition) {
|
|
1075
|
+
VerticalPosition["Top"] = "top";
|
|
1076
|
+
VerticalPosition["Bottom"] = "bottom";
|
|
1077
|
+
})(VerticalPosition || (VerticalPosition = {}));
|
|
1078
|
+
|
|
1079
|
+
var HorizontalPosition;
|
|
1080
|
+
|
|
1081
|
+
(function (HorizontalPosition) {
|
|
1082
|
+
HorizontalPosition["Left"] = "left";
|
|
1083
|
+
HorizontalPosition["Right"] = "right";
|
|
1084
|
+
})(HorizontalPosition || (HorizontalPosition = {}));
|
|
1085
|
+
|
|
1086
|
+
const useResizer = (_ref) => {
|
|
1087
|
+
let {
|
|
1088
|
+
handleVerticalPosition,
|
|
1089
|
+
handleHorizontalPosition,
|
|
1090
|
+
minWidth = Number.MIN_SAFE_INTEGER,
|
|
1091
|
+
maxWidth = Number.MAX_SAFE_INTEGER,
|
|
1092
|
+
horizontal = true,
|
|
1093
|
+
minHeight = Number.MIN_SAFE_INTEGER,
|
|
1094
|
+
maxHeight = Number.MAX_SAFE_INTEGER,
|
|
1095
|
+
vertical = true,
|
|
1096
|
+
useResize = false,
|
|
1097
|
+
onResize,
|
|
1098
|
+
onResizeEnd,
|
|
1099
|
+
onResizeStart
|
|
1100
|
+
} = _ref;
|
|
1101
|
+
const containerRef = useRef();
|
|
1102
|
+
const verticalHandleRef = useRef();
|
|
1103
|
+
const horizontalHandleRef = useRef();
|
|
1104
|
+
const updateSizes = useCallback((width, height) => {
|
|
1105
|
+
var _horizontalHandleRef$, _verticalHandleRef$cu;
|
|
1106
|
+
|
|
1107
|
+
let newWidth = width;
|
|
1108
|
+
let newHeight = height;
|
|
1109
|
+
|
|
1110
|
+
if (horizontal && newWidth < minWidth) {
|
|
1111
|
+
newWidth = minWidth;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
if (horizontal && newWidth > Math.min(window.innerWidth - ((_horizontalHandleRef$ = horizontalHandleRef.current) == null ? void 0 : _horizontalHandleRef$.clientWidth), maxWidth)) {
|
|
1115
|
+
newWidth = maxWidth;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
if (vertical && newHeight < minHeight) {
|
|
1119
|
+
newHeight = minHeight;
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
if (vertical && newHeight > Math.min(window.innerHeight - ((_verticalHandleRef$cu = verticalHandleRef.current) == null ? void 0 : _verticalHandleRef$cu.clientHeight), maxHeight)) {
|
|
1123
|
+
newHeight = maxHeight;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
if (horizontal) {
|
|
1127
|
+
requestAnimationFrame(() => {
|
|
1128
|
+
if (!isNil(containerRef.current)) {
|
|
1129
|
+
containerRef.current.style.width = newWidth + "px";
|
|
1130
|
+
}
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
if (vertical) {
|
|
1135
|
+
requestAnimationFrame(() => {
|
|
1136
|
+
if (!isNil(containerRef.current)) {
|
|
1137
|
+
containerRef.current.style.height = newHeight + "px";
|
|
1138
|
+
}
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
onResize == null || onResize(newWidth, newHeight);
|
|
1143
|
+
}, [minWidth, maxWidth, minHeight, maxHeight, horizontal, vertical]);
|
|
1144
|
+
const onPointerMove = useCallback(pointerMoveEvent => {
|
|
1145
|
+
var _containerRef$current, _containerRef$current2, _containerRef$current3;
|
|
1146
|
+
|
|
1147
|
+
const {
|
|
1148
|
+
x,
|
|
1149
|
+
y
|
|
1150
|
+
} = (_containerRef$current = containerRef.current) == null ? void 0 : _containerRef$current.getBoundingClientRect();
|
|
1151
|
+
const reverseHorizontal = handleHorizontalPosition === HorizontalPosition.Right;
|
|
1152
|
+
const reverseVertical = handleVerticalPosition === VerticalPosition.Bottom;
|
|
1153
|
+
const newWidth = reverseHorizontal ? pointerMoveEvent.pageX - x : ((_containerRef$current2 = containerRef.current) == null ? void 0 : _containerRef$current2.offsetWidth) + x - pointerMoveEvent.pageX;
|
|
1154
|
+
const newHeight = reverseVertical ? pointerMoveEvent.pageY - y : ((_containerRef$current3 = containerRef.current) == null ? void 0 : _containerRef$current3.offsetHeight) + y - pointerMoveEvent.pageY;
|
|
1155
|
+
document.body.style.userSelect = "none";
|
|
1156
|
+
updateSizes(newWidth, newHeight);
|
|
1157
|
+
}, [updateSizes]);
|
|
1158
|
+
const onPointerDown = useCallback(() => {
|
|
1159
|
+
const onPointerUp = () => {
|
|
1160
|
+
document.body.style.userSelect = "initial";
|
|
1161
|
+
document.body.removeEventListener("pointermove", onPointerMove);
|
|
1162
|
+
|
|
1163
|
+
if (!isNil(containerRef.current)) {
|
|
1164
|
+
onResizeEnd == null || onResizeEnd(containerRef.current.offsetWidth, containerRef.current.offsetHeight);
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
if (!isNil(containerRef.current)) {
|
|
1169
|
+
onResizeStart == null || onResizeStart(containerRef.current.offsetWidth, containerRef.current.offsetHeight);
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
document.body.addEventListener("pointermove", onPointerMove);
|
|
1173
|
+
document.body.addEventListener("pointerup", onPointerUp, {
|
|
1174
|
+
once: true
|
|
1175
|
+
});
|
|
1176
|
+
}, [onPointerMove]); // eslint-disable-line
|
|
1177
|
+
|
|
1178
|
+
useLayoutEffect(() => {
|
|
1179
|
+
if (useResize && !isNil(containerRef.current)) {
|
|
1180
|
+
updateSizes(containerRef.current.offsetWidth, containerRef.current.offsetHeight);
|
|
1181
|
+
}
|
|
1182
|
+
}, [updateSizes, useResize]);
|
|
1183
|
+
return {
|
|
1184
|
+
containerRef,
|
|
1185
|
+
verticalHandleRef,
|
|
1186
|
+
horizontalHandleRef,
|
|
1187
|
+
onPointerDown
|
|
1188
|
+
};
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1191
|
+
const useToggle = initial => {
|
|
1192
|
+
const [state, setState] = useState(initial !== undefined ? initial : false);
|
|
1193
|
+
const toggle = useCallback(() => setState(!state), [state]);
|
|
1194
|
+
return [state, toggle, setState];
|
|
1195
|
+
};
|
|
1196
|
+
|
|
1197
|
+
const _excluded = ["zIndex", "lowerSiblings", "upperSiblings", "drawTriggerDeps", "onError", "children"];
|
|
1198
|
+
const Map = (_ref) => {
|
|
1199
|
+
let {
|
|
1200
|
+
zIndex,
|
|
1201
|
+
lowerSiblings,
|
|
1202
|
+
upperSiblings,
|
|
1203
|
+
drawTriggerDeps,
|
|
1204
|
+
onError,
|
|
1205
|
+
children
|
|
1206
|
+
} = _ref,
|
|
1207
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1208
|
+
|
|
1209
|
+
const {
|
|
1210
|
+
map,
|
|
1211
|
+
setLoaded
|
|
1212
|
+
} = useMapContext();
|
|
1213
|
+
useMapDraw(drawTriggerDeps);
|
|
1214
|
+
return React.createElement(MapWrapper, {
|
|
1215
|
+
"$zIndex": zIndex
|
|
1216
|
+
}, lowerSiblings, React.createElement(MapGL, Object.assign({}, rest, {
|
|
1217
|
+
renderWorldCopies: true,
|
|
1218
|
+
antialias: true,
|
|
1219
|
+
doubleClickZoom: false,
|
|
1220
|
+
cursor: "default",
|
|
1221
|
+
onLoad: e => {
|
|
1222
|
+
map.current = e.target;
|
|
1223
|
+
map.current.on("error", onError);
|
|
1224
|
+
setLoaded(true);
|
|
1225
|
+
}
|
|
1226
|
+
}), children), upperSiblings);
|
|
1227
|
+
};
|
|
1228
|
+
|
|
1229
|
+
const BuildingsLayer = (_ref) => {
|
|
1230
|
+
let {
|
|
1231
|
+
beforeId,
|
|
1232
|
+
transparent
|
|
1233
|
+
} = _ref;
|
|
1234
|
+
return React.createElement(Layer$1, {
|
|
1235
|
+
id: "mapbox-3d-buildings",
|
|
1236
|
+
source: "composite",
|
|
1237
|
+
"source-layer": "building",
|
|
1238
|
+
filter: ["==", "extrude", "true"],
|
|
1239
|
+
type: "fill-extrusion",
|
|
1240
|
+
minzoom: 15,
|
|
1241
|
+
beforeId: beforeId,
|
|
1242
|
+
paint: {
|
|
1243
|
+
"fill-extrusion-color": "#aaaaaa",
|
|
1244
|
+
"fill-extrusion-height": ["interpolate", ["linear"], ["zoom"], 15, 0, 15.05, ["get", "height"]],
|
|
1245
|
+
"fill-extrusion-base": ["interpolate", ["linear"], ["zoom"], 15, 0, 15.05, ["get", "min_height"]],
|
|
1246
|
+
"fill-extrusion-opacity": transparent ? 0 : 0.5
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
};
|
|
1250
|
+
|
|
1251
|
+
const RasterLayer = (_ref) => {
|
|
1252
|
+
let {
|
|
1253
|
+
layer,
|
|
1254
|
+
tileUrl,
|
|
1255
|
+
visible,
|
|
1256
|
+
beforeId
|
|
1257
|
+
} = _ref;
|
|
1258
|
+
|
|
1259
|
+
if (!layer) {
|
|
1260
|
+
return null;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
return React.createElement(Source, {
|
|
1264
|
+
id: layer.name,
|
|
1265
|
+
type: "raster",
|
|
1266
|
+
tiles: [tileUrl]
|
|
1267
|
+
}, React.createElement(Layer$1, {
|
|
1268
|
+
id: layer.name,
|
|
1269
|
+
type: "raster",
|
|
1270
|
+
"source-layer": "default",
|
|
1271
|
+
beforeId: beforeId,
|
|
1272
|
+
layout: {
|
|
1273
|
+
visibility: visible ? "visible" : "none"
|
|
1274
|
+
}
|
|
1275
|
+
}));
|
|
1276
|
+
};
|
|
1277
|
+
|
|
1278
|
+
const DEFAULT_COLOR = "#00ffff";
|
|
1279
|
+
const DEFAULT_OPACITY = 0.5;
|
|
1280
|
+
const DEFAULT_SIZE = 4;
|
|
1281
|
+
const DEFAULT_LINE_WIDTH = 1;
|
|
1282
|
+
const DEFAULT_CIRCLE_PAINT = {
|
|
1283
|
+
"circle-radius": DEFAULT_SIZE,
|
|
1284
|
+
"circle-color": DEFAULT_COLOR,
|
|
1285
|
+
"circle-opacity": DEFAULT_OPACITY,
|
|
1286
|
+
"circle-stroke-width": 0,
|
|
1287
|
+
"circle-stroke-color": DEFAULT_COLOR,
|
|
1288
|
+
"circle-stroke-opacity": DEFAULT_OPACITY
|
|
1289
|
+
};
|
|
1290
|
+
const DEFAULT_FILL_PAINT = {
|
|
1291
|
+
"fill-color": DEFAULT_COLOR,
|
|
1292
|
+
"fill-opacity": DEFAULT_OPACITY
|
|
1293
|
+
};
|
|
1294
|
+
const DEFAULT_FILL_EXTRUSION_PAINT = {
|
|
1295
|
+
"fill-extrusion-base": 0,
|
|
1296
|
+
"fill-extrusion-vertical-gradient": true,
|
|
1297
|
+
"fill-extrusion-color": DEFAULT_COLOR,
|
|
1298
|
+
"fill-extrusion-opacity": DEFAULT_OPACITY,
|
|
1299
|
+
"fill-extrusion-height": 0
|
|
1300
|
+
};
|
|
1301
|
+
const DEFAULT_LINE_PAINT = {
|
|
1302
|
+
"line-color": DEFAULT_COLOR,
|
|
1303
|
+
"line-width": DEFAULT_LINE_WIDTH,
|
|
1304
|
+
"line-opacity": DEFAULT_OPACITY
|
|
1305
|
+
};
|
|
1306
|
+
|
|
1307
|
+
const getClientStyleItemPrefixSuffix = (geometryType, type) => {
|
|
1308
|
+
switch (geometryType) {
|
|
1309
|
+
case GeometryType.Point:
|
|
1310
|
+
return ["point-layer-", ""];
|
|
1311
|
+
|
|
1312
|
+
case GeometryType.Polyline:
|
|
1313
|
+
return ["polyline-layer-", ""];
|
|
1314
|
+
|
|
1315
|
+
case GeometryType.Polygon:
|
|
1316
|
+
switch (type) {
|
|
1317
|
+
case "line":
|
|
1318
|
+
return ["polygon-stroke-layer-", "-stroke"];
|
|
1319
|
+
|
|
1320
|
+
case "fill-extrusion":
|
|
1321
|
+
return ["polygon-extrusion-layer-", "-extrusion"];
|
|
1322
|
+
|
|
1323
|
+
default:
|
|
1324
|
+
return ["polygon-layer-", ""];
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
default:
|
|
1328
|
+
return ["", ""];
|
|
1329
|
+
}
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1332
|
+
const VectorLayer = (_ref) => {
|
|
1333
|
+
var _layer$configuration;
|
|
1334
|
+
|
|
1335
|
+
let {
|
|
1336
|
+
layer,
|
|
1337
|
+
tileUrl,
|
|
1338
|
+
visible,
|
|
1339
|
+
beforeId,
|
|
1340
|
+
getLayerTempStyle,
|
|
1341
|
+
onMount = () => null
|
|
1342
|
+
} = _ref;
|
|
1343
|
+
const clientStyle = layer == null || (_layer$configuration = layer.configuration) == null ? void 0 : _layer$configuration.clientStyle;
|
|
1344
|
+
const {
|
|
1345
|
+
idAttribute,
|
|
1346
|
+
geometryType
|
|
1347
|
+
} = layer.layerDefinition || {};
|
|
1348
|
+
const renderLayerByGeometryType = useCallback(() => {
|
|
1349
|
+
var _getLayerTempStyle, _getLayerTempStyle2, _getLayerTempStyle3, _getLayerTempStyle4, _getLayerTempStyle5, _getLayerTempStyle6, _getLayerTempStyle7, _getLayerTempStyle8, _getLayerTempStyle9, _getLayerTempStyle10, _getLayerTempStyle11, _getLayerTempStyle12, _getLayerTempStyle13, _getLayerTempStyle14;
|
|
1350
|
+
|
|
1351
|
+
const visibility = visible ? "visible" : "none";
|
|
1352
|
+
|
|
1353
|
+
switch (geometryType) {
|
|
1354
|
+
case GeometryType.Point:
|
|
1355
|
+
return React.createElement(Layer$1, {
|
|
1356
|
+
id: layer.name,
|
|
1357
|
+
type: "circle",
|
|
1358
|
+
"source-layer": "default",
|
|
1359
|
+
beforeId: beforeId,
|
|
1360
|
+
layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle = getLayerTempStyle(layer.name, "circle")) == null ? void 0 : _getLayerTempStyle.layout, {
|
|
1361
|
+
visibility
|
|
1362
|
+
}),
|
|
1363
|
+
paint: _extends({}, DEFAULT_CIRCLE_PAINT, getLayerTempStyle == null || (_getLayerTempStyle2 = getLayerTempStyle(layer.name, "circle")) == null ? void 0 : _getLayerTempStyle2.paint)
|
|
1364
|
+
});
|
|
1365
|
+
|
|
1366
|
+
case GeometryType.Polygon:
|
|
1367
|
+
return [React.createElement(Layer$1, {
|
|
1368
|
+
key: "polygon-layer-" + layer.name,
|
|
1369
|
+
id: layer.name,
|
|
1370
|
+
type: "fill",
|
|
1371
|
+
"source-layer": "default",
|
|
1372
|
+
beforeId: beforeId,
|
|
1373
|
+
layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle3 = getLayerTempStyle(layer.name, "fill")) == null ? void 0 : _getLayerTempStyle3.layout, {
|
|
1374
|
+
visibility: visible && (getLayerTempStyle == null || (_getLayerTempStyle4 = getLayerTempStyle(layer.name, "fill-extrusion")) == null || (_getLayerTempStyle4 = _getLayerTempStyle4.settings) == null || (_getLayerTempStyle4 = _getLayerTempStyle4.fill) == null ? void 0 : _getLayerTempStyle4.showBottomSurface) !== false && Boolean(getActualExtrusionHeight(_extends({}, DEFAULT_FILL_EXTRUSION_PAINT, getLayerTempStyle == null || (_getLayerTempStyle5 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle5.paint))) ? "visible" : "none"
|
|
1375
|
+
}),
|
|
1376
|
+
paint: _extends({}, DEFAULT_FILL_PAINT, getLayerTempStyle == null || (_getLayerTempStyle6 = getLayerTempStyle(layer.name, "fill")) == null ? void 0 : _getLayerTempStyle6.paint)
|
|
1377
|
+
}), React.createElement(Layer$1, {
|
|
1378
|
+
key: "polygon-stroke-layer-" + layer.name,
|
|
1379
|
+
id: layer.name + "-stroke",
|
|
1380
|
+
type: "line",
|
|
1381
|
+
"source-layer": "default",
|
|
1382
|
+
beforeId: beforeId,
|
|
1383
|
+
layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle7 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle7.layout, {
|
|
1384
|
+
visibility: visible && (getLayerTempStyle == null || (_getLayerTempStyle8 = getLayerTempStyle(layer.name, "fill-extrusion")) == null || (_getLayerTempStyle8 = _getLayerTempStyle8.settings) == null || (_getLayerTempStyle8 = _getLayerTempStyle8.fill) == null ? void 0 : _getLayerTempStyle8.showBottomSurface) !== false && Boolean(getActualExtrusionHeight(_extends({}, DEFAULT_FILL_EXTRUSION_PAINT, getLayerTempStyle == null || (_getLayerTempStyle9 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle9.paint))) ? "visible" : "none"
|
|
1385
|
+
}),
|
|
1386
|
+
paint: _extends({}, DEFAULT_LINE_PAINT, getLayerTempStyle == null || (_getLayerTempStyle10 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle10.paint)
|
|
1387
|
+
}), React.createElement(Layer$1, {
|
|
1388
|
+
key: "polygon-extrusion-layer-" + layer.name,
|
|
1389
|
+
id: layer.name + "-extrusion",
|
|
1390
|
+
type: "fill-extrusion",
|
|
1391
|
+
"source-layer": "default",
|
|
1392
|
+
beforeId: beforeId,
|
|
1393
|
+
minzoom: 0,
|
|
1394
|
+
maxzoom: 23,
|
|
1395
|
+
layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle11 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle11.layout, {
|
|
1396
|
+
visibility
|
|
1397
|
+
}),
|
|
1398
|
+
paint: _extends({}, DEFAULT_FILL_EXTRUSION_PAINT, getLayerTempStyle == null || (_getLayerTempStyle12 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle12.paint)
|
|
1399
|
+
})];
|
|
1400
|
+
|
|
1401
|
+
case GeometryType.Polyline:
|
|
1402
|
+
return React.createElement(Layer$1, {
|
|
1403
|
+
id: layer.name,
|
|
1404
|
+
type: "line",
|
|
1405
|
+
"source-layer": "default",
|
|
1406
|
+
beforeId: beforeId,
|
|
1407
|
+
layout: _extends({}, getLayerTempStyle == null || (_getLayerTempStyle13 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle13.layout, {
|
|
1408
|
+
visibility
|
|
1409
|
+
}),
|
|
1410
|
+
paint: _extends({}, DEFAULT_LINE_PAINT, getLayerTempStyle == null || (_getLayerTempStyle14 = getLayerTempStyle(layer.name, "line")) == null ? void 0 : _getLayerTempStyle14.paint)
|
|
1411
|
+
});
|
|
1412
|
+
|
|
1413
|
+
default:
|
|
1414
|
+
return null;
|
|
1415
|
+
}
|
|
1416
|
+
}, [geometryType, layer, beforeId, getLayerTempStyle, visible]);
|
|
1417
|
+
const renderClientStyle = useCallback(() => {
|
|
1418
|
+
return clientStyle.items.map(mockItem => {
|
|
1419
|
+
var _clientStyle$items, _getLayerTempStyle15, _getLayerTempStyle16, _currentSettings$fill, _currentSettings$fill2, _clientStyle$minzoom, _clientStyle$maxzoom, _getLayerTempStyle17, _getLayerTempStyle18;
|
|
1420
|
+
|
|
1421
|
+
const prefixSuffix = getClientStyleItemPrefixSuffix(geometryType, mockItem.type);
|
|
1422
|
+
const isExtrusionItem = mockItem.type === "fill-extrusion";
|
|
1423
|
+
const isPolygonPart = clientStyle.items.some(item => item.type === "fill-extrusion") && (mockItem.type === "fill" || mockItem.type === "line");
|
|
1424
|
+
const fillExtrusionPaint = isPolygonPart || isExtrusionItem ? _extends({}, (_clientStyle$items = clientStyle.items) == null || (_clientStyle$items = _clientStyle$items.find(item => item.type === "fill-extrusion")) == null ? void 0 : _clientStyle$items.paint, getLayerTempStyle == null || (_getLayerTempStyle15 = getLayerTempStyle(layer.name, "fill-extrusion")) == null ? void 0 : _getLayerTempStyle15.paint) : undefined;
|
|
1425
|
+
|
|
1426
|
+
const currentSettings = _extends({}, clientStyle == null ? void 0 : clientStyle.settings, getLayerTempStyle == null || (_getLayerTempStyle16 = getLayerTempStyle(layer.name, mockItem.type)) == null ? void 0 : _getLayerTempStyle16.settings);
|
|
1427
|
+
|
|
1428
|
+
const processedExtrusionHeight = getActualExtrusionHeight(fillExtrusionPaint);
|
|
1429
|
+
const hasExtrusion = Boolean(processedExtrusionHeight);
|
|
1430
|
+
const visibility = visible && (isExtrusionItem && hasExtrusion || !isPolygonPart && !isExtrusionItem || isPolygonPart && (!hasExtrusion || ((_currentSettings$fill = currentSettings == null || (_currentSettings$fill2 = currentSettings.fill) == null ? void 0 : _currentSettings$fill2.showBottomSurface) != null ? _currentSettings$fill : true))) ? "visible" : "none";
|
|
1431
|
+
return React.createElement(Layer$1, {
|
|
1432
|
+
key: "" + prefixSuffix[0] + layer.name,
|
|
1433
|
+
id: "" + layer.name + prefixSuffix[1],
|
|
1434
|
+
type: mockItem.type,
|
|
1435
|
+
"source-layer": "default",
|
|
1436
|
+
beforeId: beforeId,
|
|
1437
|
+
minzoom: (_clientStyle$minzoom = clientStyle == null ? void 0 : clientStyle.minzoom) != null ? _clientStyle$minzoom : 0,
|
|
1438
|
+
maxzoom: (_clientStyle$maxzoom = clientStyle == null ? void 0 : clientStyle.maxzoom) != null ? _clientStyle$maxzoom : 23,
|
|
1439
|
+
layout: _extends({}, mockItem.layout, getLayerTempStyle == null || (_getLayerTempStyle17 = getLayerTempStyle(layer.name, mockItem.type)) == null ? void 0 : _getLayerTempStyle17.layout, {
|
|
1440
|
+
visibility
|
|
1441
|
+
}),
|
|
1442
|
+
paint: _extends({}, mockItem.paint, getLayerTempStyle == null || (_getLayerTempStyle18 = getLayerTempStyle(layer.name, mockItem.type)) == null ? void 0 : _getLayerTempStyle18.paint)
|
|
1443
|
+
});
|
|
1444
|
+
});
|
|
1445
|
+
}, [beforeId, clientStyle, geometryType, layer.name, visible, getLayerTempStyle]);
|
|
1446
|
+
useEffect(onMount, [layer.name]); // eslint-disable-line
|
|
1447
|
+
|
|
1448
|
+
if (!layer) {
|
|
1449
|
+
return null;
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
return React.createElement(Source, {
|
|
1453
|
+
promoteId: idAttribute,
|
|
1454
|
+
id: layer.name,
|
|
1455
|
+
type: "vector",
|
|
1456
|
+
tiles: [tileUrl]
|
|
1457
|
+
}, clientStyle != null && clientStyle.items ? renderClientStyle() : renderLayerByGeometryType());
|
|
1458
|
+
};
|
|
1459
|
+
|
|
1460
|
+
const Layer = (_ref) => {
|
|
1461
|
+
let {
|
|
1462
|
+
layer,
|
|
1463
|
+
layerType,
|
|
1464
|
+
visible,
|
|
1465
|
+
beforeId,
|
|
1466
|
+
tileUrl,
|
|
1467
|
+
onMount = () => null
|
|
1468
|
+
} = _ref;
|
|
1469
|
+
useEffect(onMount, [layer.name]); // eslint-disable-line
|
|
1470
|
+
|
|
1471
|
+
if (!layer) {
|
|
1472
|
+
return null;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
if (layerType === "RasterTileLayer") {
|
|
1476
|
+
return React.createElement(RasterLayer, {
|
|
1477
|
+
layer: layer,
|
|
1478
|
+
tileUrl: tileUrl,
|
|
1479
|
+
visible: visible,
|
|
1480
|
+
beforeId: beforeId,
|
|
1481
|
+
onMount: onMount
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1485
|
+
return React.createElement(VectorLayer, {
|
|
1486
|
+
layer: layer,
|
|
1487
|
+
tileUrl: tileUrl,
|
|
1488
|
+
visible: visible,
|
|
1489
|
+
beforeId: beforeId,
|
|
1490
|
+
onMount: onMount
|
|
1491
|
+
});
|
|
1492
|
+
};
|
|
1493
|
+
|
|
1494
|
+
var _templateObject$2, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15;
|
|
1495
|
+
const ResizablePanelContainer = /*#__PURE__*/styled.div(_templateObject$2 || (_templateObject$2 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n flex-shrink: 0;\n position: relative;\n\n ", "\n\n ", "\n\n ", "\n ", "\n ", "\n ", "\n ", "\n"])), (_ref) => {
|
|
1496
|
+
let {
|
|
1497
|
+
horizontal,
|
|
1498
|
+
vertical
|
|
1499
|
+
} = _ref;
|
|
1500
|
+
return horizontal && !vertical ? css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n height: 100%;\n "]))) : !horizontal && vertical ? css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n width: 100%;\n "]))) : "";
|
|
1501
|
+
}, (_ref2) => {
|
|
1502
|
+
let {
|
|
1503
|
+
horizontal,
|
|
1504
|
+
vertical
|
|
1505
|
+
} = _ref2;
|
|
1506
|
+
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n will-change: ", ";\n "])), [horizontal && "width", vertical && "height"].filter(Boolean).join(","));
|
|
1507
|
+
}, (_ref3) => {
|
|
1508
|
+
let {
|
|
1509
|
+
maxHeight
|
|
1510
|
+
} = _ref3;
|
|
1511
|
+
return maxHeight && css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n max-height: ", "px;\n "])), maxHeight);
|
|
1512
|
+
}, (_ref4) => {
|
|
1513
|
+
let {
|
|
1514
|
+
minHeight
|
|
1515
|
+
} = _ref4;
|
|
1516
|
+
return minHeight && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n min-height: ", "px;\n "])), minHeight);
|
|
1517
|
+
}, (_ref5) => {
|
|
1518
|
+
let {
|
|
1519
|
+
maxWidth
|
|
1520
|
+
} = _ref5;
|
|
1521
|
+
return maxWidth && css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteralLoose(["\n max-width: ", "px;\n "])), maxWidth);
|
|
1522
|
+
}, (_ref6) => {
|
|
1523
|
+
let {
|
|
1524
|
+
height
|
|
1525
|
+
} = _ref6;
|
|
1526
|
+
return height && css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteralLoose(["\n height: ", ";\n "])), height);
|
|
1527
|
+
}, (_ref7) => {
|
|
1528
|
+
let {
|
|
1529
|
+
width
|
|
1530
|
+
} = _ref7;
|
|
1531
|
+
return width && css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteralLoose(["\n width: ", ";\n "])), width);
|
|
1532
|
+
});
|
|
1533
|
+
const getHandlePositionProps = (position, palette) => {
|
|
1534
|
+
switch (position) {
|
|
1535
|
+
case HorizontalPosition.Left:
|
|
1536
|
+
return css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteralLoose(["\n height: 100%;\n border-left: 2px solid ", ";\n top: 0;\n left: 0;\n cursor: ew-resize;\n "])), palette.elementDeep);
|
|
1537
|
+
|
|
1538
|
+
case HorizontalPosition.Right:
|
|
1539
|
+
return css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteralLoose(["\n height: 100%;\n border-right: 2px solid ", ";\n top: 0;\n right: 0;\n cursor: ew-resize;\n "])), palette.elementDeep);
|
|
1540
|
+
|
|
1541
|
+
case VerticalPosition.Top:
|
|
1542
|
+
return css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteralLoose(["\n width: 100%;\n border-top: 2px solid ", ";\n top: 0;\n left: 0;\n cursor: ns-resize;\n "])), palette.elementDeep);
|
|
1543
|
+
|
|
1544
|
+
case VerticalPosition.Bottom:
|
|
1545
|
+
return css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteralLoose(["\n width: 100%;\n border-bottom: 2px solid ", ";\n bottom: 0;\n left: 0;\n cursor: ns-resize;\n "])), palette.elementDeep);
|
|
1546
|
+
|
|
1547
|
+
default:
|
|
1548
|
+
return css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteralLoose(["\n width: 100%;\n border-top: 2px solid ", ";\n top: 0;\n left: 0;\n "])), palette.elementDeep);
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
const PanelDragHandle = /*#__PURE__*/styled.div(_templateObject15 || (_templateObject15 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n position: absolute;\n box-sizing: border-box;\n z-index: 3;\n\n padding: 0.25rem;\n pointer-events: ", ";\n transition: border-color 150ms cubic-bezier(0.2, 1, 0.6, 1);\n\n &:hover {\n border-color: ", ";\n }\n\n ", "\n"])), (_ref8) => {
|
|
1552
|
+
let {
|
|
1553
|
+
disabled
|
|
1554
|
+
} = _ref8;
|
|
1555
|
+
return disabled && "none";
|
|
1556
|
+
}, (_ref9) => {
|
|
1557
|
+
let {
|
|
1558
|
+
theme: {
|
|
1559
|
+
palette
|
|
1560
|
+
}
|
|
1561
|
+
} = _ref9;
|
|
1562
|
+
return palette.primary;
|
|
1563
|
+
}, (_ref10) => {
|
|
1564
|
+
let {
|
|
1565
|
+
position,
|
|
1566
|
+
theme: {
|
|
1567
|
+
palette
|
|
1568
|
+
}
|
|
1569
|
+
} = _ref10;
|
|
1570
|
+
return getHandlePositionProps(position, palette);
|
|
1571
|
+
});
|
|
1572
|
+
|
|
1573
|
+
const _excluded$1 = ["className", "handleClassName", "width", "height", "disabled", "handleVerticalPosition", "handleHorizontalPosition", "Handle", "children"];
|
|
1574
|
+
const ResizablePanel = (_ref) => {
|
|
1575
|
+
let {
|
|
1576
|
+
className,
|
|
1577
|
+
handleClassName,
|
|
1578
|
+
width,
|
|
1579
|
+
height,
|
|
1580
|
+
disabled,
|
|
1581
|
+
handleVerticalPosition = VerticalPosition.Top,
|
|
1582
|
+
handleHorizontalPosition = HorizontalPosition.Left,
|
|
1583
|
+
children
|
|
1584
|
+
} = _ref,
|
|
1585
|
+
resizeProps = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
1586
|
+
|
|
1587
|
+
const resizerProps = useMemo(() => _extends({}, resizeProps, {
|
|
1588
|
+
handleVerticalPosition,
|
|
1589
|
+
handleHorizontalPosition
|
|
1590
|
+
}), [resizeProps, handleVerticalPosition, handleHorizontalPosition]);
|
|
1591
|
+
const {
|
|
1592
|
+
containerRef,
|
|
1593
|
+
verticalHandleRef,
|
|
1594
|
+
horizontalHandleRef,
|
|
1595
|
+
onPointerDown
|
|
1596
|
+
} = useResizer(resizerProps);
|
|
1597
|
+
const {
|
|
1598
|
+
vertical,
|
|
1599
|
+
horizontal
|
|
1600
|
+
} = resizeProps;
|
|
1601
|
+
return React.createElement(ResizablePanelContainer, {
|
|
1602
|
+
ref: containerRef,
|
|
1603
|
+
width: width,
|
|
1604
|
+
height: height,
|
|
1605
|
+
style: disabled ? {
|
|
1606
|
+
height: "auto"
|
|
1607
|
+
} : undefined,
|
|
1608
|
+
className: className
|
|
1609
|
+
}, vertical && React.createElement(PanelDragHandle, {
|
|
1610
|
+
ref: verticalHandleRef,
|
|
1611
|
+
position: handleVerticalPosition,
|
|
1612
|
+
disabled: disabled,
|
|
1613
|
+
className: handleClassName,
|
|
1614
|
+
onPointerDown: onPointerDown
|
|
1615
|
+
}), horizontal && React.createElement(PanelDragHandle, {
|
|
1616
|
+
ref: horizontalHandleRef,
|
|
1617
|
+
position: handleHorizontalPosition,
|
|
1618
|
+
disabled: disabled,
|
|
1619
|
+
className: handleClassName,
|
|
1620
|
+
onPointerDown: onPointerDown
|
|
1621
|
+
}), children);
|
|
1622
|
+
};
|
|
1623
|
+
|
|
1624
|
+
const ServerNotificationsProvider = (_ref) => {
|
|
1625
|
+
let {
|
|
1626
|
+
url,
|
|
1627
|
+
initialized,
|
|
1628
|
+
children
|
|
1629
|
+
} = _ref;
|
|
1630
|
+
const connection = useServerNotifications(url, initialized);
|
|
1631
|
+
const addSubscription = useCallback(async payload => {
|
|
1632
|
+
if (!connection || connection.state !== "Connected" || !payload) {
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
try {
|
|
1637
|
+
const id = await connection.invoke("AddSubscription", payload);
|
|
1638
|
+
console.info("Подписка добавлена, id:", id);
|
|
1639
|
+
return id;
|
|
1640
|
+
} catch (err) {
|
|
1641
|
+
console.info("Ошибка добавления подписки:", err);
|
|
1642
|
+
return Promise.resolve(null);
|
|
1643
|
+
}
|
|
1644
|
+
}, [connection]);
|
|
1645
|
+
const updateSubscription = useCallback(async (id, payload) => {
|
|
1646
|
+
if (!connection || connection.state !== "Connected" || !id || !payload) {
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
try {
|
|
1651
|
+
await connection.invoke("UpdateSubscription", id, payload);
|
|
1652
|
+
} catch (err) {
|
|
1653
|
+
console.info("\u041E\u0448\u0438\u0431\u043A\u0430 \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u044F \u043F\u043E\u0434\u043F\u0438\u0441\u043A\u0438 " + id + ":", err);
|
|
1654
|
+
}
|
|
1655
|
+
}, [connection]);
|
|
1656
|
+
const unsubscribeById = useCallback(async id => {
|
|
1657
|
+
if (!connection || connection.state !== "Connected" || !id) {
|
|
1658
|
+
return;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
try {
|
|
1662
|
+
await connection.invoke("Unsubscribe", [id]);
|
|
1663
|
+
} catch (err) {
|
|
1664
|
+
console.info("\u041E\u0448\u0438\u0431\u043A\u0430 \u043E\u0442\u043F\u0438\u0441\u043A\u0438 \u043F\u043E " + id + ":", err);
|
|
1665
|
+
}
|
|
1666
|
+
}, [connection]);
|
|
1667
|
+
return React.createElement(ServerNotificationsContext.Provider, {
|
|
1668
|
+
value: {
|
|
1669
|
+
connection,
|
|
1670
|
+
addSubscription,
|
|
1671
|
+
updateSubscription,
|
|
1672
|
+
unsubscribeById
|
|
1673
|
+
}
|
|
1674
|
+
}, children);
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1677
|
+
export { BaseMapTheme, BuildingsLayer, DateFormat, ErrorBoundary, GeometryEditorMode, GeometrySelectionRouteTypes, GeometrySelectionToolTypes, GeometrySelectionTypes, GeometrySelectionZoneTypes, HorizontalPosition, Layer, Map, MapContext, MapProvider, NO_CONTENT_VALUE, ResizablePanel, ServerNotificationsContext, ServerNotificationsProvider, VerticalPosition, convertSpToTurfFeature, drawModeToGeometrySelectionType, findAttributeInExpression, formatDate, geometryToWkt, getActualExtrusionHeight, getDate, getGeometrySelectionTurfFeature, isNumeric, isObject, parseClientStyle, useCurrentSelectedFeature, useEditingFeature, useEwktGeometry, useGeometryEditor, useGeometrySelection, useGeometrySelectionBuffer, useMapContext, useMapDraw, useRedrawLayer, useResizer, useSelectFeaturesCount, useSelectFeaturesCurrentIndex, useSelectFeaturesGeometryMasking, useSelectFeaturesInitialized, useSelectFeaturesLayerName, useSelectFeaturesPagination, useSelectFeaturesStatisticsActive, useSelectFeaturesTotalCounts, useSelectedFeatures, useServerNotifications, useServerNotificationsContext, useToggle, useUpdateCurrentFeature, useZoomToFeatures, useZoomToLayer, useZoomToPoint };
|
|
60
1678
|
//# sourceMappingURL=react.esm.js.map
|