From 8d7f9672e81f2c7e93e4a960359c8395eda9fb22 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 14 五月 2024 17:37:27 +0800
Subject: [PATCH] 1.修复点击折线图后高亮定位点错误问题; 2.新增“分析”按钮点击加载动画

---
 src/utils/map/animation.js |   63 ++++++++++++++++++++++---------
 1 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/src/utils/map/animation.js b/src/utils/map/animation.js
index ab13719..ed664c3 100644
--- a/src/utils/map/animation.js
+++ b/src/utils/map/animation.js
@@ -3,7 +3,7 @@
 import Layer from '@/utils/map/3dLayer';
 import sector from '@/utils/map/sector';
 import { map } from '@/utils/map/index_old';
-import util from "@/utils/map/util";
+import util from '@/utils/map/util';
 import car_driving from '@/assets/mipmap/car_driving.png';
 import boat_driving from '@/assets/mipmap/boat_driving.png';
 
@@ -11,7 +11,7 @@
   // 闈炶繛缁潗鏍囩偣鏈�澶ц窛绂�(绫�)
   this.maxD = 500;
   // 褰撳墠缁樺埗鐨勭洃娴嬪洜瀛愮被鍨�
-  this.factorType = 0;
+  this.factorType;
   this.factorDatas;
   // 杞藉叿绫诲瀷
   this.vehicleType = 0; // 0: 杞﹁締锛�1锛氭棤浜烘満锛�2锛氭棤浜鸿埞
@@ -21,6 +21,7 @@
   this._fps = this.frameAnimation.fps;
   // 缁樺埗鍥惧舰缂撳瓨
   this.moveViews = {};
+  this.clear = true;
 }
 
 MapAnimation.prototype = {
@@ -116,7 +117,7 @@
       var fData2 = factorDatas.getByIndex(i + 1, i + 2);
 
       // 璁$畻鍔ㄧ敾杞ㄨ抗
-      for (let i = 0; i < count - 1; i++) {
+      for (let i = 0; i < count; i++) {
         // path
         var length = d * (i + 1);
         if (isNaN(angle)) {
@@ -149,26 +150,25 @@
         animationData,
         function (data, index, count) {
           var length = data.length();
-          var start = length - count + 1;
+          var start = length - count;
           // 1.鑾峰彇鏁版嵁
           var d = data.getByIndex(0, start + index + 1);
-          var f = d.factor[that.factorType + 1 + ''];
+          var f = d.factor[that.factorType];
           // 2.缁樺埗鍥惧舰
           if (length > count || index > 0) {
             // 3d鍥惧舰
-            // var lnglat = d.lnglats_GD[d.lnglats_GD.length - 1];
             Layer.drawMesh(d, f);
-            // MapUtil.drawLine(lnglat)
-
             // 椋庡悜椋庨��
-            sector.drawSector(d, start + index);
-            // if (d.factor['17'] != undefined && d.factor['16'] != undefined) {
-            //   var windDir = d.factor['17'].datas;
-            //   windDir = windDir[windDir.length - 1].factorData;
-            //   var windSpeed = d.factor['16'].datas;
-            //   windSpeed = windSpeed[windSpeed.length - 1].factorData;
-            //   MapUtil.drawSector4(lnglat, windDir, windSpeed);
-            // }
+            sector.drawSectorAna(d, start + index);
+            // 鎵ц鐩戝惉鍑芥暟
+            if (typeof that.OnEachFrameCallback === 'function') {
+              that.OnEachFrameCallback(d, start + index);
+            }
+            // 缁樺埗3D鍥惧舰鏃讹紝鏈�灏戦渶瑕�2涓偣鎵嶅彲缁樺埗鍥惧舰
+            // 鍥犳姝ゅ绱㈠紩鍙埌鍊掓暟绗簩涓偣灏辩粨鏉燂紝姝ゆ椂鎵ц杩欐浠诲姟缁撴潫鐨勭洃鍚洖璋�
+            if (typeof that.OnEachTaskEndCallback === 'function') {
+              that.OnEachTaskEndCallback(d);
+            }
           }
 
           var pos = d.lnglats_GD[d.lnglats_GD.length - 1];
@@ -210,9 +210,27 @@
     this.start();
   },
 
+  /**
+   * 璁剧疆姣忎竴甯х殑鐩戝惉鍑芥暟
+   * @param {Function} callback
+   */
+  setOnEachFrameCallback(callback) {
+    this.OnEachFrameCallback = callback;
+  },
+
+  /**
+   * 璁剧疆姣忎竴娈典换鍔$粨鏉熺殑鐩戝惉鍑芥暟
+   * @param {Function} callback
+   */
+  setOnEachTaskEndCallback(callback) {
+    this.OnEachTaskEndCallback = callback;
+  },
+
   /*******************************鍔ㄧ敾浠诲姟閫昏緫 -start ******************************/
   start: function () {
-    sector.clearSector();
+    if (this.frameAnimation.isStop) {
+      sector.clearSector();
+    }
     this.frameAnimation.start();
   },
   changeSpeed: function (speed) {
@@ -224,12 +242,14 @@
   stop: function () {
     this.factorDatas = undefined;
     this.frameAnimation.addOnNextTasks(undefined);
+    // this.OnEachFrameCallback = undefined;
+    // this.OnEachTaskEndCallback = undefined;
     this.frameAnimation.stop();
+    this._clearMap();
   },
   setOnStopCallback: function (callback) {
     this.frameAnimation.setOnStopCallback(
       function () {
-        this._clearMap();
         callback();
       }.bind(this)
     );
@@ -252,6 +272,8 @@
   /*******************************鍔ㄧ敾浠诲姟閫昏緫 -end ******************************/
 
   _clearMap: function () {
+    if (!this.clear) return;
+
     var list = [];
     for (const key in this.moveViews) {
       list.push(this.moveViews[key]);
@@ -396,4 +418,7 @@
   }
 };
 
-export { MapAnimation };
+const realTimeMapAnimation = new MapAnimation();
+// realTimeMapAnimation.clear = false;
+
+export { realTimeMapAnimation, MapAnimation };

--
Gitblit v1.9.3