riku
2025-03-05 4097cc9ad6c60bbb5e9864d3f54a37cfbb40026e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
 * 网格绘制
 */
import { map } from './index_old';
 
export default {
  /**
   * 绘制网格风险图
   * @param {*} points
   */
  drawRectangle: function (points) {
    const gridViews = [];
    points.forEach((p) => {
      const { lb, rt, c } = p;
 
      // eslint-disable-next-line no-undef
      let pList = [lb, rt].map((v) => new AMap.LngLat(v[0], v[1]));
      // eslint-disable-next-line no-undef
      var bounds = new AMap.Bounds(...pList);
      // eslint-disable-next-line no-undef
      var rectangle = new AMap.Rectangle({
        bounds: bounds,
        // strokeColor: '#ffffffff',
        strokeWeight: 0,
        strokeOpacity: 0,
        // strokeStyle还支持 solid
        strokeStyle: 'solid',
        fillColor: '990D0D',
        fillOpacity: 0.8,
        cursor: 'pointer',
        zIndex: 50
      });
 
      // var text = new AMap.Text({
      //   text: p.value,
      //   anchor: 'center', // 设置文本标记锚点
      //   draggable: false,
      //   style: {
      //     'background-color': 'transparent',
      //     'border-width': 0,
      //     'text-align': 'center',
      //     'font-size': '12px',
      //     color: 'white'
      //   },
      //   position: c
      // });
      gridViews.push(rectangle);
      // that.textView.push(text);
    });
    map.add(gridViews);
  }
};