diff --git a/src/components/inspection/inspectionRouteMap.vue b/src/components/inspection/inspectionRouteMap.vue index 41dfa039b..fb18552bb 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 4d586addd..e9b18832d 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 31e902a25..c0f5537d4 100644 --- a/src/components/inspection/pointPlan.vue +++ b/src/components/inspection/pointPlan.vue @@ -129,7 +129,7 @@ export default {