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