From b87b2befa85bd085f40dc5aa7ea9bfbc17d807e5 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期五, 10 一月 2025 17:15:02 +0800
Subject: [PATCH] 1. 调整了网格内文本的展示方式和样式; 2. 省去了单个网格4个顶点坐标的计算逻辑,交由后端完成;

---
 src/utils/map/grid.js |   40 +++++++++++++++++++++++++++-------------
 1 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/src/utils/map/grid.js b/src/utils/map/grid.js
index f421dae..7f37bf6 100644
--- a/src/utils/map/grid.js
+++ b/src/utils/map/grid.js
@@ -84,22 +84,36 @@
  * 鏂囨湰鏍囪
  * 鍙慨鏀筽osition
  */
-function textMaker(position, text, anchor) {
+function textMaker(position, text, anchor, type) {
+  let style = {};
+  if (type == 'data') {
+    style = {
+      'font-size': '12px',
+      'text-align': 'center',
+      color: 'white',
+      background: '#122b54a9',
+      'text-shadow': 'black 2px 2px 2px',
+      border: '0px',
+      'margin-top': '4px'
+    };
+  } else if (type == 'rank') {
+    style = {
+      'font-size': '14px',
+      'text-align': 'center',
+      color: 'white',
+      background: 'transparent',
+      'text-shadow': 'black 2px 2px 2px',
+      'border-radius': '2px',
+      border: '1px solid #122b54a9',
+      'margin-bottom': '4px'
+    };
+  }
   // eslint-disable-next-line no-undef
   return new AMap.Text({
     text: text,
     anchor,
     position: position,
-    style: {
-      'font-size': '13px',
-      'text-align': 'center',
-      color: 'white',
-      'background-color': 'transparent',
-      'text-shadow': 'black 2px 2px 2px',
-      'border-radius': '2px',
-      border: '1px',
-      padding: '4px'
-    }
+    style: style
   });
 }
 
@@ -204,7 +218,7 @@
     return gridViews;
   },
 
-  drawGridText(points, textViews, anchor) {
+  drawGridText(points, textViews, anchor, type) {
     if (textViews) {
       points.forEach((p, i) => {
         textViews[i].setPosition(p.lnglat_GD);
@@ -214,7 +228,7 @@
     } else {
       const _textViews = [];
       points.forEach((p) => {
-        const m = textMaker(p.lnglat_GD, p.data, anchor);
+        const m = textMaker(p.lnglat_GD, p.data, anchor, type);
         _textViews.push(m);
       });
       map.add(_textViews);

--
Gitblit v1.9.3