From 57c370b2dd54a8c4f65a04ebdf96221c047fe6e8 Mon Sep 17 00:00:00 2001 From: wuxw <928255095@qq.com> Date: Thu, 30 Oct 2025 14:51:12 +0800 Subject: [PATCH] v1.9 优化巡检地图展示问题 --- src/components/inspection/inspectionRouteMap.vue | 18 ++++++++++++++++++ src/components/inspection/inspectionTaskMap.vue | 21 +++++++++++++++++++++ src/components/inspection/pointPlan.vue | 2 +- src/components/inspection/pointRoute.vue | 7 +++---- src/components/inspection/pointTask.vue | 6 +++--- src/components/inspection/pointTaskDetail.vue | 2 +- src/views/inspection/inspectionItemManageList.vue | 4 ++-- src/views/inspection/inspectionItemTitleManageList.vue | 2 +- src/views/inspection/inspectionPointList.vue | 1 - src/views/inspection/inspectionRouteList.vue | 1 - 10 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/components/inspection/inspectionRouteMap.vue b/src/components/inspection/inspectionRouteMap.vue index 41dfa03..fb18552 100644 --- a/src/components/inspection/inspectionRouteMap.vue +++ b/src/components/inspection/inspectionRouteMap.vue @@ -29,6 +29,24 @@ export default { }, initMap() { + // 若已有地图或图层,先清理避免重复初始化 + if (this.markerLayer) { + this.markerLayer.setMap(null) + this.markerLayer = null + } + if (this.labelLayer) { + this.labelLayer.setMap(null) + this.labelLayer = null + } + if (this.polylineLayer) { + this.polylineLayer.setMap(null) + this.polylineLayer = null + } + if (this.map) { + this.map.destroy() + this.map = null + } + // 默认中心点(北京) const center = new window.TMap.LatLng(39.916527, 116.397128) diff --git a/src/components/inspection/inspectionTaskMap.vue b/src/components/inspection/inspectionTaskMap.vue index 4d586ad..e9b1883 100644 --- a/src/components/inspection/inspectionTaskMap.vue +++ b/src/components/inspection/inspectionTaskMap.vue @@ -26,12 +26,33 @@ export default { }, methods: { loadData(task) { + console.log('loadData',task) this.initMap() this.loadTask(task) }, initMap() { + // 若已有地图或图层,先清理避免重复初始化 + if (this.markerLayer) { + this.markerLayer.setMap(null) + this.markerLayer = null + } + if (this.labelLayer) { + this.labelLayer.setMap(null) + this.labelLayer = null + } + if (this.polylineLayer) { + this.polylineLayer.setMap(null) + this.polylineLayer = null + } + if (this.map) { + this.map.destroy() + this.map = null + } + console.log('initMap',this.map) + // 默认中心点(北京) const center = new window.TMap.LatLng(39.916527, 116.397128) + console.log('center',center) // 创建地图实例 this.map = new window.TMap.Map(document.getElementById('inspectionTaskMap'), { diff --git a/src/components/inspection/pointPlan.vue b/src/components/inspection/pointPlan.vue index 31e902a..c0f5537 100644 --- a/src/components/inspection/pointPlan.vue +++ b/src/components/inspection/pointPlan.vue @@ -129,7 +129,7 @@ export default {