xushiting 2 лет назад
Родитель
Сommit
42ce8b2fb3
2 измененных файлов с 21 добавлено и 9 удалено
  1. 12 9
      src/graphic/Renderer/Render.js
  2. 9 0
      src/graphic/Service/DataService.js

+ 12 - 9
src/graphic/Renderer/Render.js

@@ -98,15 +98,18 @@ export default class Render {
   autoRedraw() {
     console.log("重绘");
     draw.clear();
-    const grid = dataService.getGrid();
-    draw.drawGrid(
-      grid.startX,
-      grid.startY,
-      coordinate.width,
-      coordinate.height,
-      grid.step1,
-      grid.step2
-    );
+    if (dataService.getGridDisplay()) {
+      const grid = dataService.getGrid();
+      draw.drawGrid(
+        grid.startX,
+        grid.startY,
+        coordinate.width,
+        coordinate.height,
+        grid.step1,
+        grid.step2
+      );
+    }
+
     this.drawGeometry(dataService.getBackgroundImg());
 
     let roads = dataService.getRoads();

+ 9 - 0
src/graphic/Service/DataService.js

@@ -7,6 +7,7 @@ export class DataService {
       step2: 250,
       defalutstep1: 50,
       defalutstep2: 250,
+      display: true,
     };
     this.vectorData = {};
     this.currentId = 0; // 当前可用id
@@ -35,6 +36,14 @@ export class DataService {
     }
   }
 
+  setGridDisplay(value) {
+    this.grid.display = value;
+  }
+
+  getGridDisplay() {
+    return this.grid.display;
+  }
+
   setCurrentId(id) {
     this.currentId = id;
   }