jinx 2 лет назад
Родитель
Сommit
6192b939fe
1 измененных файлов с 33 добавлено и 0 удалено
  1. 33 0
      src/graphic/ListenLayer.js

+ 33 - 0
src/graphic/ListenLayer.js

@@ -843,6 +843,38 @@ export default class ListenLayer {
     };
     const svgs = dataService.getSVGs();
 
+    /**-----暴力做法 */
+    for (const svgId in svgs) {
+      if (svgId == exceptSVGId) {
+        continue;
+      }
+      const svg = dataService.getSVG(svgId);
+      for (let i = 0; i < svg.points.length; ++i) {
+        let distance = this.getDistance(position, svg.points[i]);
+        // if (!svgInfo.svgId && distance < Constant.minAdsorbPix / 5) { //改大图例四个点的选择范围
+        if (!svgInfo.svgId && distance < Constant.minAdsorbPix / 2) {
+          svgInfo = {
+            svgId: svgId,
+            distance: distance,
+            type: VectorType.SVG,
+            index: i,
+            x: position.x,
+            y: position.y,
+          };
+        } else if (svgInfo.svgId && distance < svgInfo.distance) {
+          svgInfo = {
+            svgId: svgId,
+            distance: distance,
+            type: VectorType.SVG,
+            index: i,
+            x: position.x,
+            y: position.y,
+          };
+        }
+      }
+    }
+    /**----- */
+
     for (const svgId in svgs) {
       if (svgId == exceptSVGId) {
         continue;
@@ -880,6 +912,7 @@ export default class ListenLayer {
       // if (svgInfo.svgId) {
       //   return svgInfo;
       // }
+
       let flag = mathUtil.isPointInPoly(position, svg.points);
       if (flag && !svgInfo.svgId) {
         svgInfo = {