@evergis/react 3.1.2 → 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/index.d.ts +1 -0
- package/dist/react.cjs.development.js +953 -111
- 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 +936 -93
- package/dist/react.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/react.esm.js
CHANGED
|
@@ -1,103 +1,197 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { useContext, useMemo, createContext, useCallback, useEffect, useRef, useState, useLayoutEffect } from 'react';
|
|
5
|
-
import 'styled-components';
|
|
6
|
-
import 'react-map-gl/mapbox';
|
|
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';
|
|
7
4
|
import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
|
|
8
|
-
import 'find-and';
|
|
5
|
+
import { changeProps } from 'find-and';
|
|
6
|
+
import { isEmpty, isNil } from 'lodash-es';
|
|
9
7
|
import { isValid, toDate, format, parseJSON, parseISO } from 'date-fns';
|
|
10
8
|
import { stringify } from 'wkt';
|
|
11
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
12
|
import { HubConnectionBuilder, LogLevel } from '@microsoft/signalr';
|
|
13
13
|
import 'mapbox-gl/dist/mapbox-gl.css';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
15
|
+
function _classCallCheck(instance, Constructor) {
|
|
16
|
+
if (!(instance instanceof Constructor)) {
|
|
17
|
+
throw new TypeError("Cannot call a class as a function");
|
|
18
18
|
}
|
|
19
|
+
}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
+
}
|
|
23
47
|
}
|
|
24
48
|
|
|
25
|
-
|
|
26
|
-
|
|
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
|
|
27
65
|
}
|
|
66
|
+
});
|
|
67
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
68
|
+
}
|
|
28
69
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
+
}
|
|
32
76
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
77
|
+
function _setPrototypeOf(o, p) {
|
|
78
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
79
|
+
o.__proto__ = p;
|
|
80
|
+
return o;
|
|
81
|
+
};
|
|
36
82
|
|
|
37
|
-
|
|
38
|
-
|
|
83
|
+
return _setPrototypeOf(o, p);
|
|
84
|
+
}
|
|
39
85
|
|
|
40
|
-
|
|
41
|
-
|
|
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];
|
|
42
96
|
}
|
|
43
97
|
|
|
44
|
-
return
|
|
45
|
-
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
46
100
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
101
|
+
function _assertThisInitialized(self) {
|
|
102
|
+
if (self === void 0) {
|
|
103
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
104
|
+
}
|
|
50
105
|
|
|
51
|
-
|
|
52
|
-
|
|
106
|
+
return self;
|
|
107
|
+
}
|
|
53
108
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
109
|
+
function _possibleConstructorReturn(self, call) {
|
|
110
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
111
|
+
return call;
|
|
112
|
+
}
|
|
57
113
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}, []);
|
|
61
|
-
};
|
|
114
|
+
return _assertThisInitialized(self);
|
|
115
|
+
}
|
|
62
116
|
|
|
63
|
-
|
|
64
|
-
if (!
|
|
65
|
-
|
|
117
|
+
function _taggedTemplateLiteralLoose(strings, raw) {
|
|
118
|
+
if (!raw) {
|
|
119
|
+
raw = strings.slice(0);
|
|
66
120
|
}
|
|
67
121
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
122
|
+
strings.raw = raw;
|
|
123
|
+
return strings;
|
|
124
|
+
}
|
|
71
125
|
|
|
72
|
-
|
|
73
|
-
|
|
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"])));
|
|
74
128
|
|
|
75
|
-
|
|
76
|
-
|
|
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;
|
|
77
134
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
135
|
+
try {
|
|
136
|
+
return !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
137
|
+
} catch (e) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
81
140
|
}
|
|
82
|
-
};
|
|
83
141
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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;
|
|
88
148
|
|
|
89
|
-
|
|
90
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
91
|
-
target[key] = source[key];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
149
|
+
_classCallCheck(this, ErrorBoundary);
|
|
95
150
|
|
|
96
|
-
|
|
97
|
-
|
|
151
|
+
_this2 = _callSuper(this, ErrorBoundary, arguments);
|
|
152
|
+
_this2.state = {
|
|
153
|
+
hasError: false
|
|
154
|
+
};
|
|
155
|
+
return _this2;
|
|
156
|
+
}
|
|
98
157
|
|
|
99
|
-
|
|
100
|
-
|
|
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
|
+
});
|
|
101
195
|
|
|
102
196
|
const useMapContext = () => {
|
|
103
197
|
return useContext(MapContext);
|
|
@@ -170,6 +264,206 @@ var GeometryEditorMode;
|
|
|
170
264
|
GeometryEditorMode[GeometryEditorMode["Subtract"] = 5] = "Subtract";
|
|
171
265
|
})(GeometryEditorMode || (GeometryEditorMode = {}));
|
|
172
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
|
+
|
|
173
467
|
const useGeometryEditor = () => {
|
|
174
468
|
const {
|
|
175
469
|
geometryEditor,
|
|
@@ -578,6 +872,117 @@ const useUpdateCurrentFeature = () => {
|
|
|
578
872
|
}, [updateCurrentFeature]);
|
|
579
873
|
};
|
|
580
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
|
+
|
|
581
986
|
const useZoomToFeatures = () => {
|
|
582
987
|
const {
|
|
583
988
|
map
|
|
@@ -789,47 +1194,485 @@ const useToggle = initial => {
|
|
|
789
1194
|
return [state, toggle, setState];
|
|
790
1195
|
};
|
|
791
1196
|
|
|
792
|
-
const
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
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);
|
|
796
1208
|
|
|
797
|
-
|
|
798
|
-
|
|
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
|
+
};
|
|
799
1228
|
|
|
800
|
-
|
|
801
|
-
|
|
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
|
+
}
|
|
802
1326
|
|
|
803
1327
|
default:
|
|
804
|
-
return
|
|
1328
|
+
return ["", ""];
|
|
805
1329
|
}
|
|
806
1330
|
};
|
|
807
1331
|
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
switch (selectionType) {
|
|
811
|
-
case GeometrySelectionTypes.Point:
|
|
812
|
-
return toWgs84(point(coordinates));
|
|
1332
|
+
const VectorLayer = (_ref) => {
|
|
1333
|
+
var _layer$configuration;
|
|
813
1334
|
|
|
814
|
-
|
|
815
|
-
|
|
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
|
+
});
|
|
816
1365
|
|
|
817
|
-
case
|
|
818
|
-
return
|
|
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;
|
|
819
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;
|
|
820
1450
|
}
|
|
821
1451
|
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
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
|
+
};
|
|
825
1459
|
|
|
826
|
-
|
|
827
|
-
|
|
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
|
|
828
1470
|
|
|
829
|
-
|
|
830
|
-
|
|
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
|
+
});
|
|
831
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);
|
|
832
1675
|
};
|
|
833
1676
|
|
|
834
|
-
export { DateFormat, HorizontalPosition, NO_CONTENT_VALUE, 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 };
|
|
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 };
|
|
835
1678
|
//# sourceMappingURL=react.esm.js.map
|