@fleet-frontend/mower-maps 0.2.5-beta.2 → 0.2.5-beta.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/README.md +39 -1
- package/dist/context/common.d.ts +37 -2
- package/dist/context/common.d.ts.map +1 -1
- package/dist/index.esm.js +496 -127
- package/dist/index.js +496 -127
- package/dist/render/MowerMapRenderer.d.ts.map +1 -1
- package/dist/render/svgElement/PolygonELement/components/Magnifier/index.d.ts +41 -0
- package/dist/render/svgElement/PolygonELement/components/Magnifier/index.d.ts.map +1 -0
- package/dist/render/svgElement/PolygonELement/index.d.ts.map +1 -1
- package/dist/types/renderer.d.ts +6 -0
- package/dist/types/renderer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10629,8 +10629,8 @@ var REAL_TIME_DATA_TYPE;
|
|
|
10629
10629
|
*/
|
|
10630
10630
|
// 默认坐标
|
|
10631
10631
|
const DEFAULT_COORDINATES = {
|
|
10632
|
-
sw: [116.
|
|
10633
|
-
ne: [116.
|
|
10632
|
+
sw: [116.071044, 40.102099],
|
|
10633
|
+
ne: [116.0734, 40.103901],
|
|
10634
10634
|
};
|
|
10635
10635
|
/**
|
|
10636
10636
|
* 缩放因子 - 将米转换为像素
|
|
@@ -22543,15 +22543,25 @@ var index = {
|
|
|
22543
22543
|
const CommonContext = React.createContext({
|
|
22544
22544
|
sn: '',
|
|
22545
22545
|
editMap: false,
|
|
22546
|
-
mowerIconConfig: {
|
|
22546
|
+
mowerIconConfig: {
|
|
22547
|
+
mapImgUrl: '',
|
|
22548
|
+
mapDisabledUrl: '',
|
|
22549
|
+
mapNoPositionUrl: '',
|
|
22550
|
+
},
|
|
22547
22551
|
platform: exports.PlatformType.WEB,
|
|
22548
22552
|
svgViewBox: null,
|
|
22549
22553
|
unitType: UnitsType.Metric,
|
|
22554
|
+
mapConfig: {},
|
|
22555
|
+
mapJson: null,
|
|
22556
|
+
drag: { x: 0, y: 0, rotate: 0, rotation: 0 },
|
|
22550
22557
|
mapRef: null,
|
|
22558
|
+
bounds: null,
|
|
22551
22559
|
globalHeight: 0,
|
|
22552
22560
|
heightOptions: [],
|
|
22553
22561
|
overlayScale: 1,
|
|
22554
22562
|
showStraddleBoundaryBorder: true,
|
|
22563
|
+
googleMapStaticApiKey: '',
|
|
22564
|
+
onH5FirstSelectObstaclePoint: undefined,
|
|
22555
22565
|
});
|
|
22556
22566
|
const CommonContextProvider = CommonContext.Provider;
|
|
22557
22567
|
const useCommonContext = () => React.useContext(CommonContext);
|
|
@@ -22983,10 +22993,6 @@ const DistanceLabels = ({ coordinates, createMode = false, editMode = false, com
|
|
|
22983
22993
|
} }))] }));
|
|
22984
22994
|
};
|
|
22985
22995
|
|
|
22986
|
-
var css_248z$5 = ".index-module_pointerCursor__Ee6pr {\n cursor: pointer;\n}\n\n.index-module_polygonPath__PynOn {\n pointer-events: stroke;\n cursor: pointer;\n}\n\n.index-module_dragging__xSFdO {\n cursor: grabbing;\n}\n\n.index-module_notCreate__bFnkV {\n cursor: no-drop;\n}";
|
|
22987
|
-
var styles$5 = {"pointerCursor":"index-module_pointerCursor__Ee6pr","polygonPath":"index-module_polygonPath__PynOn","dragging":"index-module_dragging__xSFdO","notCreate":"index-module_notCreate__bFnkV"};
|
|
22988
|
-
styleInject(css_248z$5);
|
|
22989
|
-
|
|
22990
22996
|
exports.CreateStatus = void 0;
|
|
22991
22997
|
(function (CreateStatus) {
|
|
22992
22998
|
CreateStatus["CREATING"] = "creating";
|
|
@@ -23036,6 +23042,420 @@ const MapEditContext = React.createContext({
|
|
|
23036
23042
|
const MapEditContextProvider = MapEditContext.Provider;
|
|
23037
23043
|
const useMapEditContext = () => React.useContext(MapEditContext);
|
|
23038
23044
|
|
|
23045
|
+
var chargingPileImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6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eqQBMX2aBlsavWbTr7AWakEAhJrEoMzBK+mnGUGK2NxYJ7NGFCjY9cWDuxHJ4EC6h/Nrd9+2l9dadbdpumDeX+ipjKDajmaKE0iVC1kkptUqnuFtoLbvvJNOyC4tUtG3ETWOxynssx3gf9R8Pm2r2EIXgxWC4JMBcfvXunTu6djhDi80TQ90aga2uv4Ivs0bfSZtHSQbLyMwSUekfruB0PF6ppMW8UVwAE9gebywlN66b3klilD2Pf31uDi6hLOvSi8u3X3t5sOGmT9FQqxqndk2iyZ50QKXjahPxqFrchL3WlQPS0Rkd9QgwG8DovujaUw4dlCnIqkiA+2NjzR2PH5x7Gi6xXLKFy3Lnb3xhOrRhL60tT3TFnwKIe/sejGDL6DpJgAXn+YSMx7iTk28O1z3SaUe8ZIc+hfCeJ772aB8us3wgwF4+d9cXplqIM6Hrprrgm9fSimSMaasE5JhGSG494iFMVKKgKvk7B94JT7D7NL2654m/v3ygXlYEsJfpu35rArCejm23jex7q/05D+qYOYHOORZcQSmFVYgpfunoY419ODP21UOH5lbsr9RWFHBZpqd3jsMVZybJyJTO4gbCPk6YJgjrRPZp+TFP7HaSMA9iFQfkyO/Awqr+SoIsyw8B5OTF820K0FQAAAAASUVORK5CYII=";
|
|
23046
|
+
|
|
23047
|
+
const useChargingPile = ({ viewBox, rotation = 0 }) => {
|
|
23048
|
+
const { svgElementDatas } = useSvgEditContext();
|
|
23049
|
+
const { sn } = useCommonContext();
|
|
23050
|
+
const items = React.useMemo(() => {
|
|
23051
|
+
if (!svgElementDatas || !viewBox)
|
|
23052
|
+
return [];
|
|
23053
|
+
const chargingPiles = svgElementDatas?.[exports.DataType.CHARGING_PILE];
|
|
23054
|
+
if (!chargingPiles)
|
|
23055
|
+
return [];
|
|
23056
|
+
const results = [];
|
|
23057
|
+
for (const element of chargingPiles) {
|
|
23058
|
+
const center = element.points?.[0];
|
|
23059
|
+
if (!center)
|
|
23060
|
+
continue;
|
|
23061
|
+
const size = element.style?.radius ? element.style.radius * 2 : 55;
|
|
23062
|
+
const direction = element?.direction || 0;
|
|
23063
|
+
const angle = (direction * 180) / Math.PI;
|
|
23064
|
+
const rotationDegree = 270 - angle; // 正东是正方向,需要处理下
|
|
23065
|
+
const actualRotation = rotationDegree - rotation;
|
|
23066
|
+
const relX = (center[0] - viewBox.x) / viewBox.width;
|
|
23067
|
+
const relY = (center[1] - viewBox.y) / viewBox.height;
|
|
23068
|
+
if (isFinite(relX) && isFinite(relY)) {
|
|
23069
|
+
results.push({
|
|
23070
|
+
leftPct: relX * 100,
|
|
23071
|
+
topPct: relY * 100,
|
|
23072
|
+
size,
|
|
23073
|
+
rotateDeg: actualRotation,
|
|
23074
|
+
imageSrc: chargingPileImage,
|
|
23075
|
+
});
|
|
23076
|
+
}
|
|
23077
|
+
}
|
|
23078
|
+
return results;
|
|
23079
|
+
}, [svgElementDatas, viewBox?.x, viewBox?.y, viewBox?.width, viewBox?.height, rotation, sn]);
|
|
23080
|
+
return items;
|
|
23081
|
+
};
|
|
23082
|
+
|
|
23083
|
+
const CharginPile = React.memo(({ viewBox, rotation = 0 }) => {
|
|
23084
|
+
const items = useChargingPile({ viewBox: viewBox || null, rotation });
|
|
23085
|
+
const containerStyle = React.useMemo(() => ({
|
|
23086
|
+
position: 'absolute',
|
|
23087
|
+
top: 0,
|
|
23088
|
+
left: 0,
|
|
23089
|
+
width: '100%',
|
|
23090
|
+
height: '100%',
|
|
23091
|
+
pointerEvents: 'none',
|
|
23092
|
+
zIndex: 750,
|
|
23093
|
+
}), []);
|
|
23094
|
+
return (jsxRuntime.jsx("div", { style: containerStyle, children: items?.map((item, idx) => (jsxRuntime.jsx("div", { className: "charging-pile", style: {
|
|
23095
|
+
position: 'absolute',
|
|
23096
|
+
width: item.size,
|
|
23097
|
+
height: item.size,
|
|
23098
|
+
left: `${item.leftPct}%`,
|
|
23099
|
+
top: `${item.topPct}%`,
|
|
23100
|
+
transform: `translate(-50%, -50%) rotate(${item.rotateDeg}deg)`,
|
|
23101
|
+
pointerEvents: 'auto',
|
|
23102
|
+
zIndex: 750,
|
|
23103
|
+
}, children: jsxRuntime.jsx("img", { src: item.imageSrc, style: { width: '100%', height: '100%', objectFit: 'contain', opacity: 1 } }) }, `pile-${idx}`))) }));
|
|
23104
|
+
});
|
|
23105
|
+
|
|
23106
|
+
const MAX_STATIC_SIZE = 640;
|
|
23107
|
+
const MAX_STATIC_MAP_RETRY = 3;
|
|
23108
|
+
const Magnifier = ({ visible, dragState, polygonPoints, fillColor = 'rgba(255, 122, 51, 0.1)', strokeColor = 'rgba(255, 122, 51, 1)', strokeWidth = 2, zoom = 3, size = 200, }) => {
|
|
23109
|
+
const { svgViewBox, mapRef, googleMapStaticApiKey, drag } = useCommonContext();
|
|
23110
|
+
const { svgElementDatas, svgRef } = useSvgEditContext();
|
|
23111
|
+
const { editMapInfo } = useMapEditContext();
|
|
23112
|
+
const [magnifierPosition, setMagnifierPosition] = React.useState({ x: 0, y: 0 });
|
|
23113
|
+
const [magnifierBoxSize, setMagnifierBoxSize] = React.useState({ width: size, height: size });
|
|
23114
|
+
// 本次拖拽中放大镜位置是否已完成初始化(未完成前隐藏,避免首帧闪动)
|
|
23115
|
+
const [isPlacementReady, setIsPlacementReady] = React.useState(false);
|
|
23116
|
+
// 放大镜所在侧边:true=右侧,false=左侧
|
|
23117
|
+
const [placeOnRight, setPlaceOnRight] = React.useState(true);
|
|
23118
|
+
// 仅在每次拖拽开始时初始化一次侧边
|
|
23119
|
+
const hasInitializedSideRef = React.useRef(false);
|
|
23120
|
+
const [mapImageFrame, setMapImageFrame] = React.useState(null);
|
|
23121
|
+
const [staticMapRetryCount, setStaticMapRetryCount] = React.useState(0);
|
|
23122
|
+
// 获取当前正在拖拽的禁区 ID
|
|
23123
|
+
const currentObstacleId = editMapInfo?.selectElement?.id;
|
|
23124
|
+
// 计算当前 SVG 单位到屏幕像素的比例(用于实现真正 1:1 预览)
|
|
23125
|
+
const getPixelScale = () => {
|
|
23126
|
+
//先拿 svgRef.getScreenCTM(),这是 SVG 到屏幕的变换矩阵(包含缩放/旋转/平移)
|
|
23127
|
+
const ctm = svgRef?.getScreenCTM?.();
|
|
23128
|
+
if (!ctm)
|
|
23129
|
+
return 1;
|
|
23130
|
+
// 使用向量长度计算缩放,兼容旋转矩阵
|
|
23131
|
+
// 用 Math.hypot(ctm.a, ctm.b) 算出 x 方向的实际缩放倍率(用向量长度是为了兼容旋转,不只看 a)
|
|
23132
|
+
const scaleX = Math.hypot(ctm.a, ctm.b);
|
|
23133
|
+
return Number.isFinite(scaleX) && scaleX > 0 ? scaleX : 1;
|
|
23134
|
+
};
|
|
23135
|
+
// 读取设备安全区(刘海/手势条)inset,兼容横屏 H5
|
|
23136
|
+
const getSafeAreaInsets = () => {
|
|
23137
|
+
const probe = document.createElement('div');
|
|
23138
|
+
probe.style.position = 'fixed';
|
|
23139
|
+
probe.style.left = '0';
|
|
23140
|
+
probe.style.top = '0';
|
|
23141
|
+
probe.style.width = '0';
|
|
23142
|
+
probe.style.height = '0';
|
|
23143
|
+
probe.style.visibility = 'hidden';
|
|
23144
|
+
probe.style.pointerEvents = 'none';
|
|
23145
|
+
probe.style.paddingTop = 'env(safe-area-inset-top)';
|
|
23146
|
+
probe.style.paddingRight = 'env(safe-area-inset-right)';
|
|
23147
|
+
probe.style.paddingBottom = 'env(safe-area-inset-bottom)';
|
|
23148
|
+
probe.style.paddingLeft = 'env(safe-area-inset-left)';
|
|
23149
|
+
document.body.appendChild(probe);
|
|
23150
|
+
const style = window.getComputedStyle(probe);
|
|
23151
|
+
const insets = {
|
|
23152
|
+
top: Number.parseFloat(style.paddingTop) || 0,
|
|
23153
|
+
right: Number.parseFloat(style.paddingRight) || 0,
|
|
23154
|
+
bottom: Number.parseFloat(style.paddingBottom) || 0,
|
|
23155
|
+
left: Number.parseFloat(style.paddingLeft) || 0,
|
|
23156
|
+
};
|
|
23157
|
+
document.body.removeChild(probe);
|
|
23158
|
+
return insets;
|
|
23159
|
+
};
|
|
23160
|
+
// 计算并获取放大镜底图:优先使用 Google Maps Static API,无图时走灰色背景兜底
|
|
23161
|
+
React.useEffect(() => {
|
|
23162
|
+
if (!visible || !dragState.currentPosition || !mapRef || !svgViewBox || !svgRef) {
|
|
23163
|
+
// console.log('[Magnifier] Skip static map effect: missing deps', {
|
|
23164
|
+
// visible,
|
|
23165
|
+
// hasCurrentPosition: Boolean(dragState.currentPosition),
|
|
23166
|
+
// hasMapRef: Boolean(mapRef),
|
|
23167
|
+
// hasSvgViewBox: Boolean(svgViewBox),
|
|
23168
|
+
// hasSvgRef: Boolean(svgRef),
|
|
23169
|
+
// });
|
|
23170
|
+
setMapImageFrame(null);
|
|
23171
|
+
setStaticMapRetryCount(0);
|
|
23172
|
+
return;
|
|
23173
|
+
}
|
|
23174
|
+
const mapDiv = mapRef.getDiv?.();
|
|
23175
|
+
// 获取 SVG 到屏幕的变换矩阵的逆矩阵
|
|
23176
|
+
const inverseCtm = svgRef.getScreenCTM?.()?.inverse?.();
|
|
23177
|
+
if (!mapDiv || !inverseCtm) {
|
|
23178
|
+
// console.log('[Magnifier] Skip static map effect: mapDiv/ctm missing', {
|
|
23179
|
+
// hasMapDiv: Boolean(mapDiv),
|
|
23180
|
+
// hasInverseCtm: Boolean(inverseCtm),
|
|
23181
|
+
// });
|
|
23182
|
+
setMapImageFrame(null);
|
|
23183
|
+
setStaticMapRetryCount(0);
|
|
23184
|
+
return;
|
|
23185
|
+
}
|
|
23186
|
+
const mapRect = mapDiv.getBoundingClientRect();
|
|
23187
|
+
const svgPoint = svgRef.createSVGPoint();
|
|
23188
|
+
// 只要有 key 就尝试 static api;请求失败时不截图,直接回退灰色背景
|
|
23189
|
+
if (googleMapStaticApiKey) {
|
|
23190
|
+
// console.log('[Magnifier] Background source: static api viewport snapshot');
|
|
23191
|
+
const mapBounds = mapRef.getBounds?.();
|
|
23192
|
+
if (!mapBounds) {
|
|
23193
|
+
// console.log('[Magnifier] Skip static map effect: mapBounds missing');
|
|
23194
|
+
setMapImageFrame(null);
|
|
23195
|
+
return;
|
|
23196
|
+
}
|
|
23197
|
+
const screenToSvg = (screenX, screenY) => {
|
|
23198
|
+
svgPoint.x = screenX;
|
|
23199
|
+
svgPoint.y = screenY;
|
|
23200
|
+
const p = svgPoint.matrixTransform(inverseCtm);
|
|
23201
|
+
return { x: p.x, y: p.y };
|
|
23202
|
+
};
|
|
23203
|
+
// 使用当前地图视口矩形四角,将屏幕坐标映射到 SVG 坐标,确保底图与主视口对齐
|
|
23204
|
+
const topLeftSvg = screenToSvg(mapRect.left, mapRect.top);
|
|
23205
|
+
const topRightSvg = screenToSvg(mapRect.right, mapRect.top);
|
|
23206
|
+
const bottomLeftSvg = screenToSvg(mapRect.left, mapRect.bottom);
|
|
23207
|
+
if (!topLeftSvg || !topRightSvg || !bottomLeftSvg) {
|
|
23208
|
+
setMapImageFrame(null);
|
|
23209
|
+
return;
|
|
23210
|
+
}
|
|
23211
|
+
// 把当前主地图可视区域尺寸,按比例压到 Static API 允许的最大尺寸以内(受 Static API 640 上限约束)),同时不改变宽高比。
|
|
23212
|
+
const mapWidth = Math.max(1, Math.round(mapRect.width));
|
|
23213
|
+
const mapHeight = Math.max(1, Math.round(mapRect.height));
|
|
23214
|
+
const shrinkRatio = Math.min(1, MAX_STATIC_SIZE / Math.max(mapWidth, mapHeight));
|
|
23215
|
+
const staticWidth = Math.max(1, Math.round(mapWidth * shrinkRatio));
|
|
23216
|
+
const staticHeight = Math.max(1, Math.round(mapHeight * shrinkRatio));
|
|
23217
|
+
const center = mapBounds.getCenter();
|
|
23218
|
+
const currentZoom = mapRef.getZoom() || 20;
|
|
23219
|
+
// 尺寸缩小后同步补偿 zoom,保持与当前主图一致的地理覆盖范围
|
|
23220
|
+
const zoomCompensation = Math.log2(shrinkRatio);
|
|
23221
|
+
const adjustedZoom = currentZoom + zoomCompensation;
|
|
23222
|
+
const staticZoom = Math.max(0, Math.min(Math.floor(adjustedZoom), 22));
|
|
23223
|
+
const staticMapUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${center.lat()},${center.lng()}&zoom=${staticZoom}&size=${staticWidth}x${staticHeight}&maptype=satellite&key=${googleMapStaticApiKey}`;
|
|
23224
|
+
// 通过三角点推导静态图在 SVG 中的宽高和旋转角
|
|
23225
|
+
// Math.hypot(x, y) 等价于 sqrt(x*x + y*y),计算两点之间的距离
|
|
23226
|
+
const width = Math.hypot(topRightSvg.x - topLeftSvg.x, topRightSvg.y - topLeftSvg.y);
|
|
23227
|
+
const height = Math.hypot(bottomLeftSvg.x - topLeftSvg.x, bottomLeftSvg.y - topLeftSvg.y);
|
|
23228
|
+
// Math.atan2(y, x) 计算反正切值,返回 [-π, π] 弧度,*180/π 转换为角度
|
|
23229
|
+
const rotationDeg = (Math.atan2(topRightSvg.y - topLeftSvg.y, topRightSvg.x - topLeftSvg.x) * 180) / Math.PI;
|
|
23230
|
+
// Static API zoom 只能取整;额外补偿小数部分,避免底图视觉偏小
|
|
23231
|
+
// 在有旋转的坐标系里,做“以中心为锚点”的等比放大补偿。
|
|
23232
|
+
const fractionalZoomScale = Math.pow(2, adjustedZoom - staticZoom); //算出“还差多少缩放比例”。例子:adjustedZoom=19.6,staticZoom=19,差 0.6,比例是 2^0.6 ≈ 1.515。
|
|
23233
|
+
//把原始 width/height 乘这个比例,得到补偿后的尺寸。
|
|
23234
|
+
const compensatedWidth = width * fractionalZoomScale;
|
|
23235
|
+
const compensatedHeight = height * fractionalZoomScale;
|
|
23236
|
+
//尺寸变大后,多出来的宽/高的一半(要从两边均匀扩张)。
|
|
23237
|
+
const offsetAlongX = (compensatedWidth - width) / 2;
|
|
23238
|
+
const offsetAlongY = (compensatedHeight - height) / 2;
|
|
23239
|
+
//“右方向”单位向量(从左上指向右上),因为图可能旋转了,不能只按水平 x 轴算。
|
|
23240
|
+
const unitX = width > 0 ? (topRightSvg.x - topLeftSvg.x) / width : 1;
|
|
23241
|
+
const unitY = width > 0 ? (topRightSvg.y - topLeftSvg.y) / width : 0;
|
|
23242
|
+
//“下方向”单位向量(从左上指向左下),同理用于旋转场景。
|
|
23243
|
+
const unitDownX = height > 0 ? (bottomLeftSvg.x - topLeftSvg.x) / height : 0;
|
|
23244
|
+
const unitDownY = height > 0 ? (bottomLeftSvg.y - topLeftSvg.y) / height : 1;
|
|
23245
|
+
/**
|
|
23246
|
+
* 计算补偿后的新左上角:
|
|
23247
|
+
* 从原左上角沿“右方向”回退半个扩展量,再沿“下方向”回退半个扩展量。
|
|
23248
|
+
* 这样放大后仍以原区域中心为中心,不会放大后位置偏移。
|
|
23249
|
+
*/
|
|
23250
|
+
const compensatedTopLeftX = topLeftSvg.x - unitX * offsetAlongX - unitDownX * offsetAlongY;
|
|
23251
|
+
const compensatedTopLeftY = topLeftSvg.y - unitY * offsetAlongX - unitDownY * offsetAlongY;
|
|
23252
|
+
setMapImageFrame({
|
|
23253
|
+
url: staticMapUrl,
|
|
23254
|
+
x: compensatedTopLeftX,
|
|
23255
|
+
y: compensatedTopLeftY,
|
|
23256
|
+
width: compensatedWidth,
|
|
23257
|
+
height: compensatedHeight,
|
|
23258
|
+
transform: `rotate(${rotationDeg} ${compensatedTopLeftX} ${compensatedTopLeftY})`,
|
|
23259
|
+
});
|
|
23260
|
+
}
|
|
23261
|
+
else {
|
|
23262
|
+
setMapImageFrame(null);
|
|
23263
|
+
setStaticMapRetryCount(0);
|
|
23264
|
+
// console.log('[Magnifier] Background source: gray fallback (no static api key)');
|
|
23265
|
+
}
|
|
23266
|
+
}, [
|
|
23267
|
+
visible,
|
|
23268
|
+
dragState.isDragging,
|
|
23269
|
+
mapRef,
|
|
23270
|
+
svgViewBox?.x,
|
|
23271
|
+
svgViewBox?.y,
|
|
23272
|
+
svgViewBox?.width,
|
|
23273
|
+
svgViewBox?.height,
|
|
23274
|
+
svgRef,
|
|
23275
|
+
size,
|
|
23276
|
+
zoom,
|
|
23277
|
+
googleMapStaticApiKey,
|
|
23278
|
+
staticMapRetryCount,
|
|
23279
|
+
]);
|
|
23280
|
+
React.useLayoutEffect(() => {
|
|
23281
|
+
if (!visible) {
|
|
23282
|
+
hasInitializedSideRef.current = false;
|
|
23283
|
+
setIsPlacementReady(false);
|
|
23284
|
+
return;
|
|
23285
|
+
}
|
|
23286
|
+
const updatePosition = () => {
|
|
23287
|
+
const mapDiv = mapRef?.getDiv?.();
|
|
23288
|
+
const mapRect = mapDiv?.getBoundingClientRect?.();
|
|
23289
|
+
const boxSize = Math.max(120, Math.round(size));
|
|
23290
|
+
// 设置放大镜大小
|
|
23291
|
+
setMagnifierBoxSize({ width: boxSize, height: boxSize });
|
|
23292
|
+
const viewportWidth = window.innerWidth;
|
|
23293
|
+
const viewportHeight = window.innerHeight;
|
|
23294
|
+
const baseMargin = 10; // 放大镜与边缘的基础间距
|
|
23295
|
+
const insets = getSafeAreaInsets();
|
|
23296
|
+
const marginTop = Math.max(baseMargin, insets.top);
|
|
23297
|
+
const marginRight = Math.max(baseMargin, insets.right);
|
|
23298
|
+
const marginBottom = Math.max(baseMargin, insets.bottom);
|
|
23299
|
+
const marginLeft = Math.max(baseMargin, insets.left);
|
|
23300
|
+
const topY = mapRect ? mapRect.top + marginTop : marginTop;
|
|
23301
|
+
// 顶部位置限制在可视区与安全区内,避免横屏时被刘海/手势条遮挡
|
|
23302
|
+
const safeTopY = Math.max(marginTop, Math.min(topY, viewportHeight - boxSize - marginBottom));
|
|
23303
|
+
let nextPlaceOnRight = placeOnRight;
|
|
23304
|
+
const ctm = svgRef?.getScreenCTM?.();
|
|
23305
|
+
// 首次显示时先同步算出侧边,再基于该侧边定位,避免“先左后右/先右后左”闪动
|
|
23306
|
+
if (!hasInitializedSideRef.current && dragState.currentPosition && ctm && mapRect) {
|
|
23307
|
+
const p = svgRef.createSVGPoint();
|
|
23308
|
+
p.x = dragState.currentPosition[0];
|
|
23309
|
+
p.y = dragState.currentPosition[1];
|
|
23310
|
+
const dragScreenPoint = p.matrixTransform(ctm);
|
|
23311
|
+
const mapMidX = mapRect.left + mapRect.width / 2;
|
|
23312
|
+
nextPlaceOnRight = dragScreenPoint.x < mapMidX;
|
|
23313
|
+
setPlaceOnRight(nextPlaceOnRight);
|
|
23314
|
+
hasInitializedSideRef.current = true;
|
|
23315
|
+
}
|
|
23316
|
+
const rightX = mapRect
|
|
23317
|
+
? mapRect.right - boxSize - marginRight
|
|
23318
|
+
: viewportWidth - boxSize - marginRight;
|
|
23319
|
+
const leftX = mapRect ? mapRect.left + marginLeft : marginLeft;
|
|
23320
|
+
const safeX = nextPlaceOnRight ? rightX : leftX;
|
|
23321
|
+
const boundedX = Math.max(marginLeft, Math.min(safeX, viewportWidth - boxSize - marginRight));
|
|
23322
|
+
// 放大镜出现后,仅当拖拽点进入放大镜区域时才切换到对侧
|
|
23323
|
+
if (dragState.currentPosition && ctm) {
|
|
23324
|
+
const p = svgRef.createSVGPoint();
|
|
23325
|
+
p.x = dragState.currentPosition[0];
|
|
23326
|
+
p.y = dragState.currentPosition[1];
|
|
23327
|
+
// 应用这个矩阵,变换成屏幕坐标
|
|
23328
|
+
const dragScreenPoint = p.matrixTransform(ctm);
|
|
23329
|
+
const pointInMagnifier = dragScreenPoint.x >= boundedX &&
|
|
23330
|
+
dragScreenPoint.x <= boundedX + boxSize &&
|
|
23331
|
+
dragScreenPoint.y >= safeTopY &&
|
|
23332
|
+
dragScreenPoint.y <= safeTopY + boxSize;
|
|
23333
|
+
if (pointInMagnifier) {
|
|
23334
|
+
setPlaceOnRight((prev) => !prev);
|
|
23335
|
+
return;
|
|
23336
|
+
}
|
|
23337
|
+
}
|
|
23338
|
+
setMagnifierPosition({
|
|
23339
|
+
x: boundedX,
|
|
23340
|
+
y: safeTopY,
|
|
23341
|
+
});
|
|
23342
|
+
setIsPlacementReady(true);
|
|
23343
|
+
};
|
|
23344
|
+
updatePosition();
|
|
23345
|
+
window.addEventListener('resize', updatePosition);
|
|
23346
|
+
return () => window.removeEventListener('resize', updatePosition);
|
|
23347
|
+
}, [
|
|
23348
|
+
visible,
|
|
23349
|
+
size,
|
|
23350
|
+
mapRef,
|
|
23351
|
+
svgRef,
|
|
23352
|
+
placeOnRight,
|
|
23353
|
+
dragState.currentPosition?.[0],
|
|
23354
|
+
dragState.currentPosition?.[1],
|
|
23355
|
+
]);
|
|
23356
|
+
// 早期返回必须在所有 hooks 之后
|
|
23357
|
+
if (!visible || !dragState.currentPosition || !svgViewBox) {
|
|
23358
|
+
return null;
|
|
23359
|
+
}
|
|
23360
|
+
const [centerX, centerY] = dragState.currentPosition;
|
|
23361
|
+
// 计算放大区域范围(以拖拽点为中心)
|
|
23362
|
+
//effectiveZoom = Math.max(0.001, zoom * getPixelScale())
|
|
23363
|
+
// 得到实际放大倍率。
|
|
23364
|
+
// zoom 是你设置的放大倍数(比如 3)
|
|
23365
|
+
// getPixelScale() 是当前 SVG 到屏幕的缩放因子(地图本身被缩放时要补偿)
|
|
23366
|
+
// Math.max(0.001, ...) 是防止出现 0 或极小值导致除零/异常
|
|
23367
|
+
// magnifierWidthInSvg = magnifierBoxSize.width / effectiveZoom
|
|
23368
|
+
// magnifierHeightInSvg = magnifierBoxSize.height / effectiveZoom
|
|
23369
|
+
// 把“屏幕上放大镜框的像素尺寸”换算成“SVG 坐标里要截取的实际尺寸”
|
|
23370
|
+
// 放大倍率越大,分母越大,截取范围越小 => 看起来越放大
|
|
23371
|
+
const effectiveZoom = Math.max(0.001, zoom * getPixelScale());
|
|
23372
|
+
const magnifierWidthInSvg = magnifierBoxSize.width / effectiveZoom;
|
|
23373
|
+
const magnifierHeightInSvg = magnifierBoxSize.height / effectiveZoom;
|
|
23374
|
+
// 计算放大区域的 viewBox
|
|
23375
|
+
const magnifierViewBox = {
|
|
23376
|
+
x: centerX - magnifierWidthInSvg / 2,
|
|
23377
|
+
y: centerY - magnifierHeightInSvg / 2,
|
|
23378
|
+
width: magnifierWidthInSvg,
|
|
23379
|
+
height: magnifierHeightInSvg,
|
|
23380
|
+
};
|
|
23381
|
+
// 样式缩放采用“弱抵消”,避免随 zoom 变细,保证放大镜内点线清晰度
|
|
23382
|
+
const styleZoomFactor = Math.max(1, zoom * 0.4);
|
|
23383
|
+
// 生成多边形点字符串(仅用于当前编辑禁区)
|
|
23384
|
+
const polygonPointsString = polygonPoints.length > 0 ? polygonPoints.map((p) => `${p[0]},${p[1]}`).join(' ') : '';
|
|
23385
|
+
const actureRotate = drag?.rotate ?? drag?.rotation ?? 0;
|
|
23386
|
+
// 渲染放大镜内容
|
|
23387
|
+
const magnifierContent = (jsxRuntime.jsxs("div", { style: {
|
|
23388
|
+
position: 'fixed',
|
|
23389
|
+
left: `${magnifierPosition.x}px`,
|
|
23390
|
+
top: `${magnifierPosition.y}px`,
|
|
23391
|
+
width: `${magnifierBoxSize.width}px`,
|
|
23392
|
+
height: `${magnifierBoxSize.height}px`,
|
|
23393
|
+
borderRadius: '50%',
|
|
23394
|
+
border: `2px solid #fff`,
|
|
23395
|
+
// boxShadow: '0 4px 20px rgba(0, 0, 0, 0.3)',
|
|
23396
|
+
overflow: 'hidden',
|
|
23397
|
+
zIndex: 10000,
|
|
23398
|
+
pointerEvents: 'none',
|
|
23399
|
+
background: 'rgba(235, 236, 240, 1)',
|
|
23400
|
+
visibility: isPlacementReady ? 'visible' : 'hidden',
|
|
23401
|
+
}, children: [jsxRuntime.jsxs("svg", {
|
|
23402
|
+
// 逻辑尺寸:与放大镜容器一致
|
|
23403
|
+
width: magnifierBoxSize.width, height: magnifierBoxSize.height,
|
|
23404
|
+
// 核心放大参数:从整张 SVG 中裁剪出当前需要展示的区域(x y width height)
|
|
23405
|
+
viewBox: `${magnifierViewBox.x} ${magnifierViewBox.y} ${magnifierViewBox.width} ${magnifierViewBox.height}`,
|
|
23406
|
+
// 保持内容居中并铺满窗口;比例不一致时裁边,不留空白
|
|
23407
|
+
preserveAspectRatio: "xMidYMid slice", style: {
|
|
23408
|
+
// CSS 尺寸:让 SVG 完全填满放大镜容器
|
|
23409
|
+
width: '100%',
|
|
23410
|
+
height: '100%',
|
|
23411
|
+
}, children: [mapImageFrame && (jsxRuntime.jsx("image", { href: mapImageFrame.url, x: mapImageFrame.x, y: mapImageFrame.y, width: mapImageFrame.width, height: mapImageFrame.height, transform: mapImageFrame.transform, preserveAspectRatio: "none", style: { opacity: 1 }, onLoad: () => {
|
|
23412
|
+
// console.log('✅ Map background loaded in magnifier');
|
|
23413
|
+
setStaticMapRetryCount(0);
|
|
23414
|
+
}, onError: (_e) => {
|
|
23415
|
+
// console.error('❌ Failed to load map background in magnifier', {
|
|
23416
|
+
// retryCount: staticMapRetryCount,
|
|
23417
|
+
// maxRetry: MAX_STATIC_MAP_RETRY,
|
|
23418
|
+
// url: mapImageFrame.url,
|
|
23419
|
+
// error: _e,
|
|
23420
|
+
// });
|
|
23421
|
+
setStaticMapRetryCount((prev) => {
|
|
23422
|
+
if (prev < MAX_STATIC_MAP_RETRY)
|
|
23423
|
+
return prev + 1;
|
|
23424
|
+
setMapImageFrame(null);
|
|
23425
|
+
return 0;
|
|
23426
|
+
});
|
|
23427
|
+
} }, `magnifier-static-map-${staticMapRetryCount}`)), svgElementDatas &&
|
|
23428
|
+
Object.keys(svgElementDatas).map((key) => {
|
|
23429
|
+
const elements = svgElementDatas[key] || [];
|
|
23430
|
+
// 过滤掉当前正在拖拽的禁区(稍后单独渲染拖拽后的状态)
|
|
23431
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23432
|
+
const filteredElements = key === exports.DataType.OBSTACLE
|
|
23433
|
+
? elements.filter((item) => item.id !== currentObstacleId)
|
|
23434
|
+
: elements;
|
|
23435
|
+
if (filteredElements.length === 0)
|
|
23436
|
+
return null;
|
|
23437
|
+
return (jsxRuntime.jsxs(GElement, { type: key, children: [key === 'channel' && jsxRuntime.jsx(ChannelClipPath, {}), filteredElements.map((item) => (
|
|
23438
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23439
|
+
jsxRuntime.jsx(SvgElement, { type: key, data: item }, item?.id)))] }, key));
|
|
23440
|
+
}), polygonPoints.length >= 3 && polygonPointsString && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("polygon", { points: polygonPointsString, fill: fillColor, stroke: strokeColor, strokeWidth: (strokeWidth * 3.2) / styleZoomFactor, strokeOpacity: 1 }), polygonPoints.map((point, idx) => {
|
|
23441
|
+
const [x, y] = point;
|
|
23442
|
+
const isDraggingPoint = dragState.dragIndex === idx;
|
|
23443
|
+
const pointRadius = isDraggingPoint ? 14 / styleZoomFactor : 10 / styleZoomFactor;
|
|
23444
|
+
const pointFill = isDraggingPoint ? '#FFAB7E' : strokeColor;
|
|
23445
|
+
const pointStroke = isDraggingPoint ? strokeColor : '#fff';
|
|
23446
|
+
const pointStrokeWidth = isDraggingPoint
|
|
23447
|
+
? 3.6 / styleZoomFactor
|
|
23448
|
+
: 3 / styleZoomFactor;
|
|
23449
|
+
return (jsxRuntime.jsx("circle", { cx: x, cy: y, r: pointRadius, fill: pointFill, stroke: pointStroke, strokeWidth: pointStrokeWidth }, idx));
|
|
23450
|
+
})] })), dragState.dragType === 'new' && dragState.edgeInfo && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("line", { x1: dragState.edgeInfo.startPoint.x, y1: dragState.edgeInfo.startPoint.y, x2: dragState.edgeInfo.endPoint.x, y2: dragState.edgeInfo.endPoint.y, stroke: "#999", strokeWidth: (strokeWidth * 3.2) / styleZoomFactor, strokeDasharray: `${6 / styleZoomFactor},${6 / styleZoomFactor}` }) }))] }), jsxRuntime.jsx(CharginPile, { viewBox: magnifierViewBox || null, rotation: actureRotate })] }));
|
|
23451
|
+
// 使用 Portal 渲染到 body,避免层级问题
|
|
23452
|
+
return ReactDOM.createPortal(magnifierContent, document.body);
|
|
23453
|
+
};
|
|
23454
|
+
|
|
23455
|
+
var css_248z$5 = ".index-module_pointerCursor__Ee6pr {\n cursor: pointer;\n}\n\n.index-module_polygonPath__PynOn {\n pointer-events: stroke;\n cursor: pointer;\n}\n\n.index-module_dragging__xSFdO {\n cursor: grabbing;\n}\n\n.index-module_notCreate__bFnkV {\n cursor: no-drop;\n}";
|
|
23456
|
+
var styles$5 = {"pointerCursor":"index-module_pointerCursor__Ee6pr","polygonPath":"index-module_polygonPath__PynOn","dragging":"index-module_dragging__xSFdO","notCreate":"index-module_notCreate__bFnkV"};
|
|
23457
|
+
styleInject(css_248z$5);
|
|
23458
|
+
|
|
23039
23459
|
/**
|
|
23040
23460
|
* SVG 坐标转换工具函数
|
|
23041
23461
|
*/
|
|
@@ -23598,7 +24018,7 @@ const createPathData = (points) => {
|
|
|
23598
24018
|
};
|
|
23599
24019
|
const PolygonElement = ({ canSelect = false, points, fillColor = 'rgba(0, 0, 0, 0.1)', fillOpacity = 1, strokeColor = '#000', strokeWidth = 2, strokeOpacity = 1, createMode = false, showPoints = false, onPointClick, completed = false, mousePos = null, editMode = false, onCoordinatesChange, onPathClick, onPolygonClick, onVertexDelete, draggable = true, // 新增参数,如果未指定则根据createMode和editMode自动判断
|
|
23600
24020
|
}) => {
|
|
23601
|
-
const { overlayScale, unitType, showStraddleBoundaryBorder } = useCommonContext();
|
|
24021
|
+
const { overlayScale, unitType, showStraddleBoundaryBorder, platform, onH5FirstSelectObstaclePoint } = useCommonContext();
|
|
23602
24022
|
const { onHandleEvent } = useMapEditContext();
|
|
23603
24023
|
const { svgRef } = useSvgEditContext();
|
|
23604
24024
|
const [dragState, setDragState] = React.useState({
|
|
@@ -23616,7 +24036,6 @@ const PolygonElement = ({ canSelect = false, points, fillColor = 'rgba(0, 0, 0,
|
|
|
23616
24036
|
const [selectedVertexIndex, setSelectedVertexIndex] = React.useState(-1);
|
|
23617
24037
|
const { checkCanNotCreateAtPosition } = useCheckElement();
|
|
23618
24038
|
const { editMapInfo } = useMapEditContext();
|
|
23619
|
-
const { platform } = useCommonContext();
|
|
23620
24039
|
// delete icon可能被上一个点遮挡,因为delete在右上方,所以手动处理点让点按照顺时针渲染,这样delete icon层级就会高一些
|
|
23621
24040
|
// 编辑的场景禁区的点最后一个和第一个相同,会导致一个位置渲染两个点,需要额外处理下
|
|
23622
24041
|
const coordinates = React.useMemo(() => {
|
|
@@ -23849,9 +24268,14 @@ const PolygonElement = ({ canSelect = false, points, fillColor = 'rgba(0, 0, 0,
|
|
|
23849
24268
|
// 开始长按计时器(1000ms)
|
|
23850
24269
|
vertexLongPressTimerRef.current = window.setTimeout(() => {
|
|
23851
24270
|
isVertexLongPressedRef.current = true;
|
|
23852
|
-
setSelectedVertexIndex(
|
|
24271
|
+
setSelectedVertexIndex((prev) => {
|
|
24272
|
+
if (prev !== index) {
|
|
24273
|
+
onH5FirstSelectObstaclePoint?.();
|
|
24274
|
+
}
|
|
24275
|
+
return index;
|
|
24276
|
+
});
|
|
23853
24277
|
}, 1000);
|
|
23854
|
-
}, [editMode, createMode, completed, dragState.isDragging]);
|
|
24278
|
+
}, [editMode, createMode, completed, dragState.isDragging, onH5FirstSelectObstaclePoint]);
|
|
23855
24279
|
const handleVertexLongPressEnd = React.useCallback(() => {
|
|
23856
24280
|
if (vertexLongPressTimerRef.current !== null) {
|
|
23857
24281
|
window.clearTimeout(vertexLongPressTimerRef.current);
|
|
@@ -24225,7 +24649,11 @@ const PolygonElement = ({ canSelect = false, points, fillColor = 'rgba(0, 0, 0,
|
|
|
24225
24649
|
setHoverVertex(null);
|
|
24226
24650
|
},
|
|
24227
24651
|
}) }, `edge-${index}`));
|
|
24228
|
-
}), ghostLastPath && (jsxRuntime.jsx("path", { d: ghostLastPath, stroke: strokeColor, strokeWidth: strokeWidth, vectorEffect: "non-scaling-stroke", opacity: 0.7, onClick: onPathClick })), ghostFirstPath && renderCoordinates.length >= 2 && (jsxRuntime.jsx("path", { d: ghostFirstPath, stroke: strokeColor, strokeWidth: strokeWidth, vectorEffect: "non-scaling-stroke", opacity: 0.7, onClick: onPathClick })), jsxRuntime.jsx(DragDistanceIndicator, { dragState: dragState, strokeColor: strokeColor, editMode: editMode, createMode: createMode, completed: completed, fontSize: platform === exports.PlatformType.H5 ? 12 * overlayScale * 1.5 : 30 * overlayScale, unitType: unitType }), jsxRuntime.jsx(
|
|
24652
|
+
}), ghostLastPath && (jsxRuntime.jsx("path", { d: ghostLastPath, stroke: strokeColor, strokeWidth: strokeWidth, vectorEffect: "non-scaling-stroke", opacity: 0.7, onClick: onPathClick })), ghostFirstPath && renderCoordinates.length >= 2 && (jsxRuntime.jsx("path", { d: ghostFirstPath, stroke: strokeColor, strokeWidth: strokeWidth, vectorEffect: "non-scaling-stroke", opacity: 0.7, onClick: onPathClick })), jsxRuntime.jsx(DragDistanceIndicator, { dragState: dragState, strokeColor: strokeColor, editMode: editMode, createMode: createMode, completed: completed, fontSize: platform === exports.PlatformType.H5 ? 12 * overlayScale * 1.5 : 30 * overlayScale, unitType: unitType }), jsxRuntime.jsx(Magnifier, { visible: platform === exports.PlatformType.H5 &&
|
|
24653
|
+
dragState.isDragging &&
|
|
24654
|
+
dragState.dragIndex !== -1 &&
|
|
24655
|
+
dragState.currentPosition !== null &&
|
|
24656
|
+
(editMode || (createMode && completed)), dragState: dragState, polygonPoints: renderCoordinates, fillColor: fillColor, strokeColor: strokeColor, strokeWidth: strokeWidth, zoom: 3, size: 130 }), jsxRuntime.jsx(DistanceLabels, { coordinates: renderCoordinates, createMode: createMode, editMode: editMode, completed: completed, showPoints: showPoints, mousePos: mousePos, ghostLastDistance: ghostLastDistance, ghostLastMidpoint: ghostLastMidpoint, ghostFirstDistance: ghostFirstDistance, ghostFirstMidpoint: ghostFirstMidpoint, fontSize: platform === exports.PlatformType.H5 ? 12 * overlayScale * 1.5 : 30 * overlayScale, showFirstDistance: platform !== exports.PlatformType.H5, unit: unitType }), hoverVertex && !dragState.isDragging && (jsxRuntime.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)) &&
|
|
24229
24657
|
renderCoordinates.map((coord, idx) => {
|
|
24230
24658
|
// 判断当前顶点的状态
|
|
24231
24659
|
const isLastPoint = idx === renderCoordinates.length - 1;
|
|
@@ -26987,67 +27415,6 @@ const MowerPosition = React.memo(({ editMap, mowerPositionData, viewBox, modelTy
|
|
|
26987
27415
|
}, children: jsxRuntime.jsx("img", { src: mowerImage, style: { width: '100%', height: '100%', objectFit: 'contain' } }) }) }));
|
|
26988
27416
|
});
|
|
26989
27417
|
|
|
26990
|
-
var chargingPileImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAABHHSURBVHgBtVtdjF3VdV7rnHPHtLbUkRrALwmDidSSgD1JqWQ3UMaNMaFq63FIKyoVZFRF6kMkbCmVcP9mrBARoJUnLRL9c+3WSVsqIkwrtRBKfaGmQFuFazBpK0wYnmLSF6MYx557zt5Zv3vvO/Z4bDPZ9pl97rlnztnfXmt969s/g/AjKrN7nxwf634wBTFMYIQNAWASAcYjxAmI+T5EnAeIdFQnYwxHqwr6Z5s1g9ld20/Cj6AgrGBhkKva0/d1MUxBiFMxEjw7gGv5RyUWL+cfiCD/0I4KoULs04ensKkP7d716/OwQmVFAD/4yMGpLsJM7MJUiIGMGiDQwUBDYHR8DgocFG/54gQ0HRVUFQPnuoK6qvp0ec/u3767Dx+wfCDAXyKg2MWZELopBth1BJQAB6ujgY5RANNpRIbLuPnFETAaxgSUawYpVhawtdQV1XWN81hXu37ni3cfgssslwX4wQf/bqLD4f6uY6AdAaWDagYqdRi18qhrn/vmc61bRbIwZqAKmms9rw/Usbdn9+5Ld/VLBvzlhw/e17XtLIEcbzsG2SpgOQQkYe0wu7SDZqgRvS7Bcisq/oFVRAZqVlaQXDeRgKIDFtBNPd9Aved3d99zAC6hXDTg2dknx6sr3psJbbezZZBtB14TWApfAqmgyYPpnF07ZMIKeqLviymMoxIWY0VEJ6/zWNgsG5uGgTdANXBNwOf+4P4duy4Wx0UBnp3dP45jcJgsO6kgWxi2BLI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5jYrCUlZky5hSc3DHn0Jg1UiyZPX3GzMhYXs/SSsxNIA2skhOlHQZc98iVJYZj04wNDv7Vw0tuRVwS8IEDcyd7sdtMrjLfU9ACXLb76b5HIQzfAetSzjvA03NKXSEx92gHFHXM6c6x2pBHdb6wcd5DLVsQ+ZD29XiTWu8d+rkdLlDqC305GLx85obJjU8RuGl62bhJRxihk5H4zB6LpsoKNsYiRLH0eZGFkAY34KoYc25VyL5/WkipQXVjjtkxZud3yHybv3bgD+fhcgFzOTZ4+eQNnyDQWE/R69dGI5xCCY2knRKOc1JeqQBMX2aBlsavWbTr7AWakEAhJrEoMzBK+mnGUGK2NxYJ7NGFCjY9cWDuxHJ4EC6h/Nrd9+2l9dadbdpumDeX+ipjKDajmaKE0iVC1kkptUqnuFtoLbvvJNOyC4tUtG3ETWOxynssx3gf9R8Pm2r2EIXgxWC4JMBcfvXunTu6djhDi80TQ90aga2uv4Ivs0bfSZtHSQbLyMwSUekfruB0PF6ppMW8UVwAE9gebywlN66b3klilD2Pf31uDi6hLOvSi8u3X3t5sOGmT9FQqxqndk2iyZ50QKXjahPxqFrchL3WlQPS0Rkd9QgwG8DovujaUw4dlCnIqkiA+2NjzR2PH5x7Gi6xXLKFy3Lnb3xhOrRhL60tT3TFnwKIe/sejGDL6DpJgAXn+YSMx7iTk28O1z3SaUe8ZIc+hfCeJ772aB8us3wgwF4+d9cXplqIM6Hrprrgm9fSimSMaasE5JhGSG494iFMVKKgKvk7B94JT7D7NL2654m/v3ygXlYEsJfpu35rArCejm23jex7q/05D+qYOYHOORZcQSmFVYgpfunoY419ODP21UOH5lbsr9RWFHBZpqd3jsMVZybJyJTO4gbCPk6YJgjrRPZp+TFP7HaSMA9iFQfkyO/Awqr+SoIsyw8B5OTF820K0FQAAAAASUVORK5CYII=";
|
|
26991
|
-
|
|
26992
|
-
const useChargingPile = ({ viewBox, rotation = 0 }) => {
|
|
26993
|
-
const { svgElementDatas } = useSvgEditContext();
|
|
26994
|
-
const { sn } = useCommonContext();
|
|
26995
|
-
const items = React.useMemo(() => {
|
|
26996
|
-
if (!svgElementDatas || !viewBox)
|
|
26997
|
-
return [];
|
|
26998
|
-
const chargingPiles = svgElementDatas?.[exports.DataType.CHARGING_PILE];
|
|
26999
|
-
if (!chargingPiles)
|
|
27000
|
-
return [];
|
|
27001
|
-
const results = [];
|
|
27002
|
-
for (const element of chargingPiles) {
|
|
27003
|
-
const center = element.points?.[0];
|
|
27004
|
-
if (!center)
|
|
27005
|
-
continue;
|
|
27006
|
-
const size = element.style?.radius ? element.style.radius * 2 : 55;
|
|
27007
|
-
const direction = element?.direction || 0;
|
|
27008
|
-
const angle = (direction * 180) / Math.PI;
|
|
27009
|
-
const rotationDegree = 270 - angle; // 正东是正方向,需要处理下
|
|
27010
|
-
const actualRotation = rotationDegree - rotation;
|
|
27011
|
-
const relX = (center[0] - viewBox.x) / viewBox.width;
|
|
27012
|
-
const relY = (center[1] - viewBox.y) / viewBox.height;
|
|
27013
|
-
if (isFinite(relX) && isFinite(relY)) {
|
|
27014
|
-
results.push({
|
|
27015
|
-
leftPct: relX * 100,
|
|
27016
|
-
topPct: relY * 100,
|
|
27017
|
-
size,
|
|
27018
|
-
rotateDeg: actualRotation,
|
|
27019
|
-
imageSrc: chargingPileImage,
|
|
27020
|
-
});
|
|
27021
|
-
}
|
|
27022
|
-
}
|
|
27023
|
-
return results;
|
|
27024
|
-
}, [svgElementDatas, viewBox?.x, viewBox?.y, viewBox?.width, viewBox?.height, rotation, sn]);
|
|
27025
|
-
return items;
|
|
27026
|
-
};
|
|
27027
|
-
|
|
27028
|
-
const CharginPile = React.memo(({ viewBox, rotation = 0 }) => {
|
|
27029
|
-
const items = useChargingPile({ viewBox: viewBox || null, rotation });
|
|
27030
|
-
const containerStyle = React.useMemo(() => ({
|
|
27031
|
-
position: 'absolute',
|
|
27032
|
-
top: 0,
|
|
27033
|
-
left: 0,
|
|
27034
|
-
width: '100%',
|
|
27035
|
-
height: '100%',
|
|
27036
|
-
pointerEvents: 'none',
|
|
27037
|
-
zIndex: 750,
|
|
27038
|
-
}), []);
|
|
27039
|
-
return (jsxRuntime.jsx("div", { style: containerStyle, children: items?.map((item, idx) => (jsxRuntime.jsx("div", { className: "charging-pile", style: {
|
|
27040
|
-
position: 'absolute',
|
|
27041
|
-
width: item.size,
|
|
27042
|
-
height: item.size,
|
|
27043
|
-
left: `${item.leftPct}%`,
|
|
27044
|
-
top: `${item.topPct}%`,
|
|
27045
|
-
transform: `translate(-50%, -50%) rotate(${item.rotateDeg}deg)`,
|
|
27046
|
-
pointerEvents: 'auto',
|
|
27047
|
-
zIndex: 750,
|
|
27048
|
-
}, children: jsxRuntime.jsx("img", { src: item.imageSrc, style: { width: '100%', height: '100%', objectFit: 'contain', opacity: 1 } }) }, `pile-${idx}`))) }));
|
|
27049
|
-
});
|
|
27050
|
-
|
|
27051
27418
|
var css_248z$3 = ".index-module_container__7IatW {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n pointer-events: none;\n}\n\n.index-module_boundaryLabel__GDHFn {\n position: absolute;\n background-color: rgba(30, 30, 31, 0.6);\n color: rgb(255, 255, 255);\n padding: 6px;\n border-radius: 12px;\n font-size: 12px;\n font-weight: bold;\n max-width: 220px;\n pointer-events: auto;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);\n cursor: pointer;\n user-select: none;\n white-space: nowrap;\n}\n.index-module_boundaryLabel__GDHFn .index-module_isolatedIcon__1pRXN {\n position: absolute;\n width: 24px;\n height: 24px;\n top: -30px;\n left: 50%;\n transform: translateX(-50%);\n}\n\n.index-module_base__qy2SG {\n font-size: 14px;\n}\n\n.index-module_extended__0TMAt {\n margin-top: 6px;\n font-size: 11px;\n opacity: 0.9;\n border-top: 1px solid rgba(255, 255, 255, 0.2);\n padding-top: 6px;\n}";
|
|
27052
27419
|
var styles$3 = {"container":"index-module_container__7IatW","boundaryLabel":"index-module_boundaryLabel__GDHFn","isolatedIcon":"index-module_isolatedIcon__1pRXN","base":"index-module_base__qy2SG","extended":"index-module_extended__0TMAt"};
|
|
27053
27420
|
styleInject(css_248z$3);
|
|
@@ -28854,7 +29221,7 @@ const defaultMapConfig$1 = DEFAULT_STYLES;
|
|
|
28854
29221
|
// 地图渲染器组件
|
|
28855
29222
|
const MowerMapRenderer = React.forwardRef(({ sn, mowerIconConfig = {}, platform = exports.PlatformType.WEB, edger = false, unitType = UnitsType.Imperial, language = 'en', onlyRead = false, mapConfig,
|
|
28856
29223
|
// pathConfig,
|
|
28857
|
-
modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTimeData, antennaConfig, onError, className, style, googleMapInstance: _googleMapInstance, dragMap = false, canRotateMap = false, dragCallbacks, defaultTransform, debug: _debug = false, doodleList = [], editMap = false, unStructMapData, disabledObstacles = false, onHandleEnterRecord, onHandleCompleteRecord, onHandleStopRecord, onHandleDeleteElement, onSaveBoundaryData, onSaveMap, onEditInfoMapChange, onUpdateBoundary, heightOptions, globalHeight, onHandleEvent, onSelectElement, }, ref) => {
|
|
29224
|
+
modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTimeData, antennaConfig, onError, className, style, googleMapInstance: _googleMapInstance, dragMap = false, canRotateMap = false, dragCallbacks, defaultTransform, debug: _debug = false, doodleList = [], editMap = false, unStructMapData, disabledObstacles = false, onHandleEnterRecord, onHandleCompleteRecord, onHandleStopRecord, onHandleDeleteElement, onSaveBoundaryData, onSaveMap, onEditInfoMapChange, onUpdateBoundary, heightOptions, globalHeight, googleMapStaticApiKey, onHandleEvent, onSelectElement, onH5FirstSelectObstaclePoint, }, ref) => {
|
|
28858
29225
|
const [currentError, setCurrentError] = React.useState(null);
|
|
28859
29226
|
// const mapRef = useMap();
|
|
28860
29227
|
const [processStateIsMowing, setProcessStateIsMowing] = React.useState(false);
|
|
@@ -29012,48 +29379,6 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29012
29379
|
currentMowingPartitionId,
|
|
29013
29380
|
processStateIsMowing,
|
|
29014
29381
|
]);
|
|
29015
|
-
const commonValue = React.useMemo(() => {
|
|
29016
|
-
return {
|
|
29017
|
-
sn,
|
|
29018
|
-
editMap,
|
|
29019
|
-
platform,
|
|
29020
|
-
language,
|
|
29021
|
-
unitType,
|
|
29022
|
-
svgViewBox,
|
|
29023
|
-
heightOptions,
|
|
29024
|
-
globalHeight,
|
|
29025
|
-
mapConfig: mergedMapConfig,
|
|
29026
|
-
mapJson,
|
|
29027
|
-
drag: {
|
|
29028
|
-
x: defaultTransform?.x ?? 0,
|
|
29029
|
-
y: defaultTransform?.y ?? 0,
|
|
29030
|
-
rotate: (defaultTransform?.rotation ?? 0) + originNorthRotate,
|
|
29031
|
-
},
|
|
29032
|
-
mapRef,
|
|
29033
|
-
overlayScale,
|
|
29034
|
-
doodleList,
|
|
29035
|
-
mowerIconConfig,
|
|
29036
|
-
showStraddleBoundaryBorder,
|
|
29037
|
-
};
|
|
29038
|
-
}, [
|
|
29039
|
-
sn,
|
|
29040
|
-
editMap,
|
|
29041
|
-
platform,
|
|
29042
|
-
svgViewBox,
|
|
29043
|
-
unitType,
|
|
29044
|
-
language,
|
|
29045
|
-
heightOptions,
|
|
29046
|
-
globalHeight,
|
|
29047
|
-
mergedMapConfig,
|
|
29048
|
-
mapJson,
|
|
29049
|
-
defaultTransform,
|
|
29050
|
-
originNorthRotate,
|
|
29051
|
-
mapRef,
|
|
29052
|
-
overlayScale,
|
|
29053
|
-
doodleList,
|
|
29054
|
-
mowerIconConfig,
|
|
29055
|
-
showStraddleBoundaryBorder,
|
|
29056
|
-
]);
|
|
29057
29382
|
const mowerPositionData = React.useMemo(() => {
|
|
29058
29383
|
// realTimeData 中包含三个种类的数据,之需要实时坐标的数据即可。
|
|
29059
29384
|
// 在初始的状态按照正常图标进行渲染,所以构造一个基本在rtk桩的一个数据
|
|
@@ -29099,15 +29424,12 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29099
29424
|
const bounds = React.useMemo(() => {
|
|
29100
29425
|
if (!mapJson)
|
|
29101
29426
|
return null;
|
|
29102
|
-
|
|
29103
|
-
|
|
29104
|
-
|
|
29105
|
-
|
|
29106
|
-
return;
|
|
29427
|
+
const mapBoundsData = calculateMapBounds(mapJson);
|
|
29428
|
+
if (!mapBoundsData) {
|
|
29429
|
+
console.warn('Failed to calculate map bounds');
|
|
29430
|
+
return null;
|
|
29107
29431
|
}
|
|
29108
|
-
// 将自定义边界转换为Google Maps LatLngBounds(使用有效的GPS坐标)
|
|
29109
29432
|
const validBounds = getValidGpsBounds(mapJson, 0);
|
|
29110
|
-
// 地图数据中的坐标格式是 [longitude, latitude]
|
|
29111
29433
|
const [swLng0, swLat0] = validBounds.sw;
|
|
29112
29434
|
const [neLng0, neLat0] = validBounds.ne;
|
|
29113
29435
|
const [swX0, swY0] = proj4(WGS84, WEB_MERCATOR, [swLng0, swLat0]);
|
|
@@ -29118,11 +29440,58 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29118
29440
|
const neY = neY0 + drag.y;
|
|
29119
29441
|
const [swLng, swLat] = proj4(WEB_MERCATOR, WGS84, [swX, swY]);
|
|
29120
29442
|
const [neLng, neLat] = proj4(WEB_MERCATOR, WGS84, [neX, neY]);
|
|
29121
|
-
|
|
29122
|
-
new window.google.maps.LatLng(neLat, neLng) // 东北角
|
|
29123
|
-
);
|
|
29124
|
-
return googleBounds;
|
|
29443
|
+
return new window.google.maps.LatLngBounds(new window.google.maps.LatLng(swLat, swLng), new window.google.maps.LatLng(neLat, neLng));
|
|
29125
29444
|
}, [mapJson, drag.x, drag.y]);
|
|
29445
|
+
const commonValue = React.useMemo(() => {
|
|
29446
|
+
return {
|
|
29447
|
+
sn,
|
|
29448
|
+
editMap,
|
|
29449
|
+
platform,
|
|
29450
|
+
language,
|
|
29451
|
+
unitType,
|
|
29452
|
+
svgViewBox,
|
|
29453
|
+
heightOptions,
|
|
29454
|
+
globalHeight,
|
|
29455
|
+
mapConfig: mergedMapConfig,
|
|
29456
|
+
mapJson,
|
|
29457
|
+
drag: {
|
|
29458
|
+
x: defaultTransform?.x ?? 0,
|
|
29459
|
+
y: defaultTransform?.y ?? 0,
|
|
29460
|
+
rotate: (defaultTransform?.rotation ?? 0) + originNorthRotate,
|
|
29461
|
+
},
|
|
29462
|
+
mapRef,
|
|
29463
|
+
bounds,
|
|
29464
|
+
overlayScale,
|
|
29465
|
+
doodleList,
|
|
29466
|
+
mowerIconConfig,
|
|
29467
|
+
showStraddleBoundaryBorder,
|
|
29468
|
+
overlayLayout,
|
|
29469
|
+
googleMapStaticApiKey,
|
|
29470
|
+
onH5FirstSelectObstaclePoint,
|
|
29471
|
+
};
|
|
29472
|
+
}, [
|
|
29473
|
+
sn,
|
|
29474
|
+
editMap,
|
|
29475
|
+
platform,
|
|
29476
|
+
svgViewBox,
|
|
29477
|
+
unitType,
|
|
29478
|
+
language,
|
|
29479
|
+
heightOptions,
|
|
29480
|
+
globalHeight,
|
|
29481
|
+
mergedMapConfig,
|
|
29482
|
+
mapJson,
|
|
29483
|
+
defaultTransform,
|
|
29484
|
+
originNorthRotate,
|
|
29485
|
+
mapRef,
|
|
29486
|
+
bounds,
|
|
29487
|
+
overlayScale,
|
|
29488
|
+
doodleList,
|
|
29489
|
+
mowerIconConfig,
|
|
29490
|
+
showStraddleBoundaryBorder,
|
|
29491
|
+
overlayLayout,
|
|
29492
|
+
googleMapStaticApiKey,
|
|
29493
|
+
onH5FirstSelectObstaclePoint,
|
|
29494
|
+
]);
|
|
29126
29495
|
const fitBounds = React.useCallback((padding = 0) => {
|
|
29127
29496
|
if (!mapJson || !mapRef)
|
|
29128
29497
|
return null;
|