From dd2ff26f240bcb79de082f1de4eaf6d2c973b28e Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期一, 20 十月 2025 08:38:01 +0800
Subject: [PATCH] 2025.10.18 修改嫉妒报告生成逻辑
---
src/utils/map/line.js | 97 ++++++++++++++++++++++++++++++------------------
1 files changed, 61 insertions(+), 36 deletions(-)
diff --git a/src/utils/map/line.js b/src/utils/map/line.js
index 6c72bb5..a4395dd 100644
--- a/src/utils/map/line.js
+++ b/src/utils/map/line.js
@@ -2,13 +2,15 @@
import calculate from './calculate';
import { getHexColor } from '../color';
-var _polylineArr = [];
+var defaultPolylineArr = [];
+const lineMap = new Map();
function newPolyline(path, color) {
// eslint-disable-next-line no-undef
return new AMap.Polyline({
path: path,
- strokeStyle: 'solid',
+ // strokeStyle: 'solid',
+ strokeStyle: 'dashed',
isOutline: true,
borderWeight: 1,
outlineColor: 'white',
@@ -19,15 +21,24 @@
});
}
+function drawDirection(path) {
+ const polyline = newPolyline(path, '#ffd82a');
+ map.add(polyline);
+ return polyline;
+}
+
export default {
drawLine(fDatas, factor) {
+ if (defaultPolylineArr.length > 0) {
+ map.remove(defaultPolylineArr);
+ defaultPolylineArr = [];
+ }
+
const lnglats_GD = fDatas.lnglats_GD;
const colors = factor.colors;
- if (_polylineArr) {
- map.remove(_polylineArr);
- _polylineArr = [];
- }
+ // this.hideLine();
+
var path = calculate.parse2LngLat(lnglats_GD);
let sIndex = 0;
@@ -40,40 +51,31 @@
const lastC = colors[i - 1];
if (distance > 500 || c != lastC) {
let _path, _color;
+ _path = path.slice(sIndex, i);
+ _color = getHexColor(
+ lastC.map((v, index) => {
+ if (index < lastC.length - 1) {
+ return v * 255;
+ } else {
+ return v;
+ }
+ })
+ );
// 褰撲袱鐐硅窛绂昏秴杩�500鏃讹紝璁や负涓ょ偣涓嶈繛缁紝涓嶇粯鍒惰繛绾�
if (distance > 500) {
- _path = path.slice(sIndex, i);
- _color = getHexColor(
- lastC.map((v, index) => {
- if (index < lastC.length - 1) {
- return v * 255;
- } else {
- return v;
- }
- })
- );
+ sIndex = i;
} else {
- _path = path.slice(sIndex, i + 1);
- _color = getHexColor(
- c.map((v, index) => {
- if (index < c.length - 1) {
- return v * 255;
- } else {
- return v;
- }
- })
- );
+ sIndex = i - 1;
}
// 鍒涘缓鎶樼嚎瀹炰緥
const polyline = newPolyline(_path, _color);
- _polylineArr.push(polyline);
-
- sIndex = i;
+ defaultPolylineArr.push(polyline);
}
}
- if (sIndex == 0) {
- const c = colors[sIndex];
+ if (sIndex < path.length - 1) {
+ const c = colors[path.length - 1];
+ const _path = path.slice(sIndex, path.length);
const _color = getHexColor(
c.map((v, index) => {
if (index < c.length - 1) {
@@ -83,11 +85,34 @@
}
})
);
- const polyline = newPolyline(path, _color);
- _polylineArr.push(polyline);
+ const polyline = newPolyline(_path, _color);
+ defaultPolylineArr.push(polyline);
}
// 灏嗘姌绾挎坊鍔犺嚦鍦板浘瀹炰緥
- map.add(_polylineArr);
- return _polylineArr;
- }
+ map.add(defaultPolylineArr);
+ return defaultPolylineArr;
+ },
+
+ drawTagLine(tag, fDatas, factor) {
+ if (lineMap.has(tag)) {
+ const _polylineArr = lineMap.get(tag);
+ map.add(_polylineArr);
+ } else {
+ const _polylineArr = this.drawLine(fDatas, factor);
+ lineMap.set(tag, _polylineArr);
+ }
+ },
+
+ hideLine(tag) {
+ if (tag && lineMap.has(tag)) {
+ const _polylineArr = lineMap.get(tag);
+ map.remove(_polylineArr);
+ } else {
+ lineMap.forEach((v) => {
+ map.remove(v);
+ });
+ }
+ },
+
+ drawDirection
};
--
Gitblit v1.9.3