From 72d26075e9fa10816822d76bcbd1847aeb163aab Mon Sep 17 00:00:00 2001 From: zjc <1034206993@qq.com> Date: Sun, 26 Jan 2025 15:55:23 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E8=BD=A6?= =?UTF-8?q?=E8=88=B9gps=E8=BF=90=E5=8A=A8=E9=94=99=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/home/components/box-2.vue | 3 ++- src/views/scenic/components/box-2.vue | 17 ++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/views/home/components/box-2.vue b/src/views/home/components/box-2.vue index ddb40be..5406bb8 100644 --- a/src/views/home/components/box-2.vue +++ b/src/views/home/components/box-2.vue @@ -141,7 +141,7 @@ let emit = defineEmits(['switch-spot']) - const { map, initMap, addMarker } = useMap() + const { map, initMap, addMarker, clearOverlays } = useMap() let spotList = ref([]) @@ -169,6 +169,7 @@ () => [map.value, homeStore.carShipData], () => { if (map.value && homeStore.carShipData) { + clearOverlays() homeStore.carShipData?.car?.list.map((item) => { if (item.lng && item.lat) { addMarker(carIcon, [item.lng, item.lat], [36, 50]) diff --git a/src/views/scenic/components/box-2.vue b/src/views/scenic/components/box-2.vue index c87a4c7..3bcaeb2 100644 --- a/src/views/scenic/components/box-2.vue +++ b/src/views/scenic/components/box-2.vue @@ -326,7 +326,7 @@ import PubSub from 'pubsub-js' const scenicStore = useScenicStore() - const { initMap, addMarker } = useMap() + const { initMap, addMarker, clearOverlays } = useMap() const garageList = computed(() => { return scenicStore.stopCarData.headList @@ -383,20 +383,19 @@ watch( () => scenicStore.carShipData, (val) => { - if (val.car.list.length) { - setTimeout(() => { + setTimeout(() => { + clearOverlays() + if (val.car.list.length) { val.car.list.map((item) => { addMarker(carIcon, [item.lng, item.lat], [36, 50]) }) - }, 1000) - } - if (val.ship.list.length) { - setTimeout(() => { + } + if (val.ship.list.length) { val.ship.list.map((item) => { addMarker(shipIcon, [item.lng, item.lat], [36, 50]) }) - }, 1000) - } + } + }, 1000) }, { immediate: true } )