0cb48f8942e21c1af0fa59e9b434783d1bccdcdf.svn-base
7.04 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
var isFFCheck = false;
var vecLayerFF = null, vLayerFF = null; //矢量要素图层
var selFeatureCtrlFlash = null; //矢量要素选择控件
var selectFlashFea;
var numFlashFea = 0;
var kFlashFea = 0;
var timerFlashFea;
var style_greenFF;
function DrawFF() {
if (!isFFCheck) {
if ($("#FFdialog").attr("id") == undefined)
BuildFFAlert();
else {
$.parser.parse($("#FFdialog")); //局部重新渲染
$("#FFdialog").dialog("open");
}
initFFCtrl();
isFFCheck = true;
} else {
// clearFlashFea();
// isFFCheck = false;
$("#FFdialog").dialog("close");
}
}
function BuildFFAlert() {
var sb = '<div id="FFdialog" class="easyui-dialog" title="框选要素闪烁" style="left:900px;top:320px;width:210px; height: 200px;padding: 5px" resizable="true">'
+ '<div id="toolspanelFF" style= "border:1px dashed gray;">'
+ ' <input class="functionButton" type="button" id="disp" value="生成要素" onclick=\'randFeatures()\'/>'
+ '<input class="functionButton" type="button" id="Button1" value="框选要素" onclick=\'boxSelect()\'/>'
+ ' <input class="functionButton" type="button" id="Button3" value="开始闪烁" onclick=\'startFlashFhFea()\'/>'
+ ' <input class="functionButton" type="button" id="Button2" value="停止闪烁" onclick=\'stopFlashFhFea()\'/>'
+ ' <input class="functionButton" type="button" id="Button4" value="停止拉框" onclick=\'stopBoxFlashFea()\'/>'
+ ' <input class="functionButton" type="button" id="Button5" value="清除" onclick=\'clearFlashFea()\'/>'
+ '</div>' + ' </div>';
$("#main").append(sb);
$("#FFdialog").dialog({
closed : false,
onClose : function() {
closeFFea();
}
});
document.getElementById('disp').disabled = false;
document.getElementById('Button1').disabled = true;
document.getElementById('Button4').disabled = true;
document.getElementById('Button3').disabled = true;
document.getElementById('Button2').disabled = true;
}
function initFFCtrl() {
vecLayerFF = new OpenLayers.Layer.Vector("矢量图层KXYS");
selectFlashFea = new OpenLayers.Layer.Vector("SelectionKXYS");
map.addLayers([ vecLayerFF, selectFlashFea ]);
map.setCenter(new OpenLayers.LonLat(-4.5142085028902, 10.743816236882), 3);
numFlashFea = 20;
kFlashFea = 0;
style_green = {
fillColor : "#ff0000",
fillOpacity : 1,
hoverFillColor : "white",
hoverFillOpacity : 0.8,
strokeColor : "#ff0000",
strokeOpacity : 1,
strokeLinecap : "round",
strokeWidth : 2,
strokeDashstyle : "solid",
hoverStrokeColor : "red",
hoverStrokeOpacity : 1,
hoverStrokeWidth : 0.2,
pointRadius : 6,
hoverPointRadius : 1,
hoverPointUnit : "%",
pointerEvents : "visiblePainted",
cursor : "inherit"
};
//图层要素选择控件
selFeatureCtrlFlash = new OpenLayers.Control.SelectFeature(vecLayerFF, {
highlightOnly : false,
box : true
});
//图层要素选择事件
vecLayerFF.events.on({
'featureselected' : function(e) {
if (e.feature.geometry.CLASS_NAME == "OpenLayers.Geometry.Point") {
var pnt = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(e.feature.geometry.x,
e.feature.geometry.y), null, style_green);
selectFlashFea.addFeatures([ pnt ]);
}
},
'featureunselected' : function(e) {
selectFlashFea.removeAllFeatures();
}
});
map.addControl(selFeatureCtrlFlash);
}
function toggleLayerFlashFea() {
if (selectFlashFea != null) {
if (selectFlashFea.visibility) {
selectFlashFea.setVisibility(false);
} else {
selectFlashFea.setVisibility(true);
}
}
}
function startFlashFhFea() {
var getSelectKXYS = selectFlashFea.features;
if (getSelectKXYS == null || getSelectKXYS.length <= 0) {
$.messager.alert("提示", "当前没有框选任何要素,请重新选择!", "info");
return;
}
document.getElementById('disp').disabled = true;
document.getElementById('Button1').disabled = true;
document.getElementById('Button4').disabled = true;
document.getElementById('Button3').disabled = true;
document.getElementById('Button2').disabled = false;
timerFlashFea = setInterval(toggleLayerFlashFea, 500);
}
function stopFlashFhFea() {
clearInterval(timerFlashFea);
selectFlashFea.redraw();
vecLayerFF.redraw();
selectFlashFea.setVisibility(false);
document.getElementById('disp').disabled = true;
document.getElementById('Button3').disabled = false;
document.getElementById('Button2').disabled = true;
document.getElementById('Button1').disabled = true;
document.getElementById('Button4').disabled = false;
// selectFlashFea.removeAllFeatures();
}
//随机生成矢量要素
function randomCreateFeatureFhFea(vLayer, numFlashFea) {
var curMapBound = map.getExtent();
var w = curMapBound.right - curMapBound.left;
var h = curMapBound.top - curMapBound.bottom;
if (vLayer == null) {
vLayer = new OpenLayers.Layer.Vector("矢量图层");
map.addLayers([ vLayer ]);
} else {
vLayer.removeAllFeatures();
}
var curResolution = map.getResolution();
for ( var i = 0; i < numFlashFea; i++) {
var x = Math.random() * w + curMapBound.left;
var y = Math.random() * h + curMapBound.bottom;
var newPoint = new OpenLayers.Geometry.Point(x, y);
var pntFeature = new OpenLayers.Feature.Vector(newPoint, null, null);
vLayer.addFeatures([ pntFeature ]);
}
}
function randFeatures() {
randomCreateFeatureFhFea(vecLayerFF, 50);
document.getElementById('disp').disabled = true;
document.getElementById('Button1').disabled = false;
document.getElementById('Button4').disabled = true;
document.getElementById('Button3').disabled = true;
document.getElementById('Button2').disabled = true;
}
function boxSelect() {
selectFlashFea.setVisibility(false);
selFeatureCtrlFlash.activate();
document.getElementById('disp').disabled = true;
document.getElementById('Button1').disabled = true;
document.getElementById('Button2').disabled = true;
document.getElementById('Button3').disabled = false;
document.getElementById('Button4').disabled = true;
}
function stopBoxFlashFea() {
document.getElementById('disp').disabled = true;
document.getElementById('Button1').disabled = false;
document.getElementById('Button2').disabled = true;
document.getElementById('Button3').disabled = true;
document.getElementById('Button4').disabled = false;
selFeatureCtrlFlash.unselectAll();
selFeatureCtrlFlash.deactivate();
vecLayerFF.redraw();
selectFlashFea.removeAllFeatures();
selectFlashFea.setVisibility(false);
}
function closeFFea() {
if (timerFlashFea) {
clearInterval(timerFlashFea);
}
document.getElementById('disp').disabled = false;
document.getElementById('Button1').disabled = true;
document.getElementById('Button2').disabled = true;
document.getElementById('Button3').disabled = true;
document.getElementById('Button4').disabled = true;
if (selFeatureCtrlFlash) {
selFeatureCtrlFlash.deactivate();
}
map.removeLayer(vecLayerFF);
map.removeLayer(selectFlashFea);
map.removeControl(selFeatureCtrlFlash);
vecLayerFF = null;
selectFlashFea = null;
selFeatureCtrlFlash = null;
numFlashFea = 0;
kFlashFea = 0;
timerFlashFea = null;
style_green = null;
isFFCheck = false;
}
function clearFlashFea() {
closeFFea();
isFFCheck = true;
initFFCtrl();
}