@fleet-frontend/mower-maps 0.2.5-beta.3 → 0.2.5-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -22523,15 +22523,25 @@ var index = {
22523
22523
  const CommonContext = createContext({
22524
22524
  sn: '',
22525
22525
  editMap: false,
22526
- mowerIconConfig: {},
22526
+ mowerIconConfig: {
22527
+ mapImgUrl: '',
22528
+ mapDisabledUrl: '',
22529
+ mapNoPositionUrl: '',
22530
+ },
22527
22531
  platform: PlatformType.WEB,
22528
22532
  svgViewBox: null,
22529
22533
  unitType: UnitsType.Metric,
22534
+ mapConfig: {},
22535
+ mapJson: null,
22536
+ drag: { x: 0, y: 0, rotate: 0, rotation: 0 },
22530
22537
  mapRef: null,
22538
+ bounds: null,
22531
22539
  globalHeight: 0,
22532
22540
  heightOptions: [],
22533
22541
  overlayScale: 1,
22534
22542
  showStraddleBoundaryBorder: true,
22543
+ googleMapStaticApiKey: '',
22544
+ onH5FirstSelectObstaclePoint: undefined,
22535
22545
  });
22536
22546
  const CommonContextProvider = CommonContext.Provider;
22537
22547
  const useCommonContext = () => useContext(CommonContext);
@@ -22963,10 +22973,6 @@ const DistanceLabels = ({ coordinates, createMode = false, editMode = false, com
22963
22973
  } }))] }));
22964
22974
  };
22965
22975
 
22966
- 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}";
22967
- var styles$5 = {"pointerCursor":"index-module_pointerCursor__Ee6pr","polygonPath":"index-module_polygonPath__PynOn","dragging":"index-module_dragging__xSFdO","notCreate":"index-module_notCreate__bFnkV"};
22968
- styleInject(css_248z$5);
22969
-
22970
22976
  var CreateStatus;
22971
22977
  (function (CreateStatus) {
22972
22978
  CreateStatus["CREATING"] = "creating";
@@ -23016,6 +23022,420 @@ const MapEditContext = createContext({
23016
23022
  const MapEditContextProvider = MapEditContext.Provider;
23017
23023
  const useMapEditContext = () => useContext(MapEditContext);
23018
23024
 
23025
+ 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+4P4duy4Wx0UBnp3dP45jcJgsO6kgWxi2BLIdYtcGBisWDqHFji3qMbzIlY2jLZgRyxaUbl1hJiwBzLWBdqBNo0fNR90MxhC279597/xyWJ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v7Vw0tuRVwS8IEDcyd7sdtMrjLfU9ACXLb76b5HIQzfAetSzjvA03NKXSEx92gHFHXM6c6x2pBHdb6wcd5DLVsQ+ZD29XiTWu8d+rkdLlDqC305GLx85obJjU8RuGl62bhJRxihk5H4zB6LpsoKNsYiRLH0eZGFkAY34KoYc25VyL5/WkipQXVjjtkxZud3yHybv3bgD+fhcgFzOTZ4+eQNnyDQWE/R69dGI5xCCY2knRKOc1JeqQBMX2aBlsavWbTr7AWakEAhJrEoMzBK+mnGUGK2NxYJ7NGFCjY9cWDuxHJ4EC6h/Nrd9+2l9dadbdpumDeX+ipjKDajmaKE0iVC1kkptUqnuFtoLbvvJNOyC4tUtG3ETWOxynssx3gf9R8Pm2r2EIXgxWC4JMBcfvXunTu6djhDi80TQ90aga2uv4Ivs0bfSZtHSQbLyMwSUekfruB0PF6ppMW8UVwAE9gebywlN66b3klilD2Pf31uDi6hLOvSi8u3X3t5sOGmT9FQqxqndk2iyZ50QKXjahPxqFrchL3WlQPS0Rkd9QgwG8DovujaUw4dlCnIqkiA+2NjzR2PH5x7Gi6xXLKFy3Lnb3xhOrRhL60tT3TFnwKIe/sejGDL6DpJgAXn+YSMx7iTk28O1z3SaUe8ZIc+hfCeJ772aB8us3wgwF4+d9cXplqIM6Hrprrgm9fSimSMaasE5JhGSG494iFMVKKgKvk7B94JT7D7NL2654m/v3ygXlYEsJfpu35rArCejm23jex7q/05D+qYOYHOORZcQSmFVYgpfunoY419ODP21UOH5lbsr9RWFHBZpqd3jsMVZybJyJTO4gbCPk6YJgjrRPZp+TFP7HaSMA9iFQfkyO/Awqr+SoIsyw8B5OTF820K0FQAAAAASUVORK5CYII=";
23026
+
23027
+ const useChargingPile = ({ viewBox, rotation = 0 }) => {
23028
+ const { svgElementDatas } = useSvgEditContext();
23029
+ const { sn } = useCommonContext();
23030
+ const items = useMemo(() => {
23031
+ if (!svgElementDatas || !viewBox)
23032
+ return [];
23033
+ const chargingPiles = svgElementDatas?.[DataType.CHARGING_PILE];
23034
+ if (!chargingPiles)
23035
+ return [];
23036
+ const results = [];
23037
+ for (const element of chargingPiles) {
23038
+ const center = element.points?.[0];
23039
+ if (!center)
23040
+ continue;
23041
+ const size = element.style?.radius ? element.style.radius * 2 : 55;
23042
+ const direction = element?.direction || 0;
23043
+ const angle = (direction * 180) / Math.PI;
23044
+ const rotationDegree = 270 - angle; // 正东是正方向,需要处理下
23045
+ const actualRotation = rotationDegree - rotation;
23046
+ const relX = (center[0] - viewBox.x) / viewBox.width;
23047
+ const relY = (center[1] - viewBox.y) / viewBox.height;
23048
+ if (isFinite(relX) && isFinite(relY)) {
23049
+ results.push({
23050
+ leftPct: relX * 100,
23051
+ topPct: relY * 100,
23052
+ size,
23053
+ rotateDeg: actualRotation,
23054
+ imageSrc: chargingPileImage,
23055
+ });
23056
+ }
23057
+ }
23058
+ return results;
23059
+ }, [svgElementDatas, viewBox?.x, viewBox?.y, viewBox?.width, viewBox?.height, rotation, sn]);
23060
+ return items;
23061
+ };
23062
+
23063
+ const CharginPile = React__default.memo(({ viewBox, rotation = 0, sizeScale = 1 }) => {
23064
+ const items = useChargingPile({ viewBox: viewBox || null, rotation });
23065
+ const containerStyle = useMemo(() => ({
23066
+ position: 'absolute',
23067
+ top: 0,
23068
+ left: 0,
23069
+ width: '100%',
23070
+ height: '100%',
23071
+ pointerEvents: 'none',
23072
+ zIndex: 750,
23073
+ }), []);
23074
+ return (jsx("div", { style: containerStyle, children: items?.map((item, idx) => (jsx("div", { className: "charging-pile", style: {
23075
+ position: 'absolute',
23076
+ width: item.size * sizeScale,
23077
+ height: item.size * sizeScale,
23078
+ left: `${item.leftPct}%`,
23079
+ top: `${item.topPct}%`,
23080
+ transform: `translate(-50%, -50%) rotate(${item.rotateDeg}deg)`,
23081
+ pointerEvents: 'auto',
23082
+ zIndex: 750,
23083
+ }, children: jsx("img", { src: item.imageSrc, style: { width: '100%', height: '100%', objectFit: 'contain', opacity: 1 } }) }, `pile-${idx}`))) }));
23084
+ });
23085
+
23086
+ const MAX_STATIC_SIZE = 640;
23087
+ const MAX_STATIC_MAP_RETRY = 3;
23088
+ const Magnifier = ({ visible, dragState, polygonPoints, fillColor = 'rgba(255, 122, 51, 0.1)', strokeColor = 'rgba(255, 122, 51, 1)', strokeWidth = 2, zoom = 3, size = 200, }) => {
23089
+ const { svgViewBox, mapRef, googleMapStaticApiKey, drag } = useCommonContext();
23090
+ const { svgElementDatas, svgRef } = useSvgEditContext();
23091
+ const { editMapInfo } = useMapEditContext();
23092
+ const [magnifierPosition, setMagnifierPosition] = useState({ x: 0, y: 0 });
23093
+ const [magnifierBoxSize, setMagnifierBoxSize] = useState({ width: size, height: size });
23094
+ // 本次拖拽中放大镜位置是否已完成初始化(未完成前隐藏,避免首帧闪动)
23095
+ const [isPlacementReady, setIsPlacementReady] = useState(false);
23096
+ // 放大镜所在侧边:true=右侧,false=左侧
23097
+ const [placeOnRight, setPlaceOnRight] = useState(true);
23098
+ // 仅在每次拖拽开始时初始化一次侧边
23099
+ const hasInitializedSideRef = useRef(false);
23100
+ const [mapImageFrame, setMapImageFrame] = useState(null);
23101
+ const [staticMapRetryCount, setStaticMapRetryCount] = useState(0);
23102
+ // 获取当前正在拖拽的禁区 ID
23103
+ const currentObstacleId = editMapInfo?.selectElement?.id;
23104
+ // 计算当前 SVG 单位到屏幕像素的比例(用于实现真正 1:1 预览)
23105
+ const getPixelScale = () => {
23106
+ //先拿 svgRef.getScreenCTM(),这是 SVG 到屏幕的变换矩阵(包含缩放/旋转/平移)
23107
+ const ctm = svgRef?.getScreenCTM?.();
23108
+ if (!ctm)
23109
+ return 1;
23110
+ // 使用向量长度计算缩放,兼容旋转矩阵
23111
+ // 用 Math.hypot(ctm.a, ctm.b) 算出 x 方向的实际缩放倍率(用向量长度是为了兼容旋转,不只看 a)
23112
+ const scaleX = Math.hypot(ctm.a, ctm.b);
23113
+ return Number.isFinite(scaleX) && scaleX > 0 ? scaleX : 1;
23114
+ };
23115
+ // 读取设备安全区(刘海/手势条)inset,兼容横屏 H5
23116
+ const getSafeAreaInsets = () => {
23117
+ const probe = document.createElement('div');
23118
+ probe.style.position = 'fixed';
23119
+ probe.style.left = '0';
23120
+ probe.style.top = '0';
23121
+ probe.style.width = '0';
23122
+ probe.style.height = '0';
23123
+ probe.style.visibility = 'hidden';
23124
+ probe.style.pointerEvents = 'none';
23125
+ probe.style.paddingTop = 'env(safe-area-inset-top)';
23126
+ probe.style.paddingRight = 'env(safe-area-inset-right)';
23127
+ probe.style.paddingBottom = 'env(safe-area-inset-bottom)';
23128
+ probe.style.paddingLeft = 'env(safe-area-inset-left)';
23129
+ document.body.appendChild(probe);
23130
+ const style = window.getComputedStyle(probe);
23131
+ const insets = {
23132
+ top: Number.parseFloat(style.paddingTop) || 0,
23133
+ right: Number.parseFloat(style.paddingRight) || 0,
23134
+ bottom: Number.parseFloat(style.paddingBottom) || 0,
23135
+ left: Number.parseFloat(style.paddingLeft) || 0,
23136
+ };
23137
+ document.body.removeChild(probe);
23138
+ return insets;
23139
+ };
23140
+ // 计算并获取放大镜底图:优先使用 Google Maps Static API,无图时走灰色背景兜底
23141
+ useEffect(() => {
23142
+ if (!visible || !dragState.currentPosition || !mapRef || !svgViewBox || !svgRef) {
23143
+ // console.log('[Magnifier] Skip static map effect: missing deps', {
23144
+ // visible,
23145
+ // hasCurrentPosition: Boolean(dragState.currentPosition),
23146
+ // hasMapRef: Boolean(mapRef),
23147
+ // hasSvgViewBox: Boolean(svgViewBox),
23148
+ // hasSvgRef: Boolean(svgRef),
23149
+ // });
23150
+ setMapImageFrame(null);
23151
+ setStaticMapRetryCount(0);
23152
+ return;
23153
+ }
23154
+ const mapDiv = mapRef.getDiv?.();
23155
+ // 获取 SVG 到屏幕的变换矩阵的逆矩阵
23156
+ const inverseCtm = svgRef.getScreenCTM?.()?.inverse?.();
23157
+ if (!mapDiv || !inverseCtm) {
23158
+ // console.log('[Magnifier] Skip static map effect: mapDiv/ctm missing', {
23159
+ // hasMapDiv: Boolean(mapDiv),
23160
+ // hasInverseCtm: Boolean(inverseCtm),
23161
+ // });
23162
+ setMapImageFrame(null);
23163
+ setStaticMapRetryCount(0);
23164
+ return;
23165
+ }
23166
+ const mapRect = mapDiv.getBoundingClientRect();
23167
+ const svgPoint = svgRef.createSVGPoint();
23168
+ // 只要有 key 就尝试 static api;请求失败时不截图,直接回退灰色背景
23169
+ if (googleMapStaticApiKey) {
23170
+ // console.log('[Magnifier] Background source: static api viewport snapshot');
23171
+ const mapBounds = mapRef.getBounds?.();
23172
+ if (!mapBounds) {
23173
+ // console.log('[Magnifier] Skip static map effect: mapBounds missing');
23174
+ setMapImageFrame(null);
23175
+ return;
23176
+ }
23177
+ const screenToSvg = (screenX, screenY) => {
23178
+ svgPoint.x = screenX;
23179
+ svgPoint.y = screenY;
23180
+ const p = svgPoint.matrixTransform(inverseCtm);
23181
+ return { x: p.x, y: p.y };
23182
+ };
23183
+ // 使用当前地图视口矩形四角,将屏幕坐标映射到 SVG 坐标,确保底图与主视口对齐
23184
+ const topLeftSvg = screenToSvg(mapRect.left, mapRect.top);
23185
+ const topRightSvg = screenToSvg(mapRect.right, mapRect.top);
23186
+ const bottomLeftSvg = screenToSvg(mapRect.left, mapRect.bottom);
23187
+ if (!topLeftSvg || !topRightSvg || !bottomLeftSvg) {
23188
+ setMapImageFrame(null);
23189
+ return;
23190
+ }
23191
+ // 把当前主地图可视区域尺寸,按比例压到 Static API 允许的最大尺寸以内(受 Static API 640 上限约束)),同时不改变宽高比。
23192
+ const mapWidth = Math.max(1, Math.round(mapRect.width));
23193
+ const mapHeight = Math.max(1, Math.round(mapRect.height));
23194
+ const shrinkRatio = Math.min(1, MAX_STATIC_SIZE / Math.max(mapWidth, mapHeight));
23195
+ const staticWidth = Math.max(1, Math.round(mapWidth * shrinkRatio));
23196
+ const staticHeight = Math.max(1, Math.round(mapHeight * shrinkRatio));
23197
+ const center = mapBounds.getCenter();
23198
+ const currentZoom = mapRef.getZoom() || 20;
23199
+ // 尺寸缩小后同步补偿 zoom,保持与当前主图一致的地理覆盖范围
23200
+ const zoomCompensation = Math.log2(shrinkRatio);
23201
+ const adjustedZoom = currentZoom + zoomCompensation;
23202
+ const staticZoom = Math.max(0, Math.min(Math.floor(adjustedZoom), 22));
23203
+ const staticMapUrl = `https://maps.googleapis.com/maps/api/staticmap?center=${center.lat()},${center.lng()}&zoom=${staticZoom}&size=${staticWidth}x${staticHeight}&maptype=satellite&key=${googleMapStaticApiKey}`;
23204
+ // 通过三角点推导静态图在 SVG 中的宽高和旋转角
23205
+ // Math.hypot(x, y) 等价于 sqrt(x*x + y*y),计算两点之间的距离
23206
+ const width = Math.hypot(topRightSvg.x - topLeftSvg.x, topRightSvg.y - topLeftSvg.y);
23207
+ const height = Math.hypot(bottomLeftSvg.x - topLeftSvg.x, bottomLeftSvg.y - topLeftSvg.y);
23208
+ // Math.atan2(y, x) 计算反正切值,返回 [-π, π] 弧度,*180/π 转换为角度
23209
+ const rotationDeg = (Math.atan2(topRightSvg.y - topLeftSvg.y, topRightSvg.x - topLeftSvg.x) * 180) / Math.PI;
23210
+ // Static API zoom 只能取整;额外补偿小数部分,避免底图视觉偏小
23211
+ // 在有旋转的坐标系里,做“以中心为锚点”的等比放大补偿。
23212
+ const fractionalZoomScale = Math.pow(2, adjustedZoom - staticZoom); //算出“还差多少缩放比例”。例子:adjustedZoom=19.6,staticZoom=19,差 0.6,比例是 2^0.6 ≈ 1.515。
23213
+ //把原始 width/height 乘这个比例,得到补偿后的尺寸。
23214
+ const compensatedWidth = width * fractionalZoomScale;
23215
+ const compensatedHeight = height * fractionalZoomScale;
23216
+ //尺寸变大后,多出来的宽/高的一半(要从两边均匀扩张)。
23217
+ const offsetAlongX = (compensatedWidth - width) / 2;
23218
+ const offsetAlongY = (compensatedHeight - height) / 2;
23219
+ //“右方向”单位向量(从左上指向右上),因为图可能旋转了,不能只按水平 x 轴算。
23220
+ const unitX = width > 0 ? (topRightSvg.x - topLeftSvg.x) / width : 1;
23221
+ const unitY = width > 0 ? (topRightSvg.y - topLeftSvg.y) / width : 0;
23222
+ //“下方向”单位向量(从左上指向左下),同理用于旋转场景。
23223
+ const unitDownX = height > 0 ? (bottomLeftSvg.x - topLeftSvg.x) / height : 0;
23224
+ const unitDownY = height > 0 ? (bottomLeftSvg.y - topLeftSvg.y) / height : 1;
23225
+ /**
23226
+ * 计算补偿后的新左上角:
23227
+ * 从原左上角沿“右方向”回退半个扩展量,再沿“下方向”回退半个扩展量。
23228
+ * 这样放大后仍以原区域中心为中心,不会放大后位置偏移。
23229
+ */
23230
+ const compensatedTopLeftX = topLeftSvg.x - unitX * offsetAlongX - unitDownX * offsetAlongY;
23231
+ const compensatedTopLeftY = topLeftSvg.y - unitY * offsetAlongX - unitDownY * offsetAlongY;
23232
+ setMapImageFrame({
23233
+ url: staticMapUrl,
23234
+ x: compensatedTopLeftX,
23235
+ y: compensatedTopLeftY,
23236
+ width: compensatedWidth,
23237
+ height: compensatedHeight,
23238
+ transform: `rotate(${rotationDeg} ${compensatedTopLeftX} ${compensatedTopLeftY})`,
23239
+ });
23240
+ }
23241
+ else {
23242
+ setMapImageFrame(null);
23243
+ setStaticMapRetryCount(0);
23244
+ // console.log('[Magnifier] Background source: gray fallback (no static api key)');
23245
+ }
23246
+ }, [
23247
+ visible,
23248
+ dragState.isDragging,
23249
+ mapRef,
23250
+ svgViewBox?.x,
23251
+ svgViewBox?.y,
23252
+ svgViewBox?.width,
23253
+ svgViewBox?.height,
23254
+ svgRef,
23255
+ size,
23256
+ zoom,
23257
+ googleMapStaticApiKey,
23258
+ staticMapRetryCount,
23259
+ ]);
23260
+ useLayoutEffect(() => {
23261
+ if (!visible) {
23262
+ hasInitializedSideRef.current = false;
23263
+ setIsPlacementReady(false);
23264
+ return;
23265
+ }
23266
+ const updatePosition = () => {
23267
+ const mapDiv = mapRef?.getDiv?.();
23268
+ const mapRect = mapDiv?.getBoundingClientRect?.();
23269
+ const boxSize = Math.max(120, Math.round(size));
23270
+ // 设置放大镜大小
23271
+ setMagnifierBoxSize({ width: boxSize, height: boxSize });
23272
+ const viewportWidth = window.innerWidth;
23273
+ const viewportHeight = window.innerHeight;
23274
+ const baseMargin = 10; // 放大镜与边缘的基础间距
23275
+ const insets = getSafeAreaInsets();
23276
+ const marginTop = Math.max(baseMargin, insets.top);
23277
+ const marginRight = Math.max(baseMargin, insets.right);
23278
+ const marginBottom = Math.max(baseMargin, insets.bottom);
23279
+ const marginLeft = Math.max(baseMargin, insets.left);
23280
+ const topY = mapRect ? mapRect.top + marginTop : marginTop;
23281
+ // 顶部位置限制在可视区与安全区内,避免横屏时被刘海/手势条遮挡
23282
+ const safeTopY = Math.max(marginTop, Math.min(topY, viewportHeight - boxSize - marginBottom));
23283
+ let nextPlaceOnRight = placeOnRight;
23284
+ const ctm = svgRef?.getScreenCTM?.();
23285
+ // 首次显示时先同步算出侧边,再基于该侧边定位,避免“先左后右/先右后左”闪动
23286
+ if (!hasInitializedSideRef.current && dragState.currentPosition && ctm && mapRect) {
23287
+ const p = svgRef.createSVGPoint();
23288
+ p.x = dragState.currentPosition[0];
23289
+ p.y = dragState.currentPosition[1];
23290
+ const dragScreenPoint = p.matrixTransform(ctm);
23291
+ const mapMidX = mapRect.left + mapRect.width / 2;
23292
+ nextPlaceOnRight = dragScreenPoint.x < mapMidX;
23293
+ setPlaceOnRight(nextPlaceOnRight);
23294
+ hasInitializedSideRef.current = true;
23295
+ }
23296
+ const rightX = mapRect
23297
+ ? mapRect.right - boxSize - marginRight
23298
+ : viewportWidth - boxSize - marginRight;
23299
+ const leftX = mapRect ? mapRect.left + marginLeft : marginLeft;
23300
+ const safeX = nextPlaceOnRight ? rightX : leftX;
23301
+ const boundedX = Math.max(marginLeft, Math.min(safeX, viewportWidth - boxSize - marginRight));
23302
+ // 放大镜出现后,仅当拖拽点进入放大镜区域时才切换到对侧
23303
+ if (dragState.currentPosition && ctm) {
23304
+ const p = svgRef.createSVGPoint();
23305
+ p.x = dragState.currentPosition[0];
23306
+ p.y = dragState.currentPosition[1];
23307
+ // 应用这个矩阵,变换成屏幕坐标
23308
+ const dragScreenPoint = p.matrixTransform(ctm);
23309
+ const pointInMagnifier = dragScreenPoint.x >= boundedX &&
23310
+ dragScreenPoint.x <= boundedX + boxSize &&
23311
+ dragScreenPoint.y >= safeTopY &&
23312
+ dragScreenPoint.y <= safeTopY + boxSize;
23313
+ if (pointInMagnifier) {
23314
+ setPlaceOnRight((prev) => !prev);
23315
+ return;
23316
+ }
23317
+ }
23318
+ setMagnifierPosition({
23319
+ x: boundedX,
23320
+ y: safeTopY,
23321
+ });
23322
+ setIsPlacementReady(true);
23323
+ };
23324
+ updatePosition();
23325
+ window.addEventListener('resize', updatePosition);
23326
+ return () => window.removeEventListener('resize', updatePosition);
23327
+ }, [
23328
+ visible,
23329
+ size,
23330
+ mapRef,
23331
+ svgRef,
23332
+ placeOnRight,
23333
+ dragState.currentPosition?.[0],
23334
+ dragState.currentPosition?.[1],
23335
+ ]);
23336
+ // 早期返回必须在所有 hooks 之后
23337
+ if (!visible || !dragState.currentPosition || !svgViewBox) {
23338
+ return null;
23339
+ }
23340
+ const [centerX, centerY] = dragState.currentPosition;
23341
+ // 计算放大区域范围(以拖拽点为中心)
23342
+ //effectiveZoom = Math.max(0.001, zoom * getPixelScale())
23343
+ // 得到实际放大倍率。
23344
+ // zoom 是你设置的放大倍数(比如 3)
23345
+ // getPixelScale() 是当前 SVG 到屏幕的缩放因子(地图本身被缩放时要补偿)
23346
+ // Math.max(0.001, ...) 是防止出现 0 或极小值导致除零/异常
23347
+ // magnifierWidthInSvg = magnifierBoxSize.width / effectiveZoom
23348
+ // magnifierHeightInSvg = magnifierBoxSize.height / effectiveZoom
23349
+ // 把“屏幕上放大镜框的像素尺寸”换算成“SVG 坐标里要截取的实际尺寸”
23350
+ // 放大倍率越大,分母越大,截取范围越小 => 看起来越放大
23351
+ const effectiveZoom = Math.max(0.001, zoom * getPixelScale());
23352
+ const magnifierWidthInSvg = magnifierBoxSize.width / effectiveZoom;
23353
+ const magnifierHeightInSvg = magnifierBoxSize.height / effectiveZoom;
23354
+ // 计算放大区域的 viewBox
23355
+ const magnifierViewBox = {
23356
+ x: centerX - magnifierWidthInSvg / 2,
23357
+ y: centerY - magnifierHeightInSvg / 2,
23358
+ width: magnifierWidthInSvg,
23359
+ height: magnifierHeightInSvg,
23360
+ };
23361
+ // 样式缩放采用“弱抵消”,避免随 zoom 变细,保证放大镜内点线清晰度
23362
+ const styleZoomFactor = Math.max(1, zoom * 0.4);
23363
+ // 生成多边形点字符串(仅用于当前编辑禁区)
23364
+ const polygonPointsString = polygonPoints.length > 0 ? polygonPoints.map((p) => `${p[0]},${p[1]}`).join(' ') : '';
23365
+ const actureRotate = drag?.rotate ?? drag?.rotation ?? 0;
23366
+ // 渲染放大镜内容
23367
+ const magnifierContent = (jsxs("div", { style: {
23368
+ position: 'fixed',
23369
+ left: `${magnifierPosition.x}px`,
23370
+ top: `${magnifierPosition.y}px`,
23371
+ width: `${magnifierBoxSize.width}px`,
23372
+ height: `${magnifierBoxSize.height}px`,
23373
+ borderRadius: '50%',
23374
+ border: `2px solid #fff`,
23375
+ // boxShadow: '0 4px 20px rgba(0, 0, 0, 0.3)',
23376
+ overflow: 'hidden',
23377
+ zIndex: 10000,
23378
+ pointerEvents: 'none',
23379
+ background: 'rgba(235, 236, 240, 1)',
23380
+ visibility: isPlacementReady ? 'visible' : 'hidden',
23381
+ }, children: [jsxs("svg", {
23382
+ // 逻辑尺寸:与放大镜容器一致
23383
+ width: magnifierBoxSize.width, height: magnifierBoxSize.height,
23384
+ // 核心放大参数:从整张 SVG 中裁剪出当前需要展示的区域(x y width height)
23385
+ viewBox: `${magnifierViewBox.x} ${magnifierViewBox.y} ${magnifierViewBox.width} ${magnifierViewBox.height}`,
23386
+ // 保持内容居中并铺满窗口;比例不一致时裁边,不留空白
23387
+ preserveAspectRatio: "xMidYMid slice", style: {
23388
+ // CSS 尺寸:让 SVG 完全填满放大镜容器
23389
+ width: '100%',
23390
+ height: '100%',
23391
+ }, children: [mapImageFrame && (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: () => {
23392
+ // console.log('✅ Map background loaded in magnifier');
23393
+ setStaticMapRetryCount(0);
23394
+ }, onError: (_e) => {
23395
+ // console.error('❌ Failed to load map background in magnifier', {
23396
+ // retryCount: staticMapRetryCount,
23397
+ // maxRetry: MAX_STATIC_MAP_RETRY,
23398
+ // url: mapImageFrame.url,
23399
+ // error: _e,
23400
+ // });
23401
+ setStaticMapRetryCount((prev) => {
23402
+ if (prev < MAX_STATIC_MAP_RETRY)
23403
+ return prev + 1;
23404
+ setMapImageFrame(null);
23405
+ return 0;
23406
+ });
23407
+ } }, `magnifier-static-map-${staticMapRetryCount}`)), svgElementDatas &&
23408
+ Object.keys(svgElementDatas).map((key) => {
23409
+ const elements = svgElementDatas[key] || [];
23410
+ // 过滤掉当前正在拖拽的禁区(稍后单独渲染拖拽后的状态)
23411
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23412
+ const filteredElements = key === DataType.OBSTACLE
23413
+ ? elements.filter((item) => item.id !== currentObstacleId)
23414
+ : elements;
23415
+ if (filteredElements.length === 0)
23416
+ return null;
23417
+ return (jsxs(GElement, { type: key, children: [key === 'channel' && jsx(ChannelClipPath, {}), filteredElements.map((item) => (
23418
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23419
+ jsx(SvgElement, { type: key, data: item }, item?.id)))] }, key));
23420
+ }), polygonPoints.length >= 3 && polygonPointsString && (jsxs(Fragment, { children: [jsx("polygon", { points: polygonPointsString, fill: fillColor, stroke: strokeColor, strokeWidth: (strokeWidth * 3.2) / styleZoomFactor, strokeOpacity: 1 }), polygonPoints.map((point, idx) => {
23421
+ const [x, y] = point;
23422
+ const isDraggingPoint = dragState.dragIndex === idx;
23423
+ const pointRadius = isDraggingPoint ? 14 / styleZoomFactor : 10 / styleZoomFactor;
23424
+ const pointFill = isDraggingPoint ? '#FFAB7E' : strokeColor;
23425
+ const pointStroke = isDraggingPoint ? strokeColor : '#fff';
23426
+ const pointStrokeWidth = isDraggingPoint
23427
+ ? 3.6 / styleZoomFactor
23428
+ : 3 / styleZoomFactor;
23429
+ return (jsx("circle", { cx: x, cy: y, r: pointRadius, fill: pointFill, stroke: pointStroke, strokeWidth: pointStrokeWidth }, idx));
23430
+ })] })), dragState.dragType === 'new' && dragState.edgeInfo && (jsx(Fragment, { children: 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}` }) }))] }), jsx(CharginPile, { viewBox: magnifierViewBox || null, rotation: actureRotate, sizeScale: Math.max(1, zoom) })] }));
23431
+ // 使用 Portal 渲染到 body,避免层级问题
23432
+ return ReactDOM.createPortal(magnifierContent, document.body);
23433
+ };
23434
+
23435
+ 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}";
23436
+ var styles$5 = {"pointerCursor":"index-module_pointerCursor__Ee6pr","polygonPath":"index-module_polygonPath__PynOn","dragging":"index-module_dragging__xSFdO","notCreate":"index-module_notCreate__bFnkV"};
23437
+ styleInject(css_248z$5);
23438
+
23019
23439
  /**
23020
23440
  * SVG 坐标转换工具函数
23021
23441
  */
@@ -23578,7 +23998,7 @@ const createPathData = (points) => {
23578
23998
  };
23579
23999
  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自动判断
23580
24000
  }) => {
23581
- const { overlayScale, unitType, showStraddleBoundaryBorder } = useCommonContext();
24001
+ const { overlayScale, unitType, showStraddleBoundaryBorder, platform, onH5FirstSelectObstaclePoint } = useCommonContext();
23582
24002
  const { onHandleEvent } = useMapEditContext();
23583
24003
  const { svgRef } = useSvgEditContext();
23584
24004
  const [dragState, setDragState] = useState({
@@ -23596,7 +24016,6 @@ const PolygonElement = ({ canSelect = false, points, fillColor = 'rgba(0, 0, 0,
23596
24016
  const [selectedVertexIndex, setSelectedVertexIndex] = useState(-1);
23597
24017
  const { checkCanNotCreateAtPosition } = useCheckElement();
23598
24018
  const { editMapInfo } = useMapEditContext();
23599
- const { platform } = useCommonContext();
23600
24019
  // delete icon可能被上一个点遮挡,因为delete在右上方,所以手动处理点让点按照顺时针渲染,这样delete icon层级就会高一些
23601
24020
  // 编辑的场景禁区的点最后一个和第一个相同,会导致一个位置渲染两个点,需要额外处理下
23602
24021
  const coordinates = useMemo(() => {
@@ -23829,9 +24248,14 @@ const PolygonElement = ({ canSelect = false, points, fillColor = 'rgba(0, 0, 0,
23829
24248
  // 开始长按计时器(1000ms)
23830
24249
  vertexLongPressTimerRef.current = window.setTimeout(() => {
23831
24250
  isVertexLongPressedRef.current = true;
23832
- setSelectedVertexIndex(index);
24251
+ setSelectedVertexIndex((prev) => {
24252
+ if (prev !== index) {
24253
+ onH5FirstSelectObstaclePoint?.();
24254
+ }
24255
+ return index;
24256
+ });
23833
24257
  }, 1000);
23834
- }, [editMode, createMode, completed, dragState.isDragging]);
24258
+ }, [editMode, createMode, completed, dragState.isDragging, onH5FirstSelectObstaclePoint]);
23835
24259
  const handleVertexLongPressEnd = useCallback(() => {
23836
24260
  if (vertexLongPressTimerRef.current !== null) {
23837
24261
  window.clearTimeout(vertexLongPressTimerRef.current);
@@ -24205,7 +24629,11 @@ const PolygonElement = ({ canSelect = false, points, fillColor = 'rgba(0, 0, 0,
24205
24629
  setHoverVertex(null);
24206
24630
  },
24207
24631
  }) }, `edge-${index}`));
24208
- }), 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)) &&
24632
+ }), 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(Magnifier, { visible: platform === PlatformType.H5 &&
24633
+ dragState.isDragging &&
24634
+ dragState.dragIndex !== -1 &&
24635
+ dragState.currentPosition !== null &&
24636
+ (editMode || (createMode && completed)), dragState: dragState, polygonPoints: renderCoordinates, fillColor: fillColor, strokeColor: strokeColor, strokeWidth: strokeWidth, zoom: 3, size: 130 }), 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)) &&
24209
24637
  renderCoordinates.map((coord, idx) => {
24210
24638
  // 判断当前顶点的状态
24211
24639
  const isLastPoint = idx === renderCoordinates.length - 1;
@@ -26967,67 +27395,6 @@ const MowerPosition = React__default.memo(({ editMap, mowerPositionData, viewBox
26967
27395
  }, children: jsx("img", { src: mowerImage, style: { width: '100%', height: '100%', objectFit: 'contain' } }) }) }));
26968
27396
  });
26969
27397
 
26970
- var chargingPileImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAABHHSURBVHgBtVtdjF3VdV7rnHPHtLbUkRrALwmDidSSgD1JqWQ3UMaNMaFq63FIKyoVZF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jKDajmaKE0iVC1kkptUqnuFtoLbvvJNOyC4tUtG3ETWOxynssx3gf9R8Pm2r2EIXgxWC4JMBcfvXunTu6djhDi80TQ90aga2uv4Ivs0bfSZtHSQbLyMwSUekfruB0PF6ppMW8UVwAE9gebywlN66b3klilD2Pf31uDi6hLOvSi8u3X3t5sOGmT9FQqxqndk2iyZ50QKXjahPxqFrchL3WlQPS0Rkd9QgwG8DovujaUw4dlCnIqkiA+2NjzR2PH5x7Gi6xXLKFy3Lnb3xhOrRhL60tT3TFnwKIe/sejGDL6DpJgAXn+YSMx7iTk28O1z3SaUe8ZIc+hfCeJ772aB8us3wgwF4+d9cXplqIM6Hrprrgm9fSimSMaasE5JhGSG494iFMVKKgKvk7B94JT7D7NL2654m/v3ygXlYEsJfpu35rArCejm23jex7q/05D+qYOYHOORZcQSmFVYgpfunoY419ODP21UOH5lbsr9RWFHBZpqd3jsMVZybJyJTO4gbCPk6YJgjrRPZp+TFP7HaSMA9iFQfkyO/Awqr+SoIsyw8B5OTF820K0FQAAAAASUVORK5CYII=";
26971
-
26972
- const useChargingPile = ({ viewBox, rotation = 0 }) => {
26973
- const { svgElementDatas } = useSvgEditContext();
26974
- const { sn } = useCommonContext();
26975
- const items = useMemo(() => {
26976
- if (!svgElementDatas || !viewBox)
26977
- return [];
26978
- const chargingPiles = svgElementDatas?.[DataType.CHARGING_PILE];
26979
- if (!chargingPiles)
26980
- return [];
26981
- const results = [];
26982
- for (const element of chargingPiles) {
26983
- const center = element.points?.[0];
26984
- if (!center)
26985
- continue;
26986
- const size = element.style?.radius ? element.style.radius * 2 : 55;
26987
- const direction = element?.direction || 0;
26988
- const angle = (direction * 180) / Math.PI;
26989
- const rotationDegree = 270 - angle; // 正东是正方向,需要处理下
26990
- const actualRotation = rotationDegree - rotation;
26991
- const relX = (center[0] - viewBox.x) / viewBox.width;
26992
- const relY = (center[1] - viewBox.y) / viewBox.height;
26993
- if (isFinite(relX) && isFinite(relY)) {
26994
- results.push({
26995
- leftPct: relX * 100,
26996
- topPct: relY * 100,
26997
- size,
26998
- rotateDeg: actualRotation,
26999
- imageSrc: chargingPileImage,
27000
- });
27001
- }
27002
- }
27003
- return results;
27004
- }, [svgElementDatas, viewBox?.x, viewBox?.y, viewBox?.width, viewBox?.height, rotation, sn]);
27005
- return items;
27006
- };
27007
-
27008
- const CharginPile = React__default.memo(({ viewBox, rotation = 0 }) => {
27009
- const items = useChargingPile({ viewBox: viewBox || null, rotation });
27010
- const containerStyle = useMemo(() => ({
27011
- position: 'absolute',
27012
- top: 0,
27013
- left: 0,
27014
- width: '100%',
27015
- height: '100%',
27016
- pointerEvents: 'none',
27017
- zIndex: 750,
27018
- }), []);
27019
- return (jsx("div", { style: containerStyle, children: items?.map((item, idx) => (jsx("div", { className: "charging-pile", style: {
27020
- position: 'absolute',
27021
- width: item.size,
27022
- height: item.size,
27023
- left: `${item.leftPct}%`,
27024
- top: `${item.topPct}%`,
27025
- transform: `translate(-50%, -50%) rotate(${item.rotateDeg}deg)`,
27026
- pointerEvents: 'auto',
27027
- zIndex: 750,
27028
- }, children: jsx("img", { src: item.imageSrc, style: { width: '100%', height: '100%', objectFit: 'contain', opacity: 1 } }) }, `pile-${idx}`))) }));
27029
- });
27030
-
27031
27398
  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}";
27032
27399
  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"};
27033
27400
  styleInject(css_248z$3);
@@ -28834,7 +29201,7 @@ const defaultMapConfig$1 = DEFAULT_STYLES;
28834
29201
  // 地图渲染器组件
28835
29202
  const MowerMapRenderer = forwardRef(({ sn, mowerIconConfig = {}, platform = PlatformType.WEB, edger = false, unitType = UnitsType.Imperial, language = 'en', onlyRead = false, mapConfig,
28836
29203
  // pathConfig,
28837
- 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) => {
29204
+ 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) => {
28838
29205
  const [currentError, setCurrentError] = useState(null);
28839
29206
  // const mapRef = useMap();
28840
29207
  const [processStateIsMowing, setProcessStateIsMowing] = useState(false);
@@ -28992,48 +29359,6 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
28992
29359
  currentMowingPartitionId,
28993
29360
  processStateIsMowing,
28994
29361
  ]);
28995
- const commonValue = useMemo(() => {
28996
- return {
28997
- sn,
28998
- editMap,
28999
- platform,
29000
- language,
29001
- unitType,
29002
- svgViewBox,
29003
- heightOptions,
29004
- globalHeight,
29005
- mapConfig: mergedMapConfig,
29006
- mapJson,
29007
- drag: {
29008
- x: defaultTransform?.x ?? 0,
29009
- y: defaultTransform?.y ?? 0,
29010
- rotate: (defaultTransform?.rotation ?? 0) + originNorthRotate,
29011
- },
29012
- mapRef,
29013
- overlayScale,
29014
- doodleList,
29015
- mowerIconConfig,
29016
- showStraddleBoundaryBorder,
29017
- };
29018
- }, [
29019
- sn,
29020
- editMap,
29021
- platform,
29022
- svgViewBox,
29023
- unitType,
29024
- language,
29025
- heightOptions,
29026
- globalHeight,
29027
- mergedMapConfig,
29028
- mapJson,
29029
- defaultTransform,
29030
- originNorthRotate,
29031
- mapRef,
29032
- overlayScale,
29033
- doodleList,
29034
- mowerIconConfig,
29035
- showStraddleBoundaryBorder,
29036
- ]);
29037
29362
  const mowerPositionData = useMemo(() => {
29038
29363
  // realTimeData 中包含三个种类的数据,之需要实时坐标的数据即可。
29039
29364
  // 在初始的状态按照正常图标进行渲染,所以构造一个基本在rtk桩的一个数据
@@ -29079,15 +29404,12 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
29079
29404
  const bounds = useMemo(() => {
29080
29405
  if (!mapJson)
29081
29406
  return null;
29082
- // 计算边界
29083
- const bounds = calculateMapBounds(mapJson);
29084
- if (!bounds) {
29085
- handleError('无法计算地图边界');
29086
- return;
29407
+ const mapBoundsData = calculateMapBounds(mapJson);
29408
+ if (!mapBoundsData) {
29409
+ console.warn('Failed to calculate map bounds');
29410
+ return null;
29087
29411
  }
29088
- // 将自定义边界转换为Google Maps LatLngBounds(使用有效的GPS坐标)
29089
29412
  const validBounds = getValidGpsBounds(mapJson, 0);
29090
- // 地图数据中的坐标格式是 [longitude, latitude]
29091
29413
  const [swLng0, swLat0] = validBounds.sw;
29092
29414
  const [neLng0, neLat0] = validBounds.ne;
29093
29415
  const [swX0, swY0] = proj4(WGS84, WEB_MERCATOR, [swLng0, swLat0]);
@@ -29098,11 +29420,58 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
29098
29420
  const neY = neY0 + drag.y;
29099
29421
  const [swLng, swLat] = proj4(WEB_MERCATOR, WGS84, [swX, swY]);
29100
29422
  const [neLng, neLat] = proj4(WEB_MERCATOR, WGS84, [neX, neY]);
29101
- const googleBounds = new window.google.maps.LatLngBounds(new window.google.maps.LatLng(swLat, swLng), // 西南角
29102
- new window.google.maps.LatLng(neLat, neLng) // 东北角
29103
- );
29104
- return googleBounds;
29423
+ return new window.google.maps.LatLngBounds(new window.google.maps.LatLng(swLat, swLng), new window.google.maps.LatLng(neLat, neLng));
29105
29424
  }, [mapJson, drag.x, drag.y]);
29425
+ const commonValue = useMemo(() => {
29426
+ return {
29427
+ sn,
29428
+ editMap,
29429
+ platform,
29430
+ language,
29431
+ unitType,
29432
+ svgViewBox,
29433
+ heightOptions,
29434
+ globalHeight,
29435
+ mapConfig: mergedMapConfig,
29436
+ mapJson,
29437
+ drag: {
29438
+ x: defaultTransform?.x ?? 0,
29439
+ y: defaultTransform?.y ?? 0,
29440
+ rotate: (defaultTransform?.rotation ?? 0) + originNorthRotate,
29441
+ },
29442
+ mapRef,
29443
+ bounds,
29444
+ overlayScale,
29445
+ doodleList,
29446
+ mowerIconConfig,
29447
+ showStraddleBoundaryBorder,
29448
+ overlayLayout,
29449
+ googleMapStaticApiKey,
29450
+ onH5FirstSelectObstaclePoint,
29451
+ };
29452
+ }, [
29453
+ sn,
29454
+ editMap,
29455
+ platform,
29456
+ svgViewBox,
29457
+ unitType,
29458
+ language,
29459
+ heightOptions,
29460
+ globalHeight,
29461
+ mergedMapConfig,
29462
+ mapJson,
29463
+ defaultTransform,
29464
+ originNorthRotate,
29465
+ mapRef,
29466
+ bounds,
29467
+ overlayScale,
29468
+ doodleList,
29469
+ mowerIconConfig,
29470
+ showStraddleBoundaryBorder,
29471
+ overlayLayout,
29472
+ googleMapStaticApiKey,
29473
+ onH5FirstSelectObstaclePoint,
29474
+ ]);
29106
29475
  const fitBounds = useCallback((padding = 0) => {
29107
29476
  if (!mapJson || !mapRef)
29108
29477
  return null;