# MeasureFace

创建量测 测面

const convertToCesiumColor = (colorString) => {
  var reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
  var color = colorString.toLowerCase();
  if (reg.test(color)) {
    // 如果只有三位的值,需变成六位,如:#fff => #ffffff
    if (color.length === 4) {
      var colorNew = "#";
      for (let i = 1; i < 4; i += 1) {
        colorNew += color.slice(i, i + 1).concat(color.slice(i, i + 1));
      }
      color = colorNew;
    }
    // 处理六位的颜色值,转为RGB
    var colorChange = [];
    for (let i = 1; i < 7; i += 2) {
      colorChange.push(parseInt("0x" + color.slice(i, i + 2)));
    }
    return new Cesium.Color(
      colorChange[0] / 255,
      colorChange[1] / 255,
      colorChange[2] / 255,
      1
    );
  } else {
    return color;
  }
};
let viewModel = {
  color1: "#ff7f00",
  measure_face_start: () => {
    let measureFace = new GeowayGlobe.MeasureFace({
      viewer,
      baseColor: convertToCesiumColor(viewModel.color1),
    });
    measureFace.start();
  },
};
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

# MeasureFace options 构造属性

属性 说明 类型 默认值
viewer 地球实例 Object viewer
baseColor 量测的颜色 Object {red: 1, green: 0.4980392156862745, blue: 0, alpha: 1}

# MeasureFace 方法

# start

参数:无

开启测面功能

measureFace.start();
1

# destroy

参数:无

销毁绘制的测面.

measureFace.destory();
1