瀏覽代碼

添加按4:3:3比例提取并存储状态坐标到localStorage的功能

sequoia tungfang 1 月之前
父節點
當前提交
7edde5b1c8
共有 1 個文件被更改,包括 35 次插入0 次删除
  1. 35 0
      src/components/TongzhouTrafficMap.vue

+ 35 - 0
src/components/TongzhouTrafficMap.vue

@@ -261,6 +261,8 @@ export default {
         this.map.on('complete', () => {
           if (!this._isDestroyed) {
             this.drawStaticRoutes();
+            // 临时方案,实际项目中删除 按4:3:3比例提取故障、离线、降级坐标点并存储到localStorage
+            this.storeStatusCoordsToLocalStorage();
           }
         });
       } catch (err) {
@@ -514,6 +516,39 @@ export default {
 
     toggleLegend() {
       this.legendVisible = !this.legendVisible;
+    },
+
+    // 按4:3:3比例提取故障、离线、降级坐标点并存储到localStorage
+    storeStatusCoordsToLocalStorage() {
+      // 故障、离线、降级坐标点(按4:3:3比例)
+      const faultCoords = [
+        [116.723317, 39.907606],
+        [116.703624, 39.89801],
+        [116.661252, 39.924948],
+        [116.708958, 39.899609]
+      ];
+      
+      const offlineCoords = [
+        [116.677855, 39.895636],
+        [116.656673, 39.856063],
+        [116.656485, 39.90118]
+      ];
+      
+      const degradedCoords = [
+        [116.713356, 39.952856],
+        [116.665391, 39.934546],
+        [116.697784, 39.891312]
+      ];
+
+      // 组合成10个元素的数组
+      const statusCoords = [...faultCoords, ...offlineCoords, ...degradedCoords];
+
+      // 存储到localStorage
+      statusCoords.forEach((coords, index) => {
+        localStorage.setItem(`pos${index + 1}`, coords.join(','));
+      });
+
+      console.log('状态坐标已存储到localStorage');
     }
   }
 };