fuchengshen
2022-07-04 343ba87e09501be7a63abde000a43e13a5b4f03e
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
"use script"; //开发环境建议开启严格模式
 
//对应widget.js中MyWidget实例化后的对象
var thisWidget;
 
//当前页面业务
function initWidgetView(_thisWidget) {
  thisWidget = _thisWidget;
 
  $("#measure_area_danwei").val("auto"); //默认值
  $("#measure_length_danwei").val("auto"); //默认值
 
  $("#btn_measure_length").bind("click", function () {
    $("#lbl_measure_result").html("");
    $("#measure_danwei").show();
    $("#measure_area_danwei").hide();
    $("#measure_length_danwei").show();
 
    thisWidget.measure.distance({
      unit: $("#measure_length_danwei").val(),
      addHeight: 0, //可以设置在绘制点基础自动增加高度(单位:米)
    });
  });
 
  $("#btn_measure_length_td").bind("click", function () {
    //用户首次使用时,提醒一次
    haoutil.oneMsg("贴地需要地形服务支撑,部分区域可能无法贴地!", "measure_length_tip");
 
    $("#lbl_measure_result").html("");
    $("#measure_danwei").show();
    $("#measure_area_danwei").hide();
    $("#measure_length_danwei").show();
 
    thisWidget.measure.distanceSurface({
      unit: $("#measure_length_danwei").val(),
    });
  });
 
  $("#btn_measure_section").bind("click", function () {
    //用户首次使用时,提醒一次
    haoutil.oneMsg("剖面需要地形服务支撑,部分区域可能无法获取高程值!", "measure_section_tip");
 
    $("#lbl_measure_result").html("");
    $("#measure_danwei").show();
    $("#measure_area_danwei").hide();
    $("#measure_length_danwei").show();
 
    thisWidget.measure.section({
      unit: $("#measure_length_danwei").val(),
      splitNum: 300, //插值次数
    });
  });
 
  $("#btn_measure_area").bind("click", function () {
    $("#lbl_measure_result").html("");
    $("#measure_danwei").show();
    $("#measure_length_danwei").hide();
    $("#measure_area_danwei").show();
 
    thisWidget.measure.area({
      unit: $("#measure_area_danwei").val(),
      style: {
        color: "#00fff2",
        outline: true,
        outlineColor: "#fafa5a",
        outlineWidth: 1,
        opacity: 0.4,
        clampToGround: false, //贴地
      },
    });
  });
 
  $("#btn_measure_area_td").bind("click", function () {
    $("#lbl_measure_result").html("");
    $("#measure_danwei").show();
    $("#measure_length_danwei").hide();
    $("#measure_area_danwei").show();
 
    thisWidget.measure.areaSurface({
      unit: $("#measure_area_danwei").val(),
      splitNum: 10, //step插值分割的个数
    });
  });
 
  $("#btn_measure_angle").bind("click", function () {
    $("#lbl_measure_result").html("");
    $("#measure_danwei").hide();
 
    thisWidget.measure.angle();
  });
 
  $("#btn_measure_point").bind("click", function () {
    $("#lbl_measure_result").html("");
    $("#measure_danwei").hide();
 
    thisWidget.measure.point();
  });
  $("#btn_measure_height").bind("click", function () {
    $("#lbl_measure_result").html("");
    $("#measure_danwei").show();
    $("#measure_area_danwei").hide();
    $("#measure_length_danwei").show();
 
    thisWidget.measure.height({
      unit: $("#measure_length_danwei").val(),
    });
  });
 
  $("#btn_measure_supHeight").bind("click", function () {
    $("#lbl_measure_result").html("");
    $("#measure_danwei").show();
    $("#measure_area_danwei").hide();
    $("#measure_length_danwei").show();
 
    thisWidget.measure.heightTriangle({
      unit: $("#measure_length_danwei").val(),
    });
  });
 
  $("#btn_measure_clear").bind("click", function () {
    $("#lbl_measure_result").html("");
 
    thisWidget.clearDraw();
  });
 
  //更换单位
  $("#measure_length_danwei").change(function (e) {
    var danwei = $("#measure_length_danwei").val();
    thisWidget.measure.updateUnit(danwei);
 
    $("#lbl_measure_result").html("");
  });
  $("#measure_area_danwei").change(function (e) {
    var danwei = $("#measure_area_danwei").val();
    thisWidget.measure.updateUnit(danwei);
 
    $("#lbl_measure_result").html("");
  });
 
  $("#chk_onlyPickModelPosition").change(function () {
    var val = $(this).is(":checked");
 
    thisWidget.changeOnlyPickModel(val);
  });
}
 
//修改值回调
function onMeasureChange(e) {
  $("#lbl_measure_result").html(e.label);
}
 
//单个对象绘制完成结束后的回调
function onMeasureEnd(e) {
  // console.log('测量完成');
}