From 2764037d640b06de16f630b6a0f22d2260487b87 Mon Sep 17 00:00:00 2001
From: zjc <1034206993@qq.com>
Date: Sun, 13 Apr 2025 16:58:24 +0800
Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E8=BD=A6=E8=88=B9?=
=?UTF-8?q?=E4=BD=8D=E7=BD=AE=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/scenic/components/big-map.vue | 123 ++++++++++----------
src/views/scenic/components/box-2.vue | 145 +++++++++++-------------
2 files changed, 134 insertions(+), 134 deletions(-)
diff --git a/src/views/scenic/components/big-map.vue b/src/views/scenic/components/big-map.vue
index 80b1409..f11a808 100644
--- a/src/views/scenic/components/big-map.vue
+++ b/src/views/scenic/components/big-map.vue
@@ -151,17 +151,15 @@
if (map.value && modelValue.value) {
// 109.645729,31.041203
if (carOverlays.value.length > 0) {
- // 更新车辆marker位置
- let flag = false
for (let i = 0; i < carOverlays.value.length; i++) {
- if (flag) break
for (let j = 0; j < props.carList.length; j++) {
- if (carOverlays.value[i].sim == props.carList[j].sim) {
+ let carOverlay = carOverlays.value[i]
+ let car = props.carList[j]
+ if (carOverlay && car && carOverlays.value[i].sim == car.sim) {
carOverlays.value[i].setPosition({
- lng: props.carList[j].lng,
- lat: props.carList[j].lat
+ lng: car.lng,
+ lat: car.lat
})
- flag = true
continue
}
}
@@ -173,15 +171,12 @@
infoBox.value &&
props.carList[i].sim == currentMarker.value.sim
) {
+ console.log('变化了')
+ let { lng, lat } = props.carList[i]
infoBox.value.setContent(setHtml(props.carList[i]))
- infoBox.value.setPosition({
- lng: props.carList[i].lng,
- lat: props.carList[i].lat
- })
- currentMarker.value.setPosition({
- lng: props.carList[i].lng,
- lat: props.carList[i].lat
- })
+ infoBox.value.setPosition(new BMapGL.Point(lng, lat))
+ currentMarker.value.setPosition(new BMapGL.Point(lng, lat))
+ map.value.centerAndZoom(new BMapGL.Point(lng, lat), 15)
break
}
}
@@ -199,7 +194,9 @@
}
marker.value.addEventListener('click', (e) => {
e.sim = e.target.sim
- currentMarker.value = e
+ currentMarker.value = carOverlays.value.find(
+ (item) => item && item.sim == e.target.sim
+ )
let obj = props.carList.find((item) => item.sim == e.target.sim)
setInfoBox(e.latLng, obj)
})
@@ -208,18 +205,18 @@
}
})
}
+
if (shipOverlays.value.length > 0) {
// 更新船只marker位置
- let flag = false
for (let i = 0; i < shipOverlays.value.length; i++) {
- if (flag) break
for (let j = 0; j < props.shipList.length; j++) {
- if (shipOverlays.value[i].sim == props.shipList[j].sim) {
+ let shipOverlay = shipOverlays.value[i]
+ let ship = props.shipList[j]
+ if (shipOverlay && ship && shipOverlay.sim == ship.sim) {
shipOverlays.value[i].setPosition({
- lng: props.shipList[j].lng,
- lat: props.shipList[j].lat
+ lng: ship.lng,
+ lat: ship.lat
})
- flag = true
continue
}
}
@@ -231,11 +228,11 @@
infoBox.value &&
props.shipList[i].sim == currentMarker.value.sim
) {
+ let { lng, lat } = props.carList[i]
infoBox.value.setContent(setHtml(props.shipList[i]))
- infoBox.value.setPosition({
- lng: props.shipList[i].lng,
- lat: props.shipList[i].lat
- })
+ infoBox.value.setPosition(new BMapGL.Point(lng, lat))
+ currentMarker.value.setPosition(new BMapGL.Point(lng, lat))
+ map.value.centerAndZoom(new BMapGL.Point(lng, lat), 15)
break
}
}
@@ -252,7 +249,9 @@
addMarker(shipStopIcon, [item.lng, item.lat], [36, 50])
}
marker.value.addEventListener('click', (e) => {
- currentMarker.value = e
+ currentMarker.value = carOverlays.value.find(
+ (item) => item && item.sim == e.target.sim
+ )
let obj = props.shipList.find((item) => item.sim == e.target.sim)
setInfoBox(e.latLng, obj)
})
@@ -275,34 +274,40 @@
}
const setHtml = (data) => {
- data.gpsTime = timestampToYMD(data?.gpsTime)
- //
18723232323
- //
3.01KM
- let html = `
-
${data?.licenseNumber}
-
-
-
-
${data?.contactUser}
-
${data?.contactTel}
-
-
-
${data?.gpsTime}
-
-
-
${data?.speed}KM
-
-
-
${data?.lng},${data?.lat}
-
-
-
${data?.address}
-
-
`
- return html
+ return `
+
${data?.licenseNumber}
+
+
+
+
+

+
${data?.contactUser}
+
+
${data?.contactTel}
+
+
+
+
+

+
${timestampToYMD(data?.gpsTime)}
+
+
+
${data?.speed}KM
+
+
+
+
${data?.lng},${data?.lat}
+
+
+
${data?.address}
+
+
`
}
const setInfoBox = (e, data) => {
@@ -315,17 +320,21 @@
align: INFOBOX_AT_TOP,
offset: new BMapGL.Size(0, 20)
})
+ infoBox.value.addEventListener('close', () => {
+ currentMarker.value = null
+ })
} else {
if (lastInfoBox.value) lastInfoBox.value?.close()
infoBox.value.setContent(setHtml(data))
lastInfoBox.value = infoBox.value
}
infoBox.value.open(e)
+ map.value.centerAndZoom(e, 15)
}
const handleItem = (e, index) => {
current.value = index
- currentMarker.value = carOverlays.value.find((item) => item.sim == e.sim)
+ currentMarker.value = carOverlays.value.find((item) => item && item.sim == e.sim)
setInfoBox(new BMapGL.Point(e.lng, e.lat), e)
}
@@ -339,6 +348,7 @@
carOverlays.value = []
shipOverlays.value = []
map.value = null
+ current.value = ''
infoBox.value = null
lastInfoBox.value = null
modelValue.value = false
@@ -366,7 +376,6 @@
onMounted(() => {
scenicChange = PubSub.subscribe('scenicChange', (msg, data) => {
- // console.log(data,'99999999999999999999999999999999999999')
scenicSpotId.value = data.scenicSpotId
lat.value = data.lat
lng.value = data.lng
diff --git a/src/views/scenic/components/box-2.vue b/src/views/scenic/components/box-2.vue
index f8d9429..df30caa 100644
--- a/src/views/scenic/components/box-2.vue
+++ b/src/views/scenic/components/box-2.vue
@@ -101,19 +101,16 @@
-
-
- 暂无数据
-
-
+
+ 暂无数据
@@ -145,10 +142,10 @@
-
+
{
- router.push('/traffic')
- // traMapShow.value = true
+ const hanldeLookMap = () => {
+ router.push('/traffic')
+ // traMapShow.value = true
}
- const handleToWorkOrder = ()=>{
- router.push('/workOrder')
+ const handleToWorkOrder = () => {
+ router.push('/workOrder')
}
const garageList = computed(() => {
return scenicStore.stopCarData.headList
@@ -360,8 +357,8 @@
return pre + cur.count
}, 0)
})
- const stopCarDataLists = computed(()=>{
- return scenicStore.stopCarData.dataLists
+ const stopCarDataLists = computed(() => {
+ return scenicStore.stopCarData.dataLists
})
const carTotal = computed(() => {
return dataLists.value.reduce((pre, cur) => {
@@ -391,44 +388,41 @@
})
let dataLists = ref([])
watch(
- ()=>scenicStore.stopCarData.dataLists,
- (val) =>{
- console.log(val.length,'watch 监听')
- if(val.length){
- dataLists.value = val
- }else{
- dataLists.value = []
- }
- },
- { immediate: true }
+ () => scenicStore.stopCarData.dataLists,
+ (val) => {
+ console.log(val.length, 'watch 监听')
+ if (val.length) {
+ dataLists.value = val
+ } else {
+ dataLists.value = []
+ }
+ },
+ { immediate: true }
)
let headList = ref([])
watch(
- ()=>scenicStore.secureData.headList,
- (val) =>{
- if(val.length){
- headList.value = scenicStore.secureData.headList
- }else{
- headList.value = []
- }
- },
- { immediate: true }
+ () => scenicStore.secureData.headList,
+ (val) => {
+ if (val.length) {
+ headList.value = scenicStore.secureData.headList
+ } else {
+ headList.value = []
+ }
+ },
+ { immediate: true }
)
watch(
() => scenicStore.carShipData,
(val) => {
setTimeout(() => {
if (carOverlays.value.length > 0) {
- let flag = false
for (let i = 0; i < carOverlays.value.length; i++) {
- if (flag) break
for (let j = 0; j < val.car.list.length; j++) {
if (carOverlays.value[i].sim == val.car.list[j].sim) {
carOverlays.value[i].setPosition({
lng: val.car.list[j].lng,
lat: val.car.list[j].lat
})
- flag = true
continue
}
}
@@ -449,16 +443,13 @@
}
if (shipOverlays.value.length > 0) {
- let flag = false
for (let i = 0; i < shipOverlays.value.length; i++) {
- if (flag) break
for (let j = 0; j < val.ship.list.length; j++) {
if (carOverlays.value[i].sim == val.ship.list[j].sim) {
carOverlays.value[i].setPosition({
lng: val.ship.list[j].lng,
lat: val.ship.list[j].lat
})
- flag = true
continue
}
}
@@ -484,8 +475,8 @@
onMounted(() => {
scenicChange = PubSub.subscribe('scenicChange', (msg, data) => {
- latitude.value = data.lat
- longitude.value = data.lng
+ latitude.value = data.lat
+ longitude.value = data.lng
carOverlays.value = []
shipOverlays.value = []
initMap('car-ship', data.lng, data.lat, 15)
@@ -497,32 +488,32 @@