@evergis/react 4.0.38 → 4.0.39
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.js +34 -4
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +35 -6
- package/dist/react.esm.js.map +1 -1
- package/dist/utils/convertSpToTurfFeature.d.ts +3 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var charts = require('@evergis/charts');
|
|
|
8
8
|
var api = require('@evergis/api');
|
|
9
9
|
var Gradient = require('javascript-color-gradient');
|
|
10
10
|
var color$1 = require('@evergis/color');
|
|
11
|
+
var turf = require('@turf/turf');
|
|
11
12
|
var dateFns = require('date-fns');
|
|
12
13
|
var lodash = require('lodash');
|
|
13
14
|
var ru = require('date-fns/locale/ru');
|
|
@@ -17,7 +18,6 @@ var findAnd = require('find-and');
|
|
|
17
18
|
var jspdf = require('jspdf');
|
|
18
19
|
var html2canvas = require('html2canvas');
|
|
19
20
|
var MapboxDraw = require('@mapbox/mapbox-gl-draw');
|
|
20
|
-
var turf = require('@turf/turf');
|
|
21
21
|
var MapGL = require('react-map-gl/maplibre');
|
|
22
22
|
require('@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css');
|
|
23
23
|
require('mapbox-gl/dist/mapbox-gl.css');
|
|
@@ -3630,6 +3630,27 @@ const adjustColor = (color, lightnessAdjustment = 5) => {
|
|
|
3630
3630
|
return `#${toHex(rNew)}${toHex(gNew)}${toHex(bNew)}`;
|
|
3631
3631
|
};
|
|
3632
3632
|
|
|
3633
|
+
const convertSpToTurfFeature = (geometry) => {
|
|
3634
|
+
if (!geometry) {
|
|
3635
|
+
return;
|
|
3636
|
+
}
|
|
3637
|
+
const { type, coordinates } = geometry;
|
|
3638
|
+
switch (type) {
|
|
3639
|
+
case api.OgcGeometryType.Point:
|
|
3640
|
+
return turf.point(coordinates);
|
|
3641
|
+
case api.OgcGeometryType.MultiPoint:
|
|
3642
|
+
return turf.multiPoint(coordinates);
|
|
3643
|
+
case api.OgcGeometryType.LineString:
|
|
3644
|
+
return turf.lineString(coordinates);
|
|
3645
|
+
case api.OgcGeometryType.MultiLineString:
|
|
3646
|
+
return turf.multiLineString(coordinates);
|
|
3647
|
+
case api.OgcGeometryType.Polygon:
|
|
3648
|
+
return turf.polygon(coordinates);
|
|
3649
|
+
case api.OgcGeometryType.MultiPolygon:
|
|
3650
|
+
return turf.multiPolygon(coordinates);
|
|
3651
|
+
}
|
|
3652
|
+
};
|
|
3653
|
+
|
|
3633
3654
|
const NO_CONTENT_VALUE = "—";
|
|
3634
3655
|
exports.DateFormat = void 0;
|
|
3635
3656
|
(function (DateFormat) {
|
|
@@ -5341,17 +5362,25 @@ const useRedrawLayer = () => {
|
|
|
5341
5362
|
}, [map]);
|
|
5342
5363
|
};
|
|
5343
5364
|
|
|
5365
|
+
const SINGLE_FEATURE_FALLBACK_ZOOM = 17;
|
|
5344
5366
|
const useZoomToFeatures = () => {
|
|
5345
5367
|
const { map } = useMapContext();
|
|
5346
5368
|
return React.useCallback((features, options) => {
|
|
5347
5369
|
if (!features) {
|
|
5348
5370
|
return;
|
|
5349
5371
|
}
|
|
5350
|
-
const
|
|
5372
|
+
const [minX, minY, maxX, maxY] = turf.bbox({
|
|
5351
5373
|
type: "FeatureCollection",
|
|
5352
|
-
features: features,
|
|
5374
|
+
features: features.map(feature => convertSpToTurfFeature(feature.geometry)),
|
|
5375
|
+
});
|
|
5376
|
+
if (minX === maxX && minY === maxY) {
|
|
5377
|
+
map.current.flyTo({ center: [minX, minY], zoom: options?.maxZoom ?? SINGLE_FEATURE_FALLBACK_ZOOM });
|
|
5378
|
+
return;
|
|
5379
|
+
}
|
|
5380
|
+
map.current.fitBounds([minX, minY, maxX, maxY], {
|
|
5381
|
+
...options,
|
|
5382
|
+
padding: options?.padding ?? 150,
|
|
5353
5383
|
});
|
|
5354
|
-
map.current.fitBounds(currentFeatureCenter, { ...options, padding: options?.padding ?? 150 });
|
|
5355
5384
|
}, [map]);
|
|
5356
5385
|
};
|
|
5357
5386
|
|
|
@@ -12561,6 +12590,7 @@ exports.applyQueryFilters = applyQueryFilters;
|
|
|
12561
12590
|
exports.applyVarsToCondition = applyVarsToCondition;
|
|
12562
12591
|
exports.checkEqualOrIncludes = checkEqualOrIncludes;
|
|
12563
12592
|
exports.checkIsLoading = checkIsLoading;
|
|
12593
|
+
exports.convertSpToTurfFeature = convertSpToTurfFeature;
|
|
12564
12594
|
exports.createConfigLayer = createConfigLayer;
|
|
12565
12595
|
exports.createConfigPage = createConfigPage;
|
|
12566
12596
|
exports.createNewPageId = createNewPageId;
|