Browse Source

fix: 修复地图图例显示隐藏以及交互功能丢失问题

sequoia tungfang 21 hours ago
parent
commit
3eee7a7da4
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/components/TongzhouTrafficMap.vue

+ 4 - 1
src/components/TongzhouTrafficMap.vue

@@ -43,6 +43,7 @@ export default {
       searchQuery: '', // 搜索内容绑定
       activeLegends: [],
       legendConfig: [
+        { type: 'all_selected', label: '全选', color: '#e5e5e5' },
         { type: 'center_plan', label: '中心计划', color: '#32c5ff' },
         { type: 'trunk_coord', label: '干线协调', color: '#3ee68d' },
         { type: 'service_route', label: '勤务路线', color: '#ffcc33' },
@@ -104,9 +105,10 @@ export default {
         // 4. 等待地图加载完成后执行路径规划
         this.map.on('complete', () => {
           console.log("地图加载完成,开始绘制真实路网...");
+          this.initialized = true;
+          this.activeLegends = this.legendConfig.map(l => l.type);
           this.drawStaticRoutes();
         });
-
       } catch (err) {
         console.error('地图加载失败:', err);
       }
@@ -231,6 +233,7 @@ export default {
     },
 
     handleLegendClick(type) {
+      if (type === 'all_selected') return this.toggleAll();
       const isVisible = this.activeLegends.includes(type);
       this.activeLegends = isVisible ? this.activeLegends.filter(t => t !== type) : [...this.activeLegends, type];
       const group = this.overlayGroups[type];