|
|
@@ -70,9 +70,32 @@ export default {
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
if (this.infoWindow) this.infoWindow.close();
|
|
|
- this.polylines.forEach(p => p.setMap(null));
|
|
|
- Object.values(this.routeGroups).forEach(g => g.setMap(null));
|
|
|
- if (this.map) this.map.destroy();
|
|
|
+
|
|
|
+ // 1. 清理普通的 polylines 数组
|
|
|
+ this.polylines.forEach(p => {
|
|
|
+ if (p && typeof p.setMap === 'function') p.setMap(null);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 2. 核心修改:清理 routeGroups
|
|
|
+ Object.values(this.routeGroups).forEach(g => {
|
|
|
+ if (!g) return;
|
|
|
+
|
|
|
+ if (Array.isArray(g)) {
|
|
|
+ // 如果是数组(当前的逻辑),遍历每个成员销毁
|
|
|
+ g.forEach(overlay => {
|
|
|
+ if (overlay && typeof overlay.setMap === 'function') {
|
|
|
+ overlay.setMap(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (typeof g.setMap === 'function') {
|
|
|
+ // 如果是旧版的 OverlayGroup 或单个覆盖物
|
|
|
+ g.setMap(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (this.map) {
|
|
|
+ this.map.destroy();
|
|
|
+ }
|
|
|
},
|
|
|
computed: {
|
|
|
// 判断是否所有图例都在激活列表中
|