-
- {{ item.sortNum }}
-
-

{
borderRadius: '3px'
}
}
-//sortNum路径点的样式
-const getSortNumStyle = (item, index) => {
- let leftNum = 0
- if (item.sortNum.toString().length === 1) {
- leftNum = 3
- } else if (item.sortNum.toString().length === 2) {
- leftNum = 7
- } else if (item.sortNum.toString().length === 3) {
- leftNum = 10
- } else if (item.sortNum.toString().length === 4) {
- leftNum = 14
- } else if (item.sortNum.toString().length === 5) {
- leftNum = 18
- } else if (item.sortNum.toString().length === 6) {
- leftNum = 21
- } else if (item.sortNum.toString().length === 7) {
- leftNum = 25
- } else if (item.sortNum.toString().length === 8) {
- leftNum = 28
- } else if (item.sortNum.toString().length === 9) {
- leftNum = 31
- }
- return {
- left: Number(item.locationWidePx) / 2 - leftNum + 'px',
- top: 6 + 'px'
- }
-}
+
//sortNum非路径点的样式
const getSortNumLocationStyle = (item, index) => {
let leftNum = 0
@@ -435,12 +388,15 @@ const filterTypeFun = (deviceType) => {
const convertActualCarToBrowser = (pointX, pointY) => {
const resolution = Number(imgBgObj.resolution)
const [originX, originY] = imgBgObj.origin.map(Number)
- const imgHeight = Number(imgBgObj.height)
+ // 使用原始高度计算,不使用可能已经被radio.value缩放过的imgBgObj.height
+ const originalHeight = props.isFullScreen
+ ? Number(imgBgObj.height) / Number(radio.value)
+ : Number(imgBgObj.height)
const carW = Number(carWidth.value)
const carH = Number(carHeight.value)
// 地图原点在左下角,y轴向上,需转换为浏览器坐标系(左上角,y轴向下)
- const yBottom = originY + imgHeight * resolution
+ const yBottom = originY + originalHeight * resolution
const xPx = Math.max(Number(pointX) - originX, 0) / resolution
const yPx = Math.max(yBottom - Number(pointY), 0) / resolution
@@ -480,15 +436,6 @@ const changeIsDrag = () => {
})
}
-// 获取曲线的路径
-const getCurvePath = (curve) => {
- let startPointX = Number(curve.startPointX) * radio.value
- let startPointY = Number(curve.startPointY) * radio.value
- let endPointX = Number(curve.endPointX) * radio.value
- let endPointY = Number(curve.endPointY) * radio.value
- return `M ${startPointX} ${startPointY} C ${curve.beginControlX * radio.value} ${curve.beginControlY * radio.value}, ${curve.endControlX * radio.value} ${curve.endControlY * radio.value}, ${endPointX} ${endPointY}`
-}
-
//放大缩小
const isSizeRadio = ref(1)
const changeSize = (type) => {
@@ -643,14 +590,12 @@ const initWebsocket = () => {
if (jsonMsg.type == 'map_push') {
requestAnimationFrame(() => {
let data = JSON.parse(jsonMsg.content)
- // console.log(data)
- // console.log(data, dayjs().format('HH:mm:ss SSS'))
-
let dataList = Object.entries(data).map(([key, value]) => ({
macAddress: key,
data: JSON.parse(value)
}))
testCarList.value = throttledUpdateCarList(testCarList.value, dataList, imgBgObj)
+ // console.log(data, dayjs().format('HH:mm:ss SSS'))
})
}
//告警信息
@@ -719,14 +664,12 @@ const mergeArraysWithoutDelete = (arr1, arr2) => {
// 优化车辆位置计算
const processCarData = (car, mapInfo) => {
+ // 保存原始分辨率信息用于调试
+ const originalResolution = mapInfo.resolution
const browserPos = convertActualCarToBrowser(car.data.pose2d.x, car.data.pose2d.y)
+
return {
...car,
- originWidth: mapInfo.width,
- originHeight: mapInfo.height,
- origin: mapInfo.origin,
- realX: browserPos.x,
- realY: browserPos.y,
robotNo: car.data.pose2d.robotNo,
style: {
left: browserPos.x * radio.value + 'px',
@@ -770,17 +713,14 @@ const computedRatio = () => {
if (props.isFullScreen) {
let width = getElementWidthByClass('index-page-container')
- testCarList.value.forEach((item) => {
- item.originWidth = imgBgObj.width
- item.originHeight = imgBgObj.height
- item.origin = imgBgObj.origin
- item.realX = convertActualCarToBrowser(item.data.pose2d.x, item.data.pose2d.y).x
- item.realY = convertActualCarToBrowser(item.data.pose2d.x, item.data.pose2d.y).y
- })
-
+ // 记录原始尺寸和新的缩放比例
+ const originalWidth = imgBgObj.width
+ const originalHeight = imgBgObj.height
radio.value = width / imgBgObj.width
- imgBgObj.width = imgBgObj.width * radio.value
- imgBgObj.height = imgBgObj.height * radio.value
+
+ // 只在视觉上应用缩放,但保留原始尺寸用于坐标计算
+ imgBgObj.width = originalWidth * radio.value
+ imgBgObj.height = originalHeight * radio.value
}
})
}
@@ -818,7 +758,7 @@ const getMapData = async (item) => {
imgBgObj.origin = yamlJson.origin
imgBgObj.resolution = yamlJson.resolution
//获取地图
- getMapDownloadPng(imgBgObj)
+ await getMapDownloadPng(imgBgObj)
//初始化Websocket
initWebsocket()
}