58d25a0d11fdc7ab86d15751af979711e2b03a44.svn-base
8.19 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
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
var IsUDZDYCtrl = false;
var isLayerSwitcherZDY = false;
var isPanZoomBarZDY = false;
var isScaleBarZDY = false;
var isMagnifyZDY = false;
var isOverviewMapZDY = false;
var isLegendBarZDY = false;
var isRightcLickMenuZDY = false;
var controlarrZDY = [];
function initUDControl() {
removeallControl();
if (!IsUDZDYCtrl) {
var obj = $("#trashUD");
$("#trashUD")[0].style.display = "block";
IsUDZDYCtrl = true;
}
else {
$("#trashUD")[0].style.display = "none";
IsUDZDYCtrl = false;
}
}
function update(element) {
if (element == null) {
return;
}
switch (element.id) {
case "LayerSwitcher":
isLayerSwitcherZDY = ISInThisControl("Zondy.Control.LayerSwitcher");
if (!isLayerSwitcherZDY) {
var layerSwitcher = new Zondy.Control.LayerSwitcher(); //自定义图层列表控件
map.addControl(layerSwitcher);
document.getElementById("LayerSwitcher").value = layerSwitcher.id;
controlarrZDY.push(layerSwitcher.id);
isLayerSwitcherZDY = true;
}
else {
isLayerSwitcherZDY = false;
removeUserContrlByClassName("Zondy.Control.LayerSwitcher");
}
break;
case "PanZoomBar":
isPanZoomBarZDY = ISInThisControl("Zondy.Control.PanZoomBar");
if (!isPanZoomBarZDY) {
var ovControl = new Zondy.Control.PanZoomBar(); //自定义导航控件
map.addControl(ovControl);
document.getElementById("PanZoomBar").value = ovControl.id;
controlarrZDY.push(ovControl.id);
isPanZoomBarZDY=true;
}
else {
isPanZoomBarZDY=false;
removeUserContrlByClassName("Zondy.Control.PanZoomBar");
}
break;
case "ScaleBar":
isScaleBarZDY = ISInThisControl("Zondy.Control.ScaleBar");
if (!isScaleBarZDY) {
var scaleControl = new Zondy.Control.ScaleBar(); //自定义比例尺控件
map.addControl(scaleControl);
document.getElementById("ScaleBar").value = scaleControl.id;
controlarrZDY.push(scaleControl.id);
isScaleBarZDY=true;
}
else {
isScaleBarZDY=false;
removeUserContrlByClassName("Zondy.Control.ScaleBar");
}
break;
case "Magnify":
isMagnifyZDY = ISInThisControl("Zondy.Control.Magnifier");
if (!isMagnifyZDY) {
var magnify = new Zondy.Control.Magnifier({ maxExtent: new OpenLayers.Bounds(114.125602, 30.453932, 114.500707, 30.829037), maxResolution: 0.00146525390625 });
map.addControl(magnify);
document.getElementById("Magnify").value = magnify.id;
controlarrZDY.push(magnify.id);
isMagnifyZDY=true;
}
else {
isMagnifyZDY=false;
removeUserContrlByClassName("Zondy.Control.Magnifier");
}
break;
case "OverviewMap":
isOverviewMapZDY = ISInThisControl("Zondy.Control.OverviewMap");
if (!isOverviewMapZDY) {
var overviewMap = new Zondy.Control.OverviewMap();
map.addControl(overviewMap);
overviewMap.maximizeControl();
document.getElementById("OverviewMap").value = overviewMap.id;
controlarrZDY.push(overviewMap.id);
isOverviewMapZDY = true;
}
else {
isOverviewMapZDY = false;
removeUserContrlByClassName("Zondy.Control.OverviewMap");
}
break;
case "LegendBar":
isLegendBarZDY = ISInThisControl("Zondy.Control.LegendBar");
if (!isLegendBarZDY) {
var legendBar = new Zondy.Control.LegendBar(); //自定义图例控件
var legendMark1 = new Zondy.Control.LegendMark("$$tools$$/" + toolIdUD +"/css/img/slider.png", "线路1");
legendBar.addLegendMark(legendMark1); //图例项
var legendMark2 = new Zondy.Control.LegendMark("$$tools$$/" + toolIdUD +"/css/img/slider.png", "线路2");
legendBar.addLegendMark(legendMark2); //图例项
var legendMark3 = new Zondy.Control.LegendMark("$$tools$$/" + toolIdUD +"/css/img/slider.png", "线路3");
legendBar.addLegendMark(legendMark3); //图例项
map.addControl(legendBar);
document.getElementById("LegendBar").value = legendBar.id;
controlarrZDY.push(legendBar.id);
isLegendBarZDY=true;
}
else {
isLegendBarZDY=false;
removeUserContrlByClassName("Zondy.Control.LegendBar");
}
break;
case "RightcLickMenu":
isRightcLickMenuZDY = ISInThisControl("Zondy.Control.RightClickMenu");
if (!isRightcLickMenuZDY) {
var rightMenu = new Zondy.Control.RightClickMenu(); //自定义右键菜单控件
map.addControl(rightMenu);
document.getElementById("RightcLickMenu").value = rightMenu.id;
isRightcLickMenuZDY = true;
controlarrZDY.push(rightMenu.id);
$.messager.alert("右键菜单提示", "右键菜单添加成功,请在地图上单击鼠标右键!", "info");
}
else {
isRightcLickMenuZDY = false;
removeUserContrlByClassName("Zondy.Control.RightClickMenu");
}
break;
}
}
//根据控件的类名删除
function removeUserContrlByClassName(className) {
var getControlArr = this.map.getControlsByClass(className);
if (getControlArr) {
if (getControlArr.length > 0) {
for (var i = 0; i < getControlArr.length; i++) {
map.removeControl(getControlArr[i]);
}
}
}
}
function ISInThisControl(className) {
var isinFlag = false;
var getControlArr = this.map.getControlsByClass(className);
if (getControlArr) {
if (getControlArr.length > 0) {
isinFlag = true;
}
}
return isinFlag;
}
function removeallControl() {
removeUserContrlByClassName("Zondy.Control.LayerSwitcher");
removeUserContrlByClassName("Zondy.Control.PanZoomBar");
removeUserContrlByClassName("Zondy.Control.ScaleBar");
removeUserContrlByClassName("Zondy.Control.Magnifier");
removeUserContrlByClassName("Zondy.Control.OverviewMap");
removeUserContrlByClassName("Zondy.Control.LegendBar");
removeUserContrlByClassName("Zondy.Control.RightClickMenu");
controlarrZDY = null;
isLayerSwitcherZDY = false;
isPanZoomBarZDY = false;
isScaleBarZDY = false;
isMagnifyZDY = false;
isOverviewMapZDY = false;
isLegendBarZDY = false;
isRightcLickMenuZDY = false;
controlarrZDY = [];
}