@fleet-frontend/mower-maps 0.2.0-beta.16 → 0.2.0-beta.17
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/config/constants.d.ts +4 -0
- package/dist/config/constants.d.ts.map +1 -1
- package/dist/index.esm.js +193 -252
- package/dist/index.js +193 -252
- package/dist/processor/unified/BaseData.d.ts.map +1 -1
- package/dist/processor/unified/UnifiedMapDataProcessor.d.ts.map +1 -1
- package/dist/render/MowerMapOverlay.d.ts.map +1 -1
- package/dist/render/MowerMapRenderer.d.ts.map +1 -1
- package/dist/render/SvgMapView.d.ts.map +1 -1
- package/dist/render/drag/drag.d.ts.map +1 -1
- package/dist/render/drag/index.d.ts.map +1 -1
- package/dist/render/svgEditMap/components/HandleElementInfo/components/DirectionModal/component/MowDirection/index.d.ts.map +1 -1
- package/dist/render/svgEditMap/components/HandleElementInfo/components/DirectionModal/index.d.ts.map +1 -1
- package/dist/render/svgEditMap/components/HandleElementInfo/components/HeightModal/index.d.ts.map +1 -1
- package/dist/render/svgEditMap/components/HandleElementInfo/doodle.d.ts.map +1 -1
- package/dist/render/svgEditMap/components/HandleElementInfo/index.d.ts.map +1 -1
- package/dist/render/svgEditMap/components/HandleElementInfo/obstacle.d.ts.map +1 -1
- package/dist/render/svgEditMap/hooks/useCheckElement.d.ts.map +1 -1
- package/dist/render/svgEditMap/hooks/useCreateVisionOffElement.d.ts.map +1 -1
- package/dist/render/svgEditMap/hooks/useHistoryHandle.d.ts.map +1 -1
- package/dist/render/svgEditMap/hooks/usePolygonDrawing.d.ts.map +1 -1
- package/dist/render/svgEditMap/index.d.ts.map +1 -1
- package/dist/render/svgElement/BoundaryElement/index.d.ts.map +1 -1
- package/dist/render/svgElement/Mobile/CreateObstacleElement/coordinateUtils.d.ts.map +1 -1
- package/dist/render/svgElement/ObstacleElement/index.d.ts.map +1 -1
- package/dist/render/svgElement/PolygonELement/index.d.ts.map +1 -1
- package/dist/render/svgElement/PolygonELement/vertex/index.d.ts.map +1 -1
- package/dist/render/svgElement/TransformWrapper/DoodleTransformWrapper/DoodleTransformWrapper.d.ts.map +1 -1
- package/dist/render/svgElement/TransformWrapper/DoodleTransformWrapper/useDoodleTransform.d.ts.map +1 -1
- package/dist/render/svgElement/TransformWrapper/VisionOffTransformWrapper/VisionOffTransformWrapper.d.ts.map +1 -1
- package/dist/render/svgElement/TransformWrapper/VisionOffTransformWrapper/useVisionOffTransform.d.ts +1 -1
- package/dist/render/svgElement/TransformWrapper/VisionOffTransformWrapper/useVisionOffTransform.d.ts.map +1 -1
- package/dist/render/svgMap/index.d.ts.map +1 -1
- package/dist/render/svgMap/useSvgMapView.d.ts.map +1 -1
- package/dist/utils/mapBounds.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/render/svgElement/TransformWrapper/HandleIcon/index.d.ts +0 -7
- package/dist/render/svgElement/TransformWrapper/HandleIcon/index.d.ts.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -48,6 +48,11 @@ var REAL_TIME_DATA_TYPE;
|
|
|
48
48
|
/**
|
|
49
49
|
* 地图渲染相关常量配置
|
|
50
50
|
*/
|
|
51
|
+
// 默认坐标
|
|
52
|
+
const DEFAULT_COORDINATES = {
|
|
53
|
+
sw: [116.35497283935547, 40.0374755859375],
|
|
54
|
+
ne: [116.35584259033203, 40.038658142089844],
|
|
55
|
+
};
|
|
51
56
|
/**
|
|
52
57
|
* 缩放因子 - 将米转换为像素
|
|
53
58
|
*/
|
|
@@ -157,7 +162,6 @@ class BaseData {
|
|
|
157
162
|
*/
|
|
158
163
|
class BoundaryData extends BaseData {
|
|
159
164
|
constructor(originalData, level, channels, style) {
|
|
160
|
-
console.log('originBoundary', originalData);
|
|
161
165
|
const convertedPoints = convertPointsFormat(originalData?.points) || [];
|
|
162
166
|
super(originalData?.id, DataType.BOUNDARY, level, RenderType.POLYGON, convertedPoints, originalData);
|
|
163
167
|
const { isFlowGlobal, cuttingHeight } = convertHeightsetToParams(originalData?.height_set || 0);
|
|
@@ -720,6 +724,7 @@ class UnifiedMapDataProcessor {
|
|
|
720
724
|
for (const element of elements) {
|
|
721
725
|
try {
|
|
722
726
|
// 如果有SVG数据,创建涂鸦数据
|
|
727
|
+
// 如果有过期时间,且过期时间大于当前时间(秒级别),才需要渲染
|
|
723
728
|
if ('svg' in element &&
|
|
724
729
|
element.svg &&
|
|
725
730
|
'center' in element &&
|
|
@@ -727,7 +732,9 @@ class UnifiedMapDataProcessor {
|
|
|
727
732
|
'scale' in element &&
|
|
728
733
|
element.scale !== undefined &&
|
|
729
734
|
'direction' in element &&
|
|
730
|
-
element.direction !== undefined
|
|
735
|
+
element.direction !== undefined &&
|
|
736
|
+
(element.expiration_ts === undefined ||
|
|
737
|
+
element.expiration_ts > Math.floor(Date.now() / 1000))) {
|
|
731
738
|
const convertedPoints = convertPoint(element.center);
|
|
732
739
|
if (!convertedPoints) {
|
|
733
740
|
continue;
|
|
@@ -740,7 +747,9 @@ class UnifiedMapDataProcessor {
|
|
|
740
747
|
else if ('points' in element &&
|
|
741
748
|
element.points &&
|
|
742
749
|
Array.isArray(element.points) &&
|
|
743
|
-
element.points.length >= 3
|
|
750
|
+
element.points.length >= 3 &&
|
|
751
|
+
(element.expiration_ts === undefined ||
|
|
752
|
+
element.expiration_ts > Math.floor(Date.now() / 1000))) {
|
|
744
753
|
const convertedPoints = convertPointsFormat(element.points);
|
|
745
754
|
if (!convertedPoints || convertedPoints.length < 3) {
|
|
746
755
|
continue;
|
|
@@ -1461,51 +1470,46 @@ function estimateGpsFromMapBounds(mapData) {
|
|
|
1461
1470
|
if (!bounds || bounds.minX === Infinity) {
|
|
1462
1471
|
return {
|
|
1463
1472
|
sw: [0, 0],
|
|
1464
|
-
ne: [0, 0]
|
|
1473
|
+
ne: [0, 0],
|
|
1465
1474
|
};
|
|
1466
1475
|
}
|
|
1467
1476
|
// 将边界数据转换为物理单位(米)
|
|
1468
|
-
const minXMeters = bounds.minX / SCALE_FACTOR
|
|
1469
|
-
const minYMeters = bounds.minY / SCALE_FACTOR
|
|
1470
|
-
const maxXMeters = bounds.maxX / SCALE_FACTOR
|
|
1471
|
-
const maxYMeters = bounds.maxY / SCALE_FACTOR
|
|
1477
|
+
const minXMeters = bounds.minX / SCALE_FACTOR; // 西边界
|
|
1478
|
+
const minYMeters = bounds.minY / SCALE_FACTOR; // 南边界
|
|
1479
|
+
const maxXMeters = bounds.maxX / SCALE_FACTOR; // 东边界
|
|
1480
|
+
const maxYMeters = bounds.maxY / SCALE_FACTOR; // 北边界
|
|
1472
1481
|
const mapWidthMeters = maxXMeters - minXMeters;
|
|
1473
1482
|
const mapHeightMeters = maxYMeters - minYMeters;
|
|
1474
|
-
//
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
baseLat = 39.9042; // 北京天安门
|
|
1480
|
-
baseLng = 116.4074;
|
|
1481
|
-
}
|
|
1482
|
-
else if (mapWidthMeters < 10000 && mapHeightMeters < 10000) {
|
|
1483
|
-
// 中型区域 - 使用城市级别的基准点
|
|
1484
|
-
baseLat = 39.9000;
|
|
1485
|
-
baseLng = 116.4000;
|
|
1486
|
-
}
|
|
1487
|
-
else {
|
|
1488
|
-
// 大型区域 - 使用更大范围的基准点
|
|
1489
|
-
baseLat = 40.0000;
|
|
1490
|
-
baseLng = 116.0000;
|
|
1491
|
-
}
|
|
1483
|
+
// 凤凰岭的GPS坐标作为地图中心点
|
|
1484
|
+
const centerLat = 40.103;
|
|
1485
|
+
const centerLng = 116.072222;
|
|
1486
|
+
// const centerLat = 40.03806686401367;
|
|
1487
|
+
// const centerLng = 116.35540771484375;
|
|
1492
1488
|
// 精确的坐标转换常数
|
|
1493
1489
|
// 1度纬度 = 约111,320米(在地球上任何地方都基本相同)
|
|
1494
1490
|
// 1度经度 = 约111,320 * cos(纬度) 米(随纬度变化)
|
|
1495
1491
|
const METERS_PER_DEGREE_LAT = 111320;
|
|
1496
|
-
const METERS_PER_DEGREE_LNG = 111320 * Math.cos(
|
|
1492
|
+
const METERS_PER_DEGREE_LNG = 111320 * Math.cos((centerLat * Math.PI) / 180);
|
|
1497
1493
|
// 计算SW(西南角)GPS坐标
|
|
1498
|
-
|
|
1499
|
-
const
|
|
1494
|
+
// 从中心点减去半个地图的宽度和高度
|
|
1495
|
+
const swLat = centerLat - mapHeightMeters / 2 / METERS_PER_DEGREE_LAT;
|
|
1496
|
+
const swLng = centerLng - mapWidthMeters / 2 / METERS_PER_DEGREE_LNG;
|
|
1500
1497
|
// 计算NE(东北角)GPS坐标
|
|
1501
|
-
|
|
1502
|
-
const
|
|
1498
|
+
// 从中心点加上半个地图的宽度和高度
|
|
1499
|
+
const neLat = centerLat + mapHeightMeters / 2 / METERS_PER_DEGREE_LAT;
|
|
1500
|
+
const neLng = centerLng + mapWidthMeters / 2 / METERS_PER_DEGREE_LNG;
|
|
1503
1501
|
// 验证估算的坐标是否在合理范围内
|
|
1504
|
-
if (swLat < -90 ||
|
|
1505
|
-
|
|
1502
|
+
if (swLat < -90 ||
|
|
1503
|
+
swLat > 90 ||
|
|
1504
|
+
swLng < -180 ||
|
|
1505
|
+
swLng > 180 ||
|
|
1506
|
+
neLat < -90 ||
|
|
1507
|
+
neLat > 90 ||
|
|
1508
|
+
neLng < -180 ||
|
|
1509
|
+
neLng > 180) {
|
|
1506
1510
|
console.warn('估算的GPS坐标超出有效范围:', {
|
|
1507
1511
|
sw: [swLng, swLat],
|
|
1508
|
-
ne: [neLng, neLat]
|
|
1512
|
+
ne: [neLng, neLat],
|
|
1509
1513
|
});
|
|
1510
1514
|
return null;
|
|
1511
1515
|
}
|
|
@@ -1513,13 +1517,13 @@ function estimateGpsFromMapBounds(mapData) {
|
|
|
1513
1517
|
if (swLat >= neLat || swLng >= neLng) {
|
|
1514
1518
|
console.warn('GPS边界坐标逻辑错误:', {
|
|
1515
1519
|
sw: [swLng, swLat],
|
|
1516
|
-
ne: [neLng, neLat]
|
|
1520
|
+
ne: [neLng, neLat],
|
|
1517
1521
|
});
|
|
1518
1522
|
return null;
|
|
1519
1523
|
}
|
|
1520
1524
|
return {
|
|
1521
1525
|
sw: [swLng, swLat], // [经度, 纬度]
|
|
1522
|
-
ne: [neLng, neLat] // [经度, 纬度]
|
|
1526
|
+
ne: [neLng, neLat], // [经度, 纬度]
|
|
1523
1527
|
};
|
|
1524
1528
|
}
|
|
1525
1529
|
catch (error) {
|
|
@@ -8561,23 +8565,6 @@ const useDrag = ({ dragCallbacks, onBoundaryLabelsCollapse, onTransformChange, }
|
|
|
8561
8565
|
|
|
8562
8566
|
// 编辑模式相关常量配置
|
|
8563
8567
|
// 默认的旋转图标
|
|
8564
|
-
const DEFAULT_ROTATE_ICON = `
|
|
8565
|
-
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
8566
|
-
<g clip-path="url(#clip0_8198_30743)">
|
|
8567
|
-
<path d="M20 10C20 15.5228 15.5228 20 10 20C4.47715 20 0 15.5228 0 10C0 4.47715 4.47715 0 10 0C15.5228 0 20 4.47715 20 10Z" fill="url(#paint0_linear_8198_30743)"/>
|
|
8568
|
-
<path d="M11.4894 14.7176C10.4257 14.9506 9.31616 14.8595 8.30481 14.4558C7.29342 14.0521 6.4264 13.3535 5.81555 12.4519C5.24299 11.6068 4.92013 10.6187 4.88196 9.60134L4.87805 9.39724C4.87805 8.94523 5.24441 8.57892 5.69641 8.57888C6.12014 8.57888 6.46888 8.90061 6.51087 9.31325L6.51477 9.39724L6.52551 9.68142C6.57513 10.3429 6.79716 10.9821 7.17102 11.534C7.54479 12.0855 8.05583 12.528 8.65149 12.8191L8.91223 12.9343C9.61943 13.2166 10.395 13.2809 11.1388 13.1179L11.4142 13.0467C11.6075 12.9889 11.795 12.9149 11.9757 12.8279L10.8282 12.3865C10.4074 12.2245 10.1977 11.7518 10.3595 11.3308C10.5215 10.9099 10.9941 10.7003 11.4152 10.8621L13.9562 11.8386C14.3773 12.0005 14.5878 12.4732 14.4259 12.8943C14.3891 12.9901 14.3364 13.0752 14.2716 13.1472L14.2726 13.1482C13.5227 13.9377 12.5531 14.4845 11.4894 14.7176Z" fill="white"/>
|
|
8569
|
-
<path d="M8.51062 4.54807C9.57433 4.31505 10.6838 4.40612 11.6952 4.80979C12.7066 5.21356 13.5736 5.91214 14.1844 6.8137C14.757 7.65884 15.0799 8.64688 15.118 9.66429L15.1219 9.86839C15.1219 10.3204 14.7556 10.6867 14.3036 10.6867C13.8799 10.6867 13.5311 10.365 13.4891 9.95237L13.4852 9.86839L13.4745 9.58421C13.4249 8.92272 13.2028 8.28348 12.829 7.73167C12.4552 7.18008 11.9442 6.73767 11.3485 6.44651L11.0878 6.33128C10.3806 6.04903 9.60501 5.98477 8.8612 6.14768L8.58581 6.21897C8.39252 6.27673 8.20502 6.35068 8.02429 6.43772L9.17175 6.87913C9.59256 7.04116 9.8023 7.51383 9.6405 7.93479C9.47855 8.35574 9.00587 8.56537 8.58484 8.40354L6.04382 7.42698C5.6227 7.26512 5.41224 6.79244 5.57409 6.37132C5.61094 6.27552 5.66365 6.19044 5.72839 6.11839L5.72742 6.11741C6.47734 5.32789 7.44693 4.78114 8.51062 4.54807Z" fill="white"/>
|
|
8570
|
-
</g>
|
|
8571
|
-
<defs>
|
|
8572
|
-
<linearGradient id="paint0_linear_8198_30743" x1="17.7273" y1="16.3636" x2="-1.21533" y2="2.08814e-07" gradientUnits="userSpaceOnUse">
|
|
8573
|
-
<stop stop-color="#F16629"/>
|
|
8574
|
-
<stop offset="1" stop-color="#F1A129"/>
|
|
8575
|
-
</linearGradient>
|
|
8576
|
-
<clipPath id="clip0_8198_30743">
|
|
8577
|
-
<rect width="20" height="20" fill="white" transform="matrix(-1 0 0 1 20 0)"/>
|
|
8578
|
-
</clipPath>
|
|
8579
|
-
</defs>
|
|
8580
|
-
</svg>`;
|
|
8581
8568
|
// 默认的拖拽图标
|
|
8582
8569
|
const DEFAULT_DRAG_ICON = `
|
|
8583
8570
|
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -8591,41 +8578,6 @@ const DEFAULT_DRAG_ICON = `
|
|
|
8591
8578
|
</defs>
|
|
8592
8579
|
</svg>`;
|
|
8593
8580
|
|
|
8594
|
-
function styleInject(css, ref) {
|
|
8595
|
-
if ( ref === void 0 ) ref = {};
|
|
8596
|
-
var insertAt = ref.insertAt;
|
|
8597
|
-
|
|
8598
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
8599
|
-
|
|
8600
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
8601
|
-
var style = document.createElement('style');
|
|
8602
|
-
style.type = 'text/css';
|
|
8603
|
-
|
|
8604
|
-
if (insertAt === 'top') {
|
|
8605
|
-
if (head.firstChild) {
|
|
8606
|
-
head.insertBefore(style, head.firstChild);
|
|
8607
|
-
} else {
|
|
8608
|
-
head.appendChild(style);
|
|
8609
|
-
}
|
|
8610
|
-
} else {
|
|
8611
|
-
head.appendChild(style);
|
|
8612
|
-
}
|
|
8613
|
-
|
|
8614
|
-
if (style.styleSheet) {
|
|
8615
|
-
style.styleSheet.cssText = css;
|
|
8616
|
-
} else {
|
|
8617
|
-
style.appendChild(document.createTextNode(css));
|
|
8618
|
-
}
|
|
8619
|
-
}
|
|
8620
|
-
|
|
8621
|
-
var css_248z$9 = ".index-module_edit__-5VvX {\n position: absolute;\n top: 0px;\n left: 0px;\n width: 100%;\n height: 100%;\n pointer-events: auto;\n z-index: 1000;\n cursor: move;\n touch-action: none;\n user-select: none;\n -webkit-tap-highlight-color: transparent;\n}\n.index-module_edit__-5VvX .index-module_border__JdNLM {\n position: absolute;\n inset: -10px;\n border: 2px dashed rgb(241, 102, 41);\n border-radius: 2px;\n pointer-events: none;\n}\n.index-module_edit__-5VvX .index-module_drag__uvdPG {\n position: absolute;\n inset: -10px;\n border-radius: 2px;\n}\n.index-module_edit__-5VvX .index-module_rotate__H-KIZ {\n position: absolute;\n top: -20px;\n right: -20px;\n width: 20px;\n height: 20px;\n cursor: grab;\n z-index: 1001;\n pointer-events: auto;\n}\n.index-module_edit__-5VvX .index-module_move__mZF8s {\n position: absolute;\n bottom: -20px;\n left: -20px;\n width: 20px;\n height: 20px;\n cursor: move;\n z-index: 1001;\n pointer-events: auto;\n}";
|
|
8622
|
-
var styles$9 = {"edit":"index-module_edit__-5VvX","border":"index-module_border__JdNLM","drag":"index-module_drag__uvdPG","rotate":"index-module_rotate__H-KIZ","move":"index-module_move__mZF8s"};
|
|
8623
|
-
styleInject(css_248z$9);
|
|
8624
|
-
|
|
8625
|
-
const RotateHandle = ({ onRotateStart, isRotating }) => {
|
|
8626
|
-
return (jsx("div", { className: styles$9.rotate, onMouseDown: (e) => onRotateStart(e), onTouchStart: (e) => onRotateStart(e), style: { cursor: isRotating ? 'grabbing' : 'grab' }, dangerouslySetInnerHTML: { __html: DEFAULT_ROTATE_ICON } }));
|
|
8627
|
-
};
|
|
8628
|
-
|
|
8629
8581
|
/**
|
|
8630
8582
|
* 高级节流函数
|
|
8631
8583
|
* @param func 要节流的函数
|
|
@@ -8695,16 +8647,45 @@ function isMobileDevice() {
|
|
|
8695
8647
|
return isMobileUserAgent || (hasTouchScreen && isSmallScreen);
|
|
8696
8648
|
}
|
|
8697
8649
|
|
|
8650
|
+
function styleInject(css, ref) {
|
|
8651
|
+
if ( ref === void 0 ) ref = {};
|
|
8652
|
+
var insertAt = ref.insertAt;
|
|
8653
|
+
|
|
8654
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
8655
|
+
|
|
8656
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
8657
|
+
var style = document.createElement('style');
|
|
8658
|
+
style.type = 'text/css';
|
|
8659
|
+
|
|
8660
|
+
if (insertAt === 'top') {
|
|
8661
|
+
if (head.firstChild) {
|
|
8662
|
+
head.insertBefore(style, head.firstChild);
|
|
8663
|
+
} else {
|
|
8664
|
+
head.appendChild(style);
|
|
8665
|
+
}
|
|
8666
|
+
} else {
|
|
8667
|
+
head.appendChild(style);
|
|
8668
|
+
}
|
|
8669
|
+
|
|
8670
|
+
if (style.styleSheet) {
|
|
8671
|
+
style.styleSheet.cssText = css;
|
|
8672
|
+
} else {
|
|
8673
|
+
style.appendChild(document.createTextNode(css));
|
|
8674
|
+
}
|
|
8675
|
+
}
|
|
8676
|
+
|
|
8677
|
+
var css_248z$9 = ".index-module_edit__-5VvX {\n position: absolute;\n top: 0px;\n left: 0px;\n width: 100%;\n height: 100%;\n pointer-events: auto;\n z-index: 1000;\n cursor: move;\n touch-action: none;\n user-select: none;\n -webkit-tap-highlight-color: transparent;\n}\n.index-module_edit__-5VvX .index-module_border__JdNLM {\n position: absolute;\n inset: -10px;\n border: 2px dashed rgb(241, 102, 41);\n border-radius: 2px;\n pointer-events: none;\n}\n.index-module_edit__-5VvX .index-module_drag__uvdPG {\n position: absolute;\n inset: -10px;\n border-radius: 2px;\n}\n.index-module_edit__-5VvX .index-module_rotate__H-KIZ {\n position: absolute;\n top: -20px;\n right: -20px;\n width: 20px;\n height: 20px;\n cursor: grab;\n z-index: 1001;\n pointer-events: auto;\n}\n.index-module_edit__-5VvX .index-module_move__mZF8s {\n position: absolute;\n bottom: -20px;\n left: -20px;\n width: 20px;\n height: 20px;\n cursor: move;\n z-index: 1001;\n pointer-events: auto;\n}";
|
|
8678
|
+
var styles$9 = {"edit":"index-module_edit__-5VvX","border":"index-module_border__JdNLM","drag":"index-module_drag__uvdPG","move":"index-module_move__mZF8s"};
|
|
8679
|
+
styleInject(css_248z$9);
|
|
8680
|
+
|
|
8698
8681
|
const DragHandle = ({ onDragStart, isDragging }) => {
|
|
8699
8682
|
// 在PC设备上隐藏拖拽手柄
|
|
8700
8683
|
if (!isMobileDevice()) {
|
|
8701
8684
|
return null;
|
|
8702
8685
|
}
|
|
8703
8686
|
return (jsx("div", { className: styles$9.move, onMouseDown: (e) => {
|
|
8704
|
-
console.log('down');
|
|
8705
8687
|
onDragStart(e);
|
|
8706
8688
|
}, onTouchStart: (e) => onDragStart(e), onMouseUp: (e) => {
|
|
8707
|
-
console.log('drag up');
|
|
8708
8689
|
// onDragEnd(e);
|
|
8709
8690
|
},
|
|
8710
8691
|
// onTouchEnd={(e) => onDragEnd(e)}
|
|
@@ -8712,7 +8693,7 @@ const DragHandle = ({ onDragStart, isDragging }) => {
|
|
|
8712
8693
|
};
|
|
8713
8694
|
|
|
8714
8695
|
const MapDrag = ({ map: _map, dragCallbacks, onBoundaryLabelsCollapse, onTransformChange, isDragMap = false, }) => {
|
|
8715
|
-
const { isDragging,
|
|
8696
|
+
const { isDragging, handleDragStart, addGlobalListeners } = useDrag({
|
|
8716
8697
|
dragCallbacks,
|
|
8717
8698
|
onBoundaryLabelsCollapse,
|
|
8718
8699
|
onTransformChange,
|
|
@@ -8723,10 +8704,6 @@ const MapDrag = ({ map: _map, dragCallbacks, onBoundaryLabelsCollapse, onTransfo
|
|
|
8723
8704
|
const cleanup = addGlobalListeners();
|
|
8724
8705
|
return cleanup;
|
|
8725
8706
|
}, [addGlobalListeners]);
|
|
8726
|
-
// 处理旋转开始
|
|
8727
|
-
const handleRotateStart = (e) => {
|
|
8728
|
-
handleDragStart(e, 'rotate', containerRef?.current);
|
|
8729
|
-
};
|
|
8730
8707
|
// 处理拖拽开始
|
|
8731
8708
|
const handleDragStartEvent = (e) => {
|
|
8732
8709
|
handleDragStart(e, 'drag', containerRef?.current);
|
|
@@ -8734,7 +8711,7 @@ const MapDrag = ({ map: _map, dragCallbacks, onBoundaryLabelsCollapse, onTransfo
|
|
|
8734
8711
|
if (!isDragMap) {
|
|
8735
8712
|
return null;
|
|
8736
8713
|
}
|
|
8737
|
-
return (jsxs("div", { ref: containerRef, className: styles$9.edit, style: { cursor: isDragging ? 'grabbing' : 'move' }, children: [jsx("div", { className: styles$9.border }), jsx(
|
|
8714
|
+
return (jsxs("div", { ref: containerRef, className: styles$9.edit, style: { cursor: isDragging ? 'grabbing' : 'move' }, children: [jsx("div", { className: styles$9.border }), jsx("div", { className: styles$9.drag, onMouseDown: handleDragStartEvent, onTouchStart: handleDragStartEvent }), jsx(DragHandle, { onDragStart: handleDragStartEvent, isDragging: isDragging })] }));
|
|
8738
8715
|
};
|
|
8739
8716
|
|
|
8740
8717
|
/**
|
|
@@ -8785,6 +8762,7 @@ class SvgMapView {
|
|
|
8785
8762
|
svg.style.width = '100%';
|
|
8786
8763
|
svg.style.height = '100%';
|
|
8787
8764
|
svg.style.background = 'transparent';
|
|
8765
|
+
svg.style.overflow = 'visible';
|
|
8788
8766
|
return svg;
|
|
8789
8767
|
}
|
|
8790
8768
|
/**
|
|
@@ -8876,7 +8854,7 @@ class SvgMapView {
|
|
|
8876
8854
|
* 设置自适应视图变换 - 让SVG刚好包裹住图形
|
|
8877
8855
|
*/
|
|
8878
8856
|
fitToView(bounds) {
|
|
8879
|
-
const padding =
|
|
8857
|
+
const padding = 0;
|
|
8880
8858
|
const boundWidth = bounds.maxX - bounds.minX + padding * 2;
|
|
8881
8859
|
const boundHeight = bounds.maxY - bounds.minY + padding * 2;
|
|
8882
8860
|
// 防止宽高为0的情况
|
|
@@ -8885,7 +8863,16 @@ class SvgMapView {
|
|
|
8885
8863
|
return;
|
|
8886
8864
|
}
|
|
8887
8865
|
// 获取容器的实际尺寸进行验证
|
|
8888
|
-
this.container.getBoundingClientRect();
|
|
8866
|
+
const containerRect = this.container.getBoundingClientRect();
|
|
8867
|
+
const containerWidth = containerRect.width;
|
|
8868
|
+
const containerHeight = containerRect.height;
|
|
8869
|
+
if (containerWidth <= 0 || containerHeight <= 0) {
|
|
8870
|
+
console.warn('Invalid container size:', containerWidth, containerHeight);
|
|
8871
|
+
return;
|
|
8872
|
+
}
|
|
8873
|
+
// // 计算内容和容器的宽高比
|
|
8874
|
+
// const contentAspectRatio = boundWidth / boundHeight;
|
|
8875
|
+
// const containerAspectRatio = containerWidth / containerHeight;
|
|
8889
8876
|
// 设置viewBox以包含所有内容
|
|
8890
8877
|
this.viewBox = {
|
|
8891
8878
|
x: bounds.minX - padding,
|
|
@@ -14147,6 +14134,7 @@ const useSvgMapView = ({ mapData, pathData, unitType: _unitType = UnitsType.Impe
|
|
|
14147
14134
|
// 调用回调
|
|
14148
14135
|
const elementCount = elements.length;
|
|
14149
14136
|
onMapLoad?.(elementCount);
|
|
14137
|
+
x;
|
|
14150
14138
|
}
|
|
14151
14139
|
catch (error) {
|
|
14152
14140
|
console.error('加载地图数据时出错:', error);
|
|
@@ -14200,9 +14188,7 @@ const useSvgMapView = ({ mapData, pathData, unitType: _unitType = UnitsType.Impe
|
|
|
14200
14188
|
}, [mapConfig, onPathLoad]);
|
|
14201
14189
|
// 初始化 SVG 地图视图
|
|
14202
14190
|
const initializeSvgMapView = useCallback((container) => {
|
|
14203
|
-
console.log('initializeSvgMapView called, container:', container, svgMapViewRef.current);
|
|
14204
14191
|
if (!container || svgMapViewRef.current) {
|
|
14205
|
-
console.log('Skipping initialization - container missing or already initialized');
|
|
14206
14192
|
return;
|
|
14207
14193
|
}
|
|
14208
14194
|
containerRef.current = container;
|
|
@@ -14216,12 +14202,10 @@ const useSvgMapView = ({ mapData, pathData, unitType: _unitType = UnitsType.Impe
|
|
|
14216
14202
|
offscreenContainerRef.current = offscreenContainer;
|
|
14217
14203
|
// 创建 SvgMapView 实例
|
|
14218
14204
|
svgMapViewRef.current = new SvgMapView(sn, offscreenContainer, 800, 600);
|
|
14219
|
-
console.log('SvgMapView created:', svgMapViewRef.current);
|
|
14220
14205
|
// 加载地图数据
|
|
14221
14206
|
loadMapData();
|
|
14222
14207
|
// 加载路径数据
|
|
14223
14208
|
if (pathData && svgMapViewRef.current) {
|
|
14224
|
-
console.log('Loading path data:', pathData);
|
|
14225
14209
|
loadPathData(pathData, mowPartitionData);
|
|
14226
14210
|
}
|
|
14227
14211
|
else {
|
|
@@ -14237,7 +14221,6 @@ const useSvgMapView = ({ mapData, pathData, unitType: _unitType = UnitsType.Impe
|
|
|
14237
14221
|
if (svgElement) {
|
|
14238
14222
|
svgElementRef.current = svgElement;
|
|
14239
14223
|
container.appendChild(svgElement);
|
|
14240
|
-
console.log('SVG element added to container');
|
|
14241
14224
|
}
|
|
14242
14225
|
else {
|
|
14243
14226
|
console.warn('Failed to get SVG element from SvgMapView');
|
|
@@ -14279,8 +14262,6 @@ const useSvgMapView = ({ mapData, pathData, unitType: _unitType = UnitsType.Impe
|
|
|
14279
14262
|
const setTransform = useCallback((transform) => {
|
|
14280
14263
|
if (!svgMapViewRef.current)
|
|
14281
14264
|
return;
|
|
14282
|
-
console.log('SvgMapView setTransform called with:', transform);
|
|
14283
|
-
// 使用SvgMapView的transform API
|
|
14284
14265
|
svgMapViewRef.current.setTransform(transform);
|
|
14285
14266
|
}, []);
|
|
14286
14267
|
// 重置到默认变换
|
|
@@ -14351,7 +14332,6 @@ const useSvgMapView = ({ mapData, pathData, unitType: _unitType = UnitsType.Impe
|
|
|
14351
14332
|
// 监听pathData变化,确保路径数据能够被加载
|
|
14352
14333
|
useEffect(() => {
|
|
14353
14334
|
if (svgMapViewRef.current && pathData) {
|
|
14354
|
-
console.log('PathData changed, reloading...', pathData);
|
|
14355
14335
|
loadPathData(pathData, mowPartitionData);
|
|
14356
14336
|
svgMapViewRef.current.refresh();
|
|
14357
14337
|
}
|
|
@@ -14359,7 +14339,6 @@ const useSvgMapView = ({ mapData, pathData, unitType: _unitType = UnitsType.Impe
|
|
|
14359
14339
|
useEffect(() => {
|
|
14360
14340
|
if (svgMapViewRef.current && mapData) {
|
|
14361
14341
|
loadMapData();
|
|
14362
|
-
console.log('mapData changed, reloading...', mapData);
|
|
14363
14342
|
svgMapViewRef.current.refresh();
|
|
14364
14343
|
}
|
|
14365
14344
|
}, [mapData, loadMapData]);
|
|
@@ -14443,7 +14422,6 @@ const SvgMapComponent = forwardRef(({ editMap, rotate, mapData, pathData, modelT
|
|
|
14443
14422
|
// 初始化 SVG 地图
|
|
14444
14423
|
useEffect(() => {
|
|
14445
14424
|
if (containerRef.current && mapData && !svgMapView) {
|
|
14446
|
-
console.log('Initializing SVG map view, containerRef->', containerRef.current);
|
|
14447
14425
|
initializeSvgMapView(containerRef.current);
|
|
14448
14426
|
}
|
|
14449
14427
|
}, [mapData, svgMapView, initializeSvgMapView, pathData]);
|
|
@@ -15114,20 +15092,20 @@ const DashPath = ({ points, stroke, strokeWidth, strokeOpacity, className, }) =>
|
|
|
15114
15092
|
};
|
|
15115
15093
|
|
|
15116
15094
|
const VertexElement = React__default.memo(({ r, stroke, fill, ...props }) => {
|
|
15117
|
-
const { overlayScale
|
|
15095
|
+
const { overlayScale } = useCommonContext();
|
|
15118
15096
|
const radius = typeof r === 'number' ? r : 12;
|
|
15119
|
-
return (jsx("circle", { r:
|
|
15097
|
+
return (jsx("circle", { r: radius * overlayScale, stroke: stroke || '#fff', fill: fill || '#fff', strokeWidth: 2 * overlayScale, ...props }));
|
|
15120
15098
|
});
|
|
15121
15099
|
|
|
15122
|
-
var _path$
|
|
15123
|
-
function _extends$
|
|
15100
|
+
var _path$4;
|
|
15101
|
+
function _extends$a() { return _extends$a = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$a.apply(null, arguments); }
|
|
15124
15102
|
var SvgDelete = function SvgDelete(props) {
|
|
15125
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
|
15103
|
+
return /*#__PURE__*/React.createElement("svg", _extends$a({
|
|
15126
15104
|
xmlns: "http://www.w3.org/2000/svg",
|
|
15127
15105
|
width: 16,
|
|
15128
15106
|
height: 16,
|
|
15129
15107
|
fill: "none"
|
|
15130
|
-
}, props), _path$
|
|
15108
|
+
}, props), _path$4 || (_path$4 = /*#__PURE__*/React.createElement("path", {
|
|
15131
15109
|
fill: "#FD494D",
|
|
15132
15110
|
d: "M6.667 12a.667.667 0 0 0 .666-.667v-4a.667.667 0 1 0-1.333 0v4a.667.667 0 0 0 .667.667m6.666-8h-2.666v-.667a2 2 0 0 0-2-2H7.333a2 2 0 0 0-2 2V4H2.667a.667.667 0 0 0 0 1.333h.666v7.334a2 2 0 0 0 2 2h5.334a2 2 0 0 0 2-2V5.333h.666a.667.667 0 1 0 0-1.333m-6.666-.667a.667.667 0 0 1 .666-.666h1.334a.667.667 0 0 1 .666.666V4H6.667zm4.666 9.334a.667.667 0 0 1-.666.666H5.333a.667.667 0 0 1-.666-.666V5.333h6.666zm-2-.667a.667.667 0 0 0 .667-.667v-4a.667.667 0 0 0-1.333 0v4a.667.667 0 0 0 .666.667"
|
|
15133
15111
|
})));
|
|
@@ -15604,7 +15582,6 @@ const useCheckElement = () => {
|
|
|
15604
15582
|
const { editMapInfo, minDistance } = useMapEditContext();
|
|
15605
15583
|
const { svgElementDatas } = useSvgEditContext();
|
|
15606
15584
|
const checkDoodle = useCallback(() => {
|
|
15607
|
-
console.log('checkdoodle', editMapInfo, svgElementDatas);
|
|
15608
15585
|
if (!editMapInfo.selectElement || editMapInfo.selectElement.type !== DataType.DOODLE) {
|
|
15609
15586
|
return {
|
|
15610
15587
|
isValid: false,
|
|
@@ -15628,18 +15605,12 @@ const useCheckElement = () => {
|
|
|
15628
15605
|
// 1. 首先判断 doodle 是否在一个 boundary 内
|
|
15629
15606
|
let isInBoundary = false;
|
|
15630
15607
|
let containingBoundary = null;
|
|
15631
|
-
console.log('doodlePoints--->', doodleElement, doodlePoints);
|
|
15632
15608
|
for (const boundaryData of boundary) {
|
|
15633
15609
|
const boundaryPoints = coordinatesToPoints$1(boundaryData.points);
|
|
15634
15610
|
const allPointsInside = doodlePoints.every((point) => {
|
|
15635
15611
|
const isIn = isPointInPolygon(point, boundaryPoints);
|
|
15636
|
-
// console.log('isIn--->', isIn, point, boundaryPoints);
|
|
15637
|
-
if (!isIn) {
|
|
15638
|
-
console.log('isIn--->', isIn, point, boundaryPoints);
|
|
15639
|
-
}
|
|
15640
15612
|
return isIn;
|
|
15641
15613
|
});
|
|
15642
|
-
console.log('allPointsInside--->', allPointsInside, boundaryPoints, boundaryData);
|
|
15643
15614
|
if (allPointsInside) {
|
|
15644
15615
|
isInBoundary = true;
|
|
15645
15616
|
containingBoundary = boundaryData;
|
|
@@ -15697,7 +15668,6 @@ const useCheckElement = () => {
|
|
|
15697
15668
|
}
|
|
15698
15669
|
// 检查距离是否大于 2m
|
|
15699
15670
|
const distance = polygonToPolygonDistance(doodlePoints, elementPoints);
|
|
15700
|
-
console.log('distance--->', distance, minDistance, doodlePoints, elementPoints);
|
|
15701
15671
|
if (distance < minDistance) {
|
|
15702
15672
|
const elementTypeName = {
|
|
15703
15673
|
[DataType.OBSTACLE]: '障碍物',
|
|
@@ -15712,8 +15682,6 @@ const useCheckElement = () => {
|
|
|
15712
15682
|
};
|
|
15713
15683
|
}
|
|
15714
15684
|
}
|
|
15715
|
-
// 所有检查通过
|
|
15716
|
-
console.log('Doodle 位置检查通过');
|
|
15717
15685
|
return { isValid: true };
|
|
15718
15686
|
}, [editMapInfo, svgElementDatas, minDistance]);
|
|
15719
15687
|
const checkCanNotCreateAtPosition = useCallback((checkPoint, checkPoints) => {
|
|
@@ -15734,7 +15702,6 @@ const useCheckElement = () => {
|
|
|
15734
15702
|
break;
|
|
15735
15703
|
}
|
|
15736
15704
|
}
|
|
15737
|
-
console.log('currentBoundary--->', currentBoundary, points);
|
|
15738
15705
|
if (!currentBoundary)
|
|
15739
15706
|
return {
|
|
15740
15707
|
result: true,
|
|
@@ -15769,7 +15736,6 @@ const useCheckElement = () => {
|
|
|
15769
15736
|
for (const obstacle of obstaclesInBoundary) {
|
|
15770
15737
|
const obstaclePoints = coordinatesToPoints$1(obstacle.points);
|
|
15771
15738
|
if (doPolygonsIntersect(currentObstaclePolygon, obstaclePoints)) {
|
|
15772
|
-
console.log('Obstacle intersection detected with:', obstacle);
|
|
15773
15739
|
return {
|
|
15774
15740
|
result: true,
|
|
15775
15741
|
code: CheckObstaclePointErrorType.OBSTACLE_INTERSECT,
|
|
@@ -15788,7 +15754,6 @@ const useCheckElement = () => {
|
|
|
15788
15754
|
const doodleTransformedPoints = transformSvgElements(doodle).flat();
|
|
15789
15755
|
// 检查相交
|
|
15790
15756
|
if (doPolygonsIntersect(currentObstaclePolygon, doodleTransformedPoints)) {
|
|
15791
|
-
console.log('Obstacle-Doodle intersection detected with:', doodle);
|
|
15792
15757
|
return {
|
|
15793
15758
|
result: true,
|
|
15794
15759
|
code: CheckObstaclePointErrorType.DOODLE_INTERSECT,
|
|
@@ -15796,9 +15761,7 @@ const useCheckElement = () => {
|
|
|
15796
15761
|
}
|
|
15797
15762
|
// 检查距离
|
|
15798
15763
|
const distance = polygonToPolygonDistance(currentObstaclePolygon, doodleTransformedPoints);
|
|
15799
|
-
console.log('Obstacle-Doodle distance too close:', distance, 'required:', minDistance);
|
|
15800
15764
|
if (distance < minDistance) {
|
|
15801
|
-
console.log('Obstacle-Doodle distance too close:', distance, 'required:', minDistance);
|
|
15802
15765
|
return {
|
|
15803
15766
|
result: true,
|
|
15804
15767
|
code: CheckObstaclePointErrorType.DOODLE_DISTANCE_TOO_CLOSE,
|
|
@@ -16453,11 +16416,26 @@ const PolygonElement = ({ points, fillColor = 'rgba(0, 0, 0, 0.1)', fillOpacity
|
|
|
16453
16416
|
return (jsxs(Fragment, { children: [(editMode || (createMode && completed)) &&
|
|
16454
16417
|
dragState.isDragging &&
|
|
16455
16418
|
dragState.dragType !== 'new' &&
|
|
16456
|
-
dragState.originalPosition && (jsxs(Fragment, { children: [jsx(VertexElement, { cx: dragState.originalPosition[0], cy: dragState.originalPosition[1], stroke: strokeColor, strokeOpacity: 0.2, pointerEvents: "none"
|
|
16419
|
+
dragState.originalPosition && (jsxs(Fragment, { children: [jsx(VertexElement, { cx: dragState.originalPosition[0], cy: dragState.originalPosition[1], stroke: strokeColor, strokeOpacity: 0.2, pointerEvents: "none", style: {
|
|
16420
|
+
userSelect: 'none',
|
|
16421
|
+
WebkitUserSelect: 'none',
|
|
16422
|
+
WebkitTouchCallout: 'none',
|
|
16423
|
+
touchAction: 'none',
|
|
16424
|
+
} }, "ghost-vertex"), (() => {
|
|
16457
16425
|
// 获取前一个点和后一个点的索引
|
|
16458
16426
|
const prevIndex = (dragState.dragIndex - 1 + coordinates.length) % coordinates.length;
|
|
16459
16427
|
const nextIndex = (dragState.dragIndex + 1) % coordinates.length;
|
|
16460
|
-
return (jsxs(Fragment, { children: [jsx("line", { x1: coordinates[prevIndex][0], y1: coordinates[prevIndex][1], x2: dragState.originalPosition[0], y2: dragState.originalPosition[1], stroke: strokeColor, strokeWidth: strokeWidth, strokeOpacity: 0.5, strokeDasharray: "5,5", pointerEvents: "none"
|
|
16428
|
+
return (jsxs(Fragment, { children: [jsx("line", { x1: coordinates[prevIndex][0], y1: coordinates[prevIndex][1], x2: dragState.originalPosition[0], y2: dragState.originalPosition[1], stroke: strokeColor, strokeWidth: strokeWidth, strokeOpacity: 0.5, strokeDasharray: "5,5", pointerEvents: "none", style: {
|
|
16429
|
+
userSelect: 'none',
|
|
16430
|
+
WebkitUserSelect: 'none',
|
|
16431
|
+
WebkitTouchCallout: 'none',
|
|
16432
|
+
touchAction: 'none',
|
|
16433
|
+
} }), jsx("line", { x1: dragState.originalPosition[0], y1: dragState.originalPosition[1], x2: coordinates[nextIndex][0], y2: coordinates[nextIndex][1], stroke: strokeColor, strokeWidth: strokeWidth, strokeOpacity: 0.5, strokeDasharray: "5,5", pointerEvents: "none", style: {
|
|
16434
|
+
userSelect: 'none',
|
|
16435
|
+
WebkitUserSelect: 'none',
|
|
16436
|
+
WebkitTouchCallout: 'none',
|
|
16437
|
+
touchAction: 'none',
|
|
16438
|
+
} })] }));
|
|
16461
16439
|
})()] })), renderCoordinates.length >= 3 && (jsx("polygon", { className: editMapInfo?.createMode === CreateStatus.CREATING ? '' : styles$5.polygonPathG, points: polygonPoints, fill: fillColor, fillOpacity: fillOpacity, stroke: "none" // 边框透明
|
|
16462
16440
|
, onClick: onPolygonClick })), jsxs("g", { className: styles$5.polygonPathG, children: [renderCoordinates.length >= 2 &&
|
|
16463
16441
|
pathSegments.map((segment, index) => {
|
|
@@ -16465,7 +16443,12 @@ const PolygonElement = ({ points, fillColor = 'rgba(0, 0, 0, 0.1)', fillOpacity
|
|
|
16465
16443
|
return null;
|
|
16466
16444
|
const pathData = createPathData(segment.points);
|
|
16467
16445
|
const isDash = segment.type === 1;
|
|
16468
|
-
return (jsx("path", { d: pathData, fill: "none", stroke: isDash ? 'none' : strokeColor, strokeWidth: strokeWidth, strokeOpacity: strokeOpacity, strokeLinecap: "round", strokeLinejoin: "round", className: styles$5.polygonPath, vectorEffect: "non-scaling-stroke", onClick: onPathClick
|
|
16446
|
+
return (jsx("path", { d: pathData, fill: "none", stroke: isDash ? 'none' : strokeColor, strokeWidth: strokeWidth, strokeOpacity: strokeOpacity, strokeLinecap: "round", strokeLinejoin: "round", className: styles$5.polygonPath, vectorEffect: "non-scaling-stroke", onClick: onPathClick, style: {
|
|
16447
|
+
userSelect: 'none',
|
|
16448
|
+
WebkitUserSelect: 'none',
|
|
16449
|
+
WebkitTouchCallout: 'none',
|
|
16450
|
+
touchAction: 'none',
|
|
16451
|
+
} }, index));
|
|
16469
16452
|
}), renderCoordinates.length >= 2 &&
|
|
16470
16453
|
dashPaths.map((segment, index) => {
|
|
16471
16454
|
if (segment.points.length < 2)
|
|
@@ -16508,7 +16491,7 @@ const PolygonElement = ({ points, fillColor = 'rgba(0, 0, 0, 0.1)', fillOpacity
|
|
|
16508
16491
|
setHoverVertex(null);
|
|
16509
16492
|
},
|
|
16510
16493
|
}) }, `edge-${index}`));
|
|
16511
|
-
}), ghostLastPath && (jsx("path", { d: ghostLastPath, stroke: strokeColor, strokeWidth: strokeWidth, vectorEffect: "non-scaling-stroke", opacity: 0.7, onClick: onPathClick })), ghostFirstPath && renderCoordinates.length >= 2 && (jsx("path", { d: ghostFirstPath, stroke: strokeColor, strokeWidth: strokeWidth, vectorEffect: "non-scaling-stroke", opacity: 0.7, onClick: onPathClick })), jsx(DragDistanceIndicator, { dragState: dragState, strokeColor: strokeColor, editMode: editMode, createMode: createMode, completed: completed, fontSize: platform === PlatformType.H5 ? 12 * overlayScale : 30 * overlayScale, unitType: unitType }), jsx(DistanceLabels, { coordinates: renderCoordinates, createMode: createMode, editMode: editMode, completed: completed, showPoints: showPoints, mousePos: mousePos, ghostLastDistance: ghostLastDistance, ghostLastMidpoint: ghostLastMidpoint, ghostFirstDistance: ghostFirstDistance, ghostFirstMidpoint: ghostFirstMidpoint, fontSize: platform === PlatformType.H5 ? 12 * overlayScale : 30 * overlayScale, showFirstDistance: platform !== PlatformType.H5, unit: unitType }), hoverVertex && !dragState.isDragging && (jsx(VertexElement, { cx: hoverVertex.position.x, cy: hoverVertex.position.y, stroke: strokeColor, strokeOpacity: 0.6, fill: "white", fillOpacity: 0.8, pointerEvents: "none" })), ((createMode && showPoints) || editMode || (createMode && completed)) &&
|
|
16494
|
+
}), ghostLastPath && (jsx("path", { d: ghostLastPath, stroke: strokeColor, strokeWidth: strokeWidth, vectorEffect: "non-scaling-stroke", opacity: 0.7, onClick: onPathClick })), ghostFirstPath && renderCoordinates.length >= 2 && (jsx("path", { d: ghostFirstPath, stroke: strokeColor, strokeWidth: strokeWidth, vectorEffect: "non-scaling-stroke", opacity: 0.7, onClick: onPathClick })), jsx(DragDistanceIndicator, { dragState: dragState, strokeColor: strokeColor, editMode: editMode, createMode: createMode, completed: completed, fontSize: platform === PlatformType.H5 ? 12 * overlayScale * 1.5 : 30 * overlayScale, unitType: unitType }), jsx(DistanceLabels, { coordinates: renderCoordinates, createMode: createMode, editMode: editMode, completed: completed, showPoints: showPoints, mousePos: mousePos, ghostLastDistance: ghostLastDistance, ghostLastMidpoint: ghostLastMidpoint, ghostFirstDistance: ghostFirstDistance, ghostFirstMidpoint: ghostFirstMidpoint, fontSize: platform === PlatformType.H5 ? 12 * overlayScale * 1.5 : 30 * overlayScale, showFirstDistance: platform !== PlatformType.H5, unit: unitType }), hoverVertex && !dragState.isDragging && (jsx(VertexElement, { cx: hoverVertex.position.x, cy: hoverVertex.position.y, stroke: strokeColor, strokeOpacity: 0.6, fill: "white", fillOpacity: 0.8, pointerEvents: "none" })), ((createMode && showPoints) || editMode || (createMode && completed)) &&
|
|
16512
16495
|
renderCoordinates.map((coord, idx) => {
|
|
16513
16496
|
// 判断当前顶点的状态
|
|
16514
16497
|
const isLastPoint = idx === renderCoordinates.length - 1;
|
|
@@ -16517,7 +16500,8 @@ const PolygonElement = ({ points, fillColor = 'rgba(0, 0, 0, 0.1)', fillOpacity
|
|
|
16517
16500
|
const isInEditMode = editMode;
|
|
16518
16501
|
// H5模式下选中的顶点显示蓝色,并且放大1.5倍
|
|
16519
16502
|
const isSelected = platform === PlatformType.H5 && selectedVertexIndex === idx;
|
|
16520
|
-
const
|
|
16503
|
+
const commonRadius = canComplete ? 16 : 12;
|
|
16504
|
+
const vertexRadius = isSelected ? commonRadius * 1.2 : commonRadius;
|
|
16521
16505
|
const vertexFill = isSelected ? '#FFAB7E' : 'white';
|
|
16522
16506
|
return (jsxs("g", { children: [jsx(VertexElement, { className: generateVertexClassName, style: {
|
|
16523
16507
|
userSelect: 'none',
|
|
@@ -16695,7 +16679,6 @@ const BoundaryElement = ({ data }) => {
|
|
|
16695
16679
|
return (jsx(PolygonElement, { points: currentPoints, fillColor: style.fillColor, fillOpacity: style.fillOpacity, strokeColor: style.lineColor, strokeWidth: strokeWidth, editMode: false, onPathClick: onPathClick, onPolygonClick: () => {
|
|
16696
16680
|
onPathClick();
|
|
16697
16681
|
}, onCoordinatesChange: (coordinates) => {
|
|
16698
|
-
console.log('onCoordinatesChange', coordinates);
|
|
16699
16682
|
setEditMapInfo((prev) => ({
|
|
16700
16683
|
...prev,
|
|
16701
16684
|
selectElement: {
|
|
@@ -16748,7 +16731,6 @@ const useHistoryHandle = (props) => {
|
|
|
16748
16731
|
// undo
|
|
16749
16732
|
const undo = () => {
|
|
16750
16733
|
setEditMapInfo((prev) => {
|
|
16751
|
-
console.log('undo->', prev);
|
|
16752
16734
|
if (prev?.historyList?.length > 0 && prev?.currentHistoryIndex > 0) {
|
|
16753
16735
|
return {
|
|
16754
16736
|
...prev,
|
|
@@ -16816,10 +16798,8 @@ const ObstacleElement = ({ data }) => {
|
|
|
16816
16798
|
const { addHistory } = useHistoryHandle();
|
|
16817
16799
|
// 处理删除顶点
|
|
16818
16800
|
const handleCreateVertexDelete = useCallback((vertexIndex) => {
|
|
16819
|
-
console.log('ObstacleElement删除顶点', vertexIndex);
|
|
16820
16801
|
if (editMapInfo?.selectElement?.points && editMapInfo?.selectElement?.points?.length > 0) {
|
|
16821
16802
|
const newPoints = editMapInfo?.selectElement?.points?.filter((_, index) => index !== vertexIndex);
|
|
16822
|
-
console.log('newPoints', newPoints);
|
|
16823
16803
|
setEditMapInfo((prev) => ({
|
|
16824
16804
|
...prev,
|
|
16825
16805
|
selectElement: {
|
|
@@ -16991,11 +16971,11 @@ const useVisionOffTransform = (data, scaleConstraints
|
|
|
16991
16971
|
return newPoints;
|
|
16992
16972
|
}, []);
|
|
16993
16973
|
// 计算选择框的四个角点(每条边与内部元素对应边平行)
|
|
16994
|
-
const calculateSelectionBoxPoints = useCallback((points) => {
|
|
16974
|
+
const calculateSelectionBoxPoints = useCallback((points, scale = 1) => {
|
|
16995
16975
|
if (points.length < 4)
|
|
16996
16976
|
return points;
|
|
16997
16977
|
// 设置偏移距离(可以根据需要调整)
|
|
16998
|
-
const offset =
|
|
16978
|
+
const offset = 20 * scale; // 偏移距离
|
|
16999
16979
|
// 使用更简单的方法:计算矩形的边界框,然后向外扩展
|
|
17000
16980
|
// 计算矩形的两条相邻边向量(从左上角出发)
|
|
17001
16981
|
const edge1 = { x: points[1].x - points[0].x, y: points[1].y - points[0].y }; // 左上到左下
|
|
@@ -17312,9 +17292,9 @@ const useVisionOffTransform = (data, scaleConstraints
|
|
|
17312
17292
|
};
|
|
17313
17293
|
|
|
17314
17294
|
var _g$5, _defs$5;
|
|
17315
|
-
function _extends$
|
|
17295
|
+
function _extends$9() { return _extends$9 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$9.apply(null, arguments); }
|
|
17316
17296
|
var SvgTransformDelete = function SvgTransformDelete(props) {
|
|
17317
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
|
17297
|
+
return /*#__PURE__*/React.createElement("svg", _extends$9({
|
|
17318
17298
|
xmlns: "http://www.w3.org/2000/svg",
|
|
17319
17299
|
width: 20,
|
|
17320
17300
|
height: 20,
|
|
@@ -17363,9 +17343,9 @@ var SvgTransformDelete = function SvgTransformDelete(props) {
|
|
|
17363
17343
|
};
|
|
17364
17344
|
|
|
17365
17345
|
var _g$4, _defs$4;
|
|
17366
|
-
function _extends$
|
|
17346
|
+
function _extends$8() { return _extends$8 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$8.apply(null, arguments); }
|
|
17367
17347
|
var SvgTransformRotate = function SvgTransformRotate(props) {
|
|
17368
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
|
17348
|
+
return /*#__PURE__*/React.createElement("svg", _extends$8({
|
|
17369
17349
|
xmlns: "http://www.w3.org/2000/svg",
|
|
17370
17350
|
width: 21,
|
|
17371
17351
|
height: 20,
|
|
@@ -17399,9 +17379,9 @@ var SvgTransformRotate = function SvgTransformRotate(props) {
|
|
|
17399
17379
|
};
|
|
17400
17380
|
|
|
17401
17381
|
var _g$3, _defs$3;
|
|
17402
|
-
function _extends$
|
|
17382
|
+
function _extends$7() { return _extends$7 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$7.apply(null, arguments); }
|
|
17403
17383
|
var SvgTransformScale = function SvgTransformScale(props) {
|
|
17404
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
|
17384
|
+
return /*#__PURE__*/React.createElement("svg", _extends$7({
|
|
17405
17385
|
xmlns: "http://www.w3.org/2000/svg",
|
|
17406
17386
|
width: 21,
|
|
17407
17387
|
height: 20,
|
|
@@ -17435,9 +17415,9 @@ var SvgTransformScale = function SvgTransformScale(props) {
|
|
|
17435
17415
|
};
|
|
17436
17416
|
|
|
17437
17417
|
var _g$2, _defs$2;
|
|
17438
|
-
function _extends$
|
|
17418
|
+
function _extends$6() { return _extends$6 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$6.apply(null, arguments); }
|
|
17439
17419
|
var SvgTransformTranslate = function SvgTransformTranslate(props) {
|
|
17440
|
-
return /*#__PURE__*/React.createElement("svg", _extends$
|
|
17420
|
+
return /*#__PURE__*/React.createElement("svg", _extends$6({
|
|
17441
17421
|
xmlns: "http://www.w3.org/2000/svg",
|
|
17442
17422
|
width: 20,
|
|
17443
17423
|
height: 20,
|
|
@@ -17604,7 +17584,7 @@ const VisionOffTransformWrapper = ({ data, isSelected = false, onSelect, onCance
|
|
|
17604
17584
|
}) })), isSelected &&
|
|
17605
17585
|
currentPoints.length === 4 &&
|
|
17606
17586
|
(() => {
|
|
17607
|
-
const selectionBoxPoints = calculateSelectionBoxPoints(currentPoints);
|
|
17587
|
+
const selectionBoxPoints = calculateSelectionBoxPoints(currentPoints, overlayScale);
|
|
17608
17588
|
// 计算选择框的边界
|
|
17609
17589
|
const minX = Math.min(...selectionBoxPoints.map((p) => p.x));
|
|
17610
17590
|
const maxX = Math.max(...selectionBoxPoints.map((p) => p.x));
|
|
@@ -17612,13 +17592,23 @@ const VisionOffTransformWrapper = ({ data, isSelected = false, onSelect, onCance
|
|
|
17612
17592
|
// 计算选择框的中心
|
|
17613
17593
|
const centerX = (minX + maxX) / 2;
|
|
17614
17594
|
// 计算尺寸显示框的位置(选择框下方)
|
|
17615
|
-
const infoBoxY = maxY + 20; // 选择框下方20像素
|
|
17616
|
-
const infoBoxWidth =
|
|
17617
|
-
const infoBoxHeight =
|
|
17595
|
+
const infoBoxY = maxY + 20 + 40 * overlayScale; // 选择框下方20像素
|
|
17596
|
+
const infoBoxWidth = 300 * overlayScale; // 信息框宽度
|
|
17597
|
+
const infoBoxHeight = 50 * overlayScale; // 信息框高度
|
|
17618
17598
|
const infoBoxX = centerX - infoBoxWidth / 2; // 居中对齐
|
|
17619
|
-
const scale =
|
|
17599
|
+
const scale = 2 * overlayScale;
|
|
17620
17600
|
const offsetLeft = 10 * scale;
|
|
17621
|
-
return (jsxs(Fragment, { children: [jsx("
|
|
17601
|
+
return (jsxs(Fragment, { children: [showInfo && (jsx("foreignObject", { x: infoBoxX, y: infoBoxY, width: infoBoxWidth, height: infoBoxHeight, style: { textAlign: 'center' }, children: jsxs("div", { style: {
|
|
17602
|
+
padding: `5px ${10 * overlayScale}px`,
|
|
17603
|
+
background: 'linear-gradient(266.64deg, #F26A2A 4.1%, #F2942A 86.42%)',
|
|
17604
|
+
borderRadius: `${30 * overlayScale}px`,
|
|
17605
|
+
display: 'inline-flex',
|
|
17606
|
+
alignItems: 'center',
|
|
17607
|
+
justifyContent: 'center',
|
|
17608
|
+
fontSize: `${26 * overlayScale}px`,
|
|
17609
|
+
color: 'white',
|
|
17610
|
+
fontWeight: '400',
|
|
17611
|
+
}, children: [convertDistanceByUnits(dimensions.height, unitType).value, " \u00D7", ' ', convertDistanceByUnits(dimensions.width, unitType).value] }) })), jsx("polygon", { points: selectionBoxPoints.map((point) => `${point.x},${point.y}`).join(' '), fill: "none", stroke: "#9EA6BA", strokeWidth: "2", strokeDasharray: "5,5", vectorEffect: "non-scaling-stroke", style: { cursor: 'move' }, ...(platform === PlatformType.H5
|
|
17622
17612
|
? {
|
|
17623
17613
|
onTouchStart: createReactEventHandler((e) => {
|
|
17624
17614
|
handleMouseDownWithDisabled(e);
|
|
@@ -17658,18 +17648,7 @@ const VisionOffTransformWrapper = ({ data, isSelected = false, onSelect, onCance
|
|
|
17658
17648
|
}
|
|
17659
17649
|
: {
|
|
17660
17650
|
onMouseDown: handleScaleStartWithDisabled,
|
|
17661
|
-
}), transform: `translate(${selectionBoxPoints[2].x}, ${selectionBoxPoints[2].y})`, children: jsx("g", { style: { cursor: 'pointer' }, transformOrigin: "center", transform: `translate(-${offsetLeft}, -${offsetLeft}) scale(${scale})`, children: jsx(SvgTransformScale, {}) }) })
|
|
17662
|
-
padding: '5px 6px',
|
|
17663
|
-
background: 'linear-gradient(266.64deg, #F26A2A 4.1%, #F2942A 86.42%)',
|
|
17664
|
-
borderRadius: '20px',
|
|
17665
|
-
display: 'inline-flex',
|
|
17666
|
-
alignItems: 'center',
|
|
17667
|
-
justifyContent: 'center',
|
|
17668
|
-
fontSize: '12px',
|
|
17669
|
-
color: 'white',
|
|
17670
|
-
fontWeight: '400',
|
|
17671
|
-
// transform: `translate(0, ${50 * overlayScale}px) scale(${overlayScale})`,
|
|
17672
|
-
}, children: [convertDistanceByUnits(dimensions.height, unitType).value, " \u00D7", ' ', convertDistanceByUnits(dimensions.width, unitType).value] }) }))] }));
|
|
17651
|
+
}), transform: `translate(${selectionBoxPoints[2].x}, ${selectionBoxPoints[2].y})`, children: jsx("g", { style: { cursor: 'pointer' }, transformOrigin: "center", transform: `translate(-${offsetLeft}, -${offsetLeft}) scale(${scale})`, children: jsx(SvgTransformScale, {}) }) })] }));
|
|
17673
17652
|
})()] }));
|
|
17674
17653
|
};
|
|
17675
17654
|
|
|
@@ -17899,11 +17878,6 @@ const useDoodleTransform = (data, onTransformChange, options) => {
|
|
|
17899
17878
|
}, [currentCenter, currentScale, currentDirection, getSvgDimensions]);
|
|
17900
17879
|
// 初始化变换状态
|
|
17901
17880
|
const initializeTransform = useCallback(() => {
|
|
17902
|
-
console.log('useDoodleTransform: 初始化变换状态', {
|
|
17903
|
-
center: data.center,
|
|
17904
|
-
scale: data.scale,
|
|
17905
|
-
direction: data.direction,
|
|
17906
|
-
});
|
|
17907
17881
|
const convertedCenter = convertPoint(data.center);
|
|
17908
17882
|
setCurrentCenter({ x: convertedCenter[0], y: convertedCenter[1] });
|
|
17909
17883
|
setCurrentScale(data.scale);
|
|
@@ -18130,21 +18104,6 @@ const useDoodleTransform = (data, onTransformChange, options) => {
|
|
|
18130
18104
|
};
|
|
18131
18105
|
};
|
|
18132
18106
|
|
|
18133
|
-
var _path$4;
|
|
18134
|
-
function _extends$6() { return _extends$6 = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends$6.apply(null, arguments); }
|
|
18135
|
-
var SvgTransformArrow = function SvgTransformArrow(props) {
|
|
18136
|
-
return /*#__PURE__*/React.createElement("svg", _extends$6({
|
|
18137
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
18138
|
-
width: 7,
|
|
18139
|
-
height: 11,
|
|
18140
|
-
fill: "none"
|
|
18141
|
-
}, props), _path$4 || (_path$4 = /*#__PURE__*/React.createElement("path", {
|
|
18142
|
-
fill: "#fff",
|
|
18143
|
-
d: "M2.156 1.032a.777.777 0 0 0-1.061 0 .69.69 0 0 0-.062.943l.062.068 3.97 3.78-3.97 3.78a.69.69 0 0 0-.062.944l.062.067c.27.257.696.277.99.06l.07-.06 4.5-4.286a.69.69 0 0 0 .063-.943l-.062-.067z",
|
|
18144
|
-
opacity: 0.5
|
|
18145
|
-
})));
|
|
18146
|
-
};
|
|
18147
|
-
|
|
18148
18107
|
const DoodleTransform = ({ data, isSelected: _isSelected, onSelect }) => {
|
|
18149
18108
|
const { editMapInfo } = useMapEditContext();
|
|
18150
18109
|
const { platform } = useCommonContext();
|
|
@@ -18322,10 +18281,9 @@ const DoodleTransformWrapper = ({ data, isSelected = false, isSelectedWithoutOpe
|
|
|
18322
18281
|
const maxY = Math.max(...selectionBoxPoints.map((p) => p.y));
|
|
18323
18282
|
// 计算选择框的中心
|
|
18324
18283
|
const centerX = (minX + maxX) / 2;
|
|
18325
|
-
//
|
|
18326
|
-
const
|
|
18327
|
-
const
|
|
18328
|
-
const infoBoxHeight = 100 * overlayScale; // 信息框高度
|
|
18284
|
+
const infoBoxY = maxY + 20 + 30 * overlayScale; // 选择框下方20像素
|
|
18285
|
+
const infoBoxWidth = 300 * overlayScale; // 信息框宽度
|
|
18286
|
+
const infoBoxHeight = 40 * overlayScale; // 信息框高度
|
|
18329
18287
|
const infoBoxX = centerX - infoBoxWidth / 2; // 居中对齐
|
|
18330
18288
|
return (jsxs(Fragment, { children: [jsx("polygon", { points: selectionBoxPoints.map((point) => `${point.x},${point.y}`).join(' '), fill: "none", stroke: "#B2B4B9", strokeWidth: "2", strokeDasharray: "5,5", vectorEffect: "non-scaling-stroke", style: { cursor: 'move' }, ...(platform === PlatformType.H5
|
|
18331
18289
|
? {
|
|
@@ -18338,14 +18296,14 @@ const DoodleTransformWrapper = ({ data, isSelected = false, isSelectedWithoutOpe
|
|
|
18338
18296
|
}) }), jsx("circle", { cx: selectionBoxPoints[0].x, cy: selectionBoxPoints[0].y, r: 10 * overlayScale, fill: "#B2B4B9", stroke: "none" }), jsx("circle", { cx: selectionBoxPoints[3].x, cy: selectionBoxPoints[3].y, r: 10 * overlayScale, fill: "#B2B4B9", stroke: "none" }), jsx("circle", { cx: selectionBoxPoints[1].x, cy: selectionBoxPoints[1].y, r: 10 * overlayScale, fill: "#B2B4B9", stroke: "none" }), jsx("circle", { cx: selectionBoxPoints[2].x, cy: selectionBoxPoints[2].y, r: 10 * overlayScale, fill: "#B2B4B9", stroke: "none" }), platform === PlatformType.H5 && (jsx("foreignObject", { x: infoBoxX, y: infoBoxY, width: infoBoxWidth, height: infoBoxHeight, style: { textAlign: 'center' }, onClick: () => {
|
|
18339
18297
|
onClickInfo?.();
|
|
18340
18298
|
}, children: jsx("div", { style: {
|
|
18341
|
-
padding:
|
|
18299
|
+
padding: `5px ${10 * overlayScale}px`,
|
|
18342
18300
|
background: 'rgba(201, 209, 218, 1)',
|
|
18343
|
-
borderRadius:
|
|
18301
|
+
borderRadius: `${10 * overlayScale}px`,
|
|
18344
18302
|
display: 'inline-flex',
|
|
18345
18303
|
flexDirection: 'column',
|
|
18346
18304
|
alignItems: 'flex-start',
|
|
18347
18305
|
justifyContent: 'center',
|
|
18348
|
-
fontSize:
|
|
18306
|
+
fontSize: `${26 * overlayScale}px`,
|
|
18349
18307
|
color: 'white',
|
|
18350
18308
|
fontWeight: '400',
|
|
18351
18309
|
// transform: `translate(0, ${50 * overlayScale}px) scale(${overlayScale})`,
|
|
@@ -18403,14 +18361,32 @@ const DoodleTransformWrapper = ({ data, isSelected = false, isSelectedWithoutOpe
|
|
|
18403
18361
|
const maxY = Math.max(...selectionBoxPoints.map((p) => p.y));
|
|
18404
18362
|
// 计算选择框的中心
|
|
18405
18363
|
const centerX = (minX + maxX) / 2;
|
|
18406
|
-
//
|
|
18407
|
-
const
|
|
18408
|
-
const infoBoxWidth = 140 * overlayScale; // 信息框宽度
|
|
18364
|
+
const infoBoxY = maxY + 20 + 40 * overlayScale; // 选择框下方20像素
|
|
18365
|
+
const infoBoxWidth = 300 * overlayScale; // 信息框宽度
|
|
18409
18366
|
const infoBoxHeight = 100 * overlayScale; // 信息框高度
|
|
18410
18367
|
const infoBoxX = centerX - infoBoxWidth / 2; // 居中对齐
|
|
18411
|
-
const scale =
|
|
18368
|
+
const scale = 2 * overlayScale;
|
|
18412
18369
|
const offsetLeft = 10 * scale;
|
|
18413
|
-
return (jsxs(Fragment, { children: [jsx("
|
|
18370
|
+
return (jsxs(Fragment, { children: [showInfo && (jsx("foreignObject", { x: infoBoxX, y: infoBoxY, width: infoBoxWidth, height: infoBoxHeight, style: { textAlign: 'center' }, onClick: () => {
|
|
18371
|
+
onClickInfo?.();
|
|
18372
|
+
}, children: jsxs("div", { style: {
|
|
18373
|
+
padding: `${10 * overlayScale}px`,
|
|
18374
|
+
background: 'linear-gradient(266.64deg, #F26A2A 4.1%, #F2942A 86.42%)',
|
|
18375
|
+
borderRadius: `${20 * overlayScale}px`,
|
|
18376
|
+
display: 'inline-flex',
|
|
18377
|
+
flexDirection: 'column',
|
|
18378
|
+
alignItems: 'flex-start',
|
|
18379
|
+
justifyContent: 'center',
|
|
18380
|
+
fontSize: `${26 * overlayScale}px`,
|
|
18381
|
+
color: 'white',
|
|
18382
|
+
fontWeight: '400',
|
|
18383
|
+
// transform: `translate(0, ${50 * overlayScale}px) scale(${overlayScale})`,
|
|
18384
|
+
}, children: [jsxs("div", { children: [convertDistanceByUnits(dimensions.width, unitType).value, " \u00D7", ' ', convertDistanceByUnits(dimensions.height, unitType).value] }), jsx("div", { style: {
|
|
18385
|
+
display: 'flex',
|
|
18386
|
+
alignItems: 'center',
|
|
18387
|
+
justifyContent: 'center',
|
|
18388
|
+
gap: `${10 * overlayScale}px`,
|
|
18389
|
+
}, children: jsxs("div", { children: ["Active Time: ", activeTime, " >"] }) })] }) })), jsx("polygon", { points: selectionBoxPoints.map((point) => `${point.x},${point.y}`).join(' '), fill: "none", stroke: "#9EA6BA", strokeWidth: "2", strokeDasharray: "5,5", vectorEffect: "non-scaling-stroke", style: { cursor: 'move' }, ...(platform === PlatformType.H5
|
|
18414
18390
|
? {
|
|
18415
18391
|
onTouchStart: createReactEventHandler((e) => {
|
|
18416
18392
|
handleMouseDownWithDisabled(e);
|
|
@@ -18450,26 +18426,7 @@ const DoodleTransformWrapper = ({ data, isSelected = false, isSelectedWithoutOpe
|
|
|
18450
18426
|
}
|
|
18451
18427
|
: {
|
|
18452
18428
|
onMouseDown: handleScaleStartWithDisabled,
|
|
18453
|
-
}), transform: `translate(${selectionBoxPoints[2].x}, ${selectionBoxPoints[2].y})`, children: jsx("g", { style: { cursor: 'pointer' }, transformOrigin: "center", transform: `translate(-${offsetLeft}, -${offsetLeft}) scale(${scale})`, children: jsx(SvgTransformScale, {}) }) })
|
|
18454
|
-
onClickInfo?.();
|
|
18455
|
-
}, children: jsxs("div", { style: {
|
|
18456
|
-
padding: '5px 6px',
|
|
18457
|
-
background: 'linear-gradient(266.64deg, #F26A2A 4.1%, #F2942A 86.42%)',
|
|
18458
|
-
borderRadius: '10px',
|
|
18459
|
-
display: 'inline-flex',
|
|
18460
|
-
flexDirection: 'column',
|
|
18461
|
-
alignItems: 'flex-start',
|
|
18462
|
-
justifyContent: 'center',
|
|
18463
|
-
fontSize: '12px',
|
|
18464
|
-
color: 'white',
|
|
18465
|
-
fontWeight: '400',
|
|
18466
|
-
// transform: `translate(0, ${50 * overlayScale}px) scale(${overlayScale})`,
|
|
18467
|
-
}, children: [jsxs("div", { children: [convertDistanceByUnits(dimensions.width, unitType).value, " \u00D7", ' ', convertDistanceByUnits(dimensions.height, unitType).value] }), jsxs("div", { style: {
|
|
18468
|
-
display: 'flex',
|
|
18469
|
-
alignItems: 'center',
|
|
18470
|
-
justifyContent: 'center',
|
|
18471
|
-
gap: '10px',
|
|
18472
|
-
}, children: [jsxs("div", { children: ["Active Time: ", activeTime] }), jsx(SvgTransformArrow, {})] })] }) }))] }));
|
|
18429
|
+
}), transform: `translate(${selectionBoxPoints[2].x}, ${selectionBoxPoints[2].y})`, children: jsx("g", { style: { cursor: 'pointer' }, transformOrigin: "center", transform: `translate(-${offsetLeft}, -${offsetLeft}) scale(${scale})`, children: jsx(SvgTransformScale, {}) }) })] }));
|
|
18473
18430
|
})()] }));
|
|
18474
18431
|
};
|
|
18475
18432
|
|
|
@@ -19695,7 +19652,6 @@ function usePolygonDrawing(options = {}) {
|
|
|
19695
19652
|
},
|
|
19696
19653
|
};
|
|
19697
19654
|
});
|
|
19698
|
-
console.log('onSvgClick');
|
|
19699
19655
|
addHistory({
|
|
19700
19656
|
selectElement: {
|
|
19701
19657
|
...editMapInfo.selectElement,
|
|
@@ -19737,7 +19693,6 @@ function usePolygonDrawing(options = {}) {
|
|
|
19737
19693
|
},
|
|
19738
19694
|
};
|
|
19739
19695
|
});
|
|
19740
|
-
console.log('updatePoints');
|
|
19741
19696
|
addHistory({
|
|
19742
19697
|
selectElement: {
|
|
19743
19698
|
...editMapInfo.selectElement,
|
|
@@ -19785,11 +19740,6 @@ const isPointInSvgBounds = (point, svgElement) => {
|
|
|
19785
19740
|
const maxY = minY + height;
|
|
19786
19741
|
// 检查点是否在viewBox范围内
|
|
19787
19742
|
const isInBounds = point.x >= minX && point.x <= maxX && point.y >= minY && point.y <= maxY;
|
|
19788
|
-
console.log('点边界检查:', {
|
|
19789
|
-
point: { x: point.x, y: point.y },
|
|
19790
|
-
viewBox: { minX, minY, maxX, maxY },
|
|
19791
|
-
isInBounds,
|
|
19792
|
-
});
|
|
19793
19743
|
return isInBounds;
|
|
19794
19744
|
}
|
|
19795
19745
|
catch (error) {
|
|
@@ -19816,8 +19766,6 @@ const getScreenCenterSvgPoint = (svgElement, mapInstance) => {
|
|
|
19816
19766
|
// 计算Google Maps容器的中心点
|
|
19817
19767
|
const centerX = mapRect.left + mapRect.width / 2;
|
|
19818
19768
|
const centerY = mapRect.top + mapRect.height / 2;
|
|
19819
|
-
console.log('Google Maps容器中心位置:', { centerX, centerY });
|
|
19820
|
-
console.log('Google Maps容器尺寸:', { width: mapRect.width, height: mapRect.height });
|
|
19821
19769
|
// 直接使用SVG的CTM进行坐标转换
|
|
19822
19770
|
const pt = svgElement.createSVGPoint();
|
|
19823
19771
|
pt.x = centerX;
|
|
@@ -19829,7 +19777,6 @@ const getScreenCenterSvgPoint = (svgElement, mapInstance) => {
|
|
|
19829
19777
|
}
|
|
19830
19778
|
const inv = ctm.inverse();
|
|
19831
19779
|
const svgPoint = pt.matrixTransform(inv);
|
|
19832
|
-
console.log('转换后的SVG坐标:', { x: svgPoint.x, y: svgPoint.y });
|
|
19833
19780
|
// 检查点是否在SVG可见区域内
|
|
19834
19781
|
const point = { x: svgPoint.x, y: svgPoint.y };
|
|
19835
19782
|
if (!isPointInSvgBounds(point, svgElement)) {
|
|
@@ -19934,31 +19881,27 @@ CreateObstacleElement.displayName = 'CreateObstacleElement';
|
|
|
19934
19881
|
|
|
19935
19882
|
const MIN_ELEMENT_WIDTH = 50;
|
|
19936
19883
|
const useCreateVisionOffElement = () => {
|
|
19937
|
-
const { svgRef } = useSvgEditContext();
|
|
19938
19884
|
const { editMapInfo } = useMapEditContext();
|
|
19885
|
+
const { svgViewBox } = useCommonContext();
|
|
19939
19886
|
const centerPoint = useMemo(() => {
|
|
19940
|
-
if (!
|
|
19887
|
+
if (!svgViewBox)
|
|
19941
19888
|
return null;
|
|
19942
|
-
const
|
|
19943
|
-
const center = [
|
|
19944
|
-
baseVal?.x + (baseVal?.width || 0) / 2,
|
|
19945
|
-
baseVal?.y + (baseVal?.height || 0) / 2,
|
|
19946
|
-
];
|
|
19889
|
+
const center = [svgViewBox.x + svgViewBox.width / 2, -svgViewBox.y - svgViewBox.height / 2];
|
|
19947
19890
|
return center;
|
|
19948
|
-
}, [
|
|
19891
|
+
}, [svgViewBox]);
|
|
19949
19892
|
const elementWidth = useMemo(() => {
|
|
19950
|
-
if (!
|
|
19893
|
+
if (!svgViewBox)
|
|
19951
19894
|
return MIN_ELEMENT_WIDTH;
|
|
19952
|
-
const baseVal =
|
|
19953
|
-
if (baseVal && baseVal /
|
|
19954
|
-
return baseVal /
|
|
19895
|
+
const baseVal = Math.min(svgViewBox.width, svgViewBox.height);
|
|
19896
|
+
if (baseVal && baseVal / 4 > MIN_ELEMENT_WIDTH) {
|
|
19897
|
+
return baseVal / 4;
|
|
19955
19898
|
}
|
|
19956
19899
|
return MIN_ELEMENT_WIDTH;
|
|
19957
|
-
}, [
|
|
19900
|
+
}, [svgViewBox]);
|
|
19958
19901
|
const getVisionOffPoints = useCallback(() => {
|
|
19959
|
-
if (!
|
|
19902
|
+
if (!svgViewBox)
|
|
19960
19903
|
return null;
|
|
19961
|
-
const offset = ((
|
|
19904
|
+
const offset = (Math.random() - 0.5) * elementWidth;
|
|
19962
19905
|
const [minX, minY, maxX, maxY] = [
|
|
19963
19906
|
centerPoint[0] - elementWidth / 2 + offset,
|
|
19964
19907
|
centerPoint[1] - elementWidth / 2 + offset,
|
|
@@ -20019,7 +19962,7 @@ const SvgEditMap = forwardRef(({ mapJson, mapConfig, editMap, onEditInfoMapChang
|
|
|
20019
19962
|
}, [centerPoint]);
|
|
20020
19963
|
// 调整SVG大小的函数
|
|
20021
19964
|
const adjustSvgSize = (layoutData) => {
|
|
20022
|
-
const padding =
|
|
19965
|
+
const padding = 0; // 添加一些边距以避免内容贴边
|
|
20023
19966
|
const boundWidth = bounds.maxX - bounds.minX + padding * 2;
|
|
20024
19967
|
const boundHeight = bounds.maxY - bounds.minY + padding * 2;
|
|
20025
19968
|
// 防止宽高为0的情况
|
|
@@ -20235,6 +20178,7 @@ const SvgEditMap = forwardRef(({ mapJson, mapConfig, editMap, onEditInfoMapChang
|
|
|
20235
20178
|
left: '50%',
|
|
20236
20179
|
top: '50%',
|
|
20237
20180
|
transform: 'translate(-50%, -50%)',
|
|
20181
|
+
overflow: 'visible',
|
|
20238
20182
|
// cursor: createMode ? 'crosshair' : editMode ? 'default' : 'move',
|
|
20239
20183
|
// pointerEvents: 'auto', // 关键:允许接收鼠标事件
|
|
20240
20184
|
}, xmlns: "http://www.w3.org/2000/svg", "shape-rendering": "geometricPrecision", "text-rendering": "geometricPrecision", "image-rendering": "optimizeQuality", ref: svgRef, onClick: editMapInfo.createMode && platform !== PlatformType.H5 ? onSvgClick : undefined, onMouseMove: editMapInfo.createMode && platform !== PlatformType.H5 ? onSvgMouseMove : undefined, children: [jsxs("defs", { children: [jsx("filter", { id: "vertex-tooltip-shadow", x: "-50%", y: "-50%", width: "200%", height: "200%", children: jsx("feDropShadow", { dx: "2", dy: "2", stdDeviation: "2", floodColor: "#000", floodOpacity: "0.12" }) }), jsxs("filter", { id: `path-hover-${DataType.BOUNDARY}`, x: "-10%", y: "-10%", width: "120%", height: "120%", children: [jsx("feMorphology", { operator: "dilate", radius: "1", in: "SourceGraphic", result: "border" }), jsx("feFlood", { floodColor: BOUNDARY_STYLES.lineColor, floodOpacity: "1", result: "borderColor" }), jsx("feComposite", { in: "borderColor", in2: "border", operator: "in", result: "coloredBorder" }), jsxs("feMerge", { children: [jsx("feMergeNode", { in: "coloredBorder" }), jsx("feMergeNode", { in: "SourceGraphic" })] })] }), jsxs("filter", { id: `path-hover-${DataType.VISION_OFF}`, x: "-10%", y: "-10%", width: "120%", height: "120%", children: [jsx("feMorphology", { operator: "dilate", radius: "1", in: "SourceGraphic", result: "border" }), jsx("feFlood", { floodColor: VISION_OFF_AREA_STYLES.lineColor, floodOpacity: "1", result: "borderColor" }), jsx("feComposite", { in: "borderColor", in2: "border", operator: "in", result: "coloredBorder" }), jsxs("feMerge", { children: [jsx("feMergeNode", { in: "coloredBorder" }), jsx("feMergeNode", { in: "SourceGraphic" })] })] }), jsxs("filter", { id: `path-hover-${DataType.OBSTACLE}`, x: "-10%", y: "-10%", width: "120%", height: "120%", children: [jsx("feMorphology", { operator: "dilate", radius: "1", in: "SourceGraphic", result: "border" }), jsx("feFlood", { floodColor: OBSTACLE_STYLES.lineColor, floodOpacity: "1", result: "borderColor" }), jsx("feComposite", { in: "borderColor", in2: "border", operator: "in", result: "coloredBorder" }), jsxs("feMerge", { children: [jsx("feMergeNode", { in: "coloredBorder" }), jsx("feMergeNode", { in: "SourceGraphic" })] })] })] }), Object.keys(svgElementDatas)
|
|
@@ -20868,10 +20812,7 @@ const getValidGpsBounds = (mapData, rotation = 0) => {
|
|
|
20868
20812
|
else {
|
|
20869
20813
|
// 最后的fallback:使用默认坐标
|
|
20870
20814
|
console.warn('无法获取有效的GPS边界,使用默认坐标');
|
|
20871
|
-
bounds =
|
|
20872
|
-
sw: [-9.1562, -37.7503],
|
|
20873
|
-
ne: [31.247, 5.797],
|
|
20874
|
-
};
|
|
20815
|
+
bounds = DEFAULT_COORDINATES;
|
|
20875
20816
|
}
|
|
20876
20817
|
}
|
|
20877
20818
|
// 如果有旋转角度,计算旋转后的边界
|
|
@@ -21024,7 +20965,6 @@ modelType, mapRef, mapJson, pathJson, realTimeData, antennaConfig, onMapLoad, on
|
|
|
21024
20965
|
overlayScale,
|
|
21025
20966
|
doodleList,
|
|
21026
20967
|
]);
|
|
21027
|
-
// console.log('svgElementDatas->', svgElementDatas, unStructMapData, commonValue);
|
|
21028
20968
|
// 处理地图分区边界
|
|
21029
20969
|
// const partitionBoundary = useMemo(() => {
|
|
21030
20970
|
// const allBoundaryElements = [];
|
|
@@ -21272,8 +21212,7 @@ modelType, mapRef, mapJson, pathJson, realTimeData, antennaConfig, onMapLoad, on
|
|
|
21272
21212
|
// 基于固定的参考zoom级别计算overlayScale
|
|
21273
21213
|
const zoomDiff = currentZoom - REFERENCE_ZOOM;
|
|
21274
21214
|
const scale = Math.pow(2, -zoomDiff); // 负数实现反向缩放
|
|
21275
|
-
|
|
21276
|
-
setOverlayScale(scale < 1 ? 1 : scale);
|
|
21215
|
+
setOverlayScale(scale < 1 ? 1 : platform === PlatformType.H5 ? 1.5 * scale : scale);
|
|
21277
21216
|
};
|
|
21278
21217
|
// 使用lodash throttle进行节流处理: 100ms内只执行一次
|
|
21279
21218
|
const handleZoomChanged = throttle$2(updateScale, 50);
|
|
@@ -21355,7 +21294,9 @@ modelType, mapRef, mapJson, pathJson, realTimeData, antennaConfig, onMapLoad, on
|
|
|
21355
21294
|
// 添加视觉失效区
|
|
21356
21295
|
addVisionOffPoint: () => svgEditMapRef.current?.addVisionOffPoint(),
|
|
21357
21296
|
// h5进入视觉失效区编辑模式
|
|
21358
|
-
enterVisionOffEditMode: (mode) =>
|
|
21297
|
+
enterVisionOffEditMode: (mode) => {
|
|
21298
|
+
svgEditMapRef.current?.enterVisionOffEditMode(mode);
|
|
21299
|
+
},
|
|
21359
21300
|
// 重做
|
|
21360
21301
|
redo: () => svgEditMapRef.current?.redo(),
|
|
21361
21302
|
// 撤销
|