MapMeasure.js
3.65 KB
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
var Mcontrol, controlm;
var MMeasureDialogFlag = false;
function MapMeasureDisplay() {
if (!MMeasureDialogFlag) {
clearMeasure();
//添加“地图量测”的弹出框
var sb = '<div id="MMCLdialog" class="easyui-dialog" title="地图量测"style="left:900px;top:110px;width:190px; height: 150px;padding: 5px" resizable="true">'
+ '<div id="toolspanelMM">'
+ '<button class="functionButton" onclick="activateCtl(\'dist\') ">量距</button>'
+ '<button class="functionButton" onclick="activateCtl(\'area\') ">量面积</button>'
+ '<button class="functionButton" onclick="clearCLMeasure() ">清除</button>'
+ '</div></div>';
$("#main").append(sb);
$("#MMCLdialog").dialog({ closed: false, onClose: function () {
clearMeasure();
MMeasureDialogFlag = false;
}
});
MMeasureDialogFlag = true;
} else {
$("#MMCLdialog").dialog("close");
}
}
function activateCtl(type) {
switch (type) {
case "dist":
//注销并删除量测控件
Mcontrol = map.getControl("zondyCD");
if (Mcontrol) {
Mcontrol.deactivate();
map.removeControl(Mcontrol);
}
Mcontrol = map.getControl("zondyCA");
if (Mcontrol) {
Mcontrol.deactivate();
map.removeControl(Mcontrol);
}
controlm = new Zondy.Control.Measure(OpenLayers.Handler.Path, { id: "zondyCD" });
map.addControl(controlm);
controlm.activate();
break;
case "area":
//注销并删除量测控件
Mcontrol = map.getControl("zondyCD");
if (Mcontrol) {
Mcontrol.deactivate();
map.removeControl(Mcontrol);
}
Mcontrol = map.getControl("zondyCA");
if (Mcontrol) {
Mcontrol.deactivate();
map.removeControl(Mcontrol);
}
controlm = new Zondy.Control.Measure(OpenLayers.Handler.Polygon, { id: "zondyCA" });
map.addControl(controlm);
controlm.activate();
break;
default:
//注销并删除量测控件
Mcontrol = map.getControl("zondyCD");
if (Mcontrol) {
Mcontrol.deactivate();
map.removeControl(Mcontrol);
}
Mcontrol = map.getControl("zondyCA");
if (Mcontrol) {
Mcontrol.deactivate();
map.removeControl(Mcontrol);
}
break;
}
}
//清除功能及界面
function clearMeasure() {
//注销并删除量测控件
clearCLMeasure();
clearMbox();
}
//删除弹出框
function clearMbox() {
var divobj = $("#MMCLdialog");
if (divobj[0]) {
divobj.remove();
}
}
//清除图层
function clearMlayer() {
var layerA = map.getLayersByName("measureLayer");
var textA = map.getLayersByName("measureTexts");
var closeA = map.getLayersByName("measureClose");
if (layerA[0] != null) {
for (var i = layerA.length - 1; i > -1; i--) {
map.removeLayer(layerA[i]);
map.removeLayer(textA[i]);
map.removeLayer(closeA[i]);
}
}
}
function clearCLMeasure() {
//注销并删除量测控件
Mcontrol = map.getControl("zondyCD");
if (Mcontrol) {
Mcontrol.deactivate();
map.removeControl(Mcontrol);
}
Mcontrol = map.getControl("zondyCA");
if (Mcontrol) {
Mcontrol.deactivate();
map.removeControl(Mcontrol);
}
clearMlayer();
}