5430528714eaff9561686f9451fa979ff69b7e93.svn-base
5.28 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
var IsAddMLCCtrl = false;
function InitMLCCtrl() {
if (!IsAddMLCCtrl) {
if ($("#MLCdialog").attr("id") == undefined)
BuildMLCAlert();
else {
$.parser.parse($("#MLCdialog")); //局部重新渲染
$("#MLCdialog").dialog("open");
}
IsAddMLCCtrl = true;
} else {
$("#MLCdialog").dialog("close");
}
}
function moveToPoint() {
var bh = $("#addressCode").val();
if(isNaN(bh)){
alert('非正确的宗地编号!');
return;
}
var x = 0;
var y = 0;
switch(bh){
case '1':
x = 36406584.17574;
y = 3666485.5731947;
break;
case '2':
x = 36410889.17574;
y = 3663076.5731947;
break;
case '3':
x = 36408114.514741;
y = 3660008.0621932;
break;
default:
x = 36407201.524239;
y = 3661882.7404462;
break;
}
// 跳转到某一级某个位置
map.moveTo(new OpenLayers.LonLat(x, y), 3); //通过moveTo方法定位到某一级别地图的某一点
var datas = [ {
bh : 2015001,
x : 36406584.17574,
y : 3666485.5731947
}, {
bh : 2015002,
x : 36410889.17574,
y : 3663076.5731947
}, {
bh : 2015003,
x : 36408114.514741,
y : 3660008.0621932
}, {
bh : 2015004,
x : 36407201.524239,
y : 3661882.7404462
} ];
createMark(datas);
}
function createMark(datas){
var vectorLayer = new OpenLayers.Layer.Vector("points");
map.addLayer(vectorLayer);
var markers = new OpenLayers.Layer.Markers( "Markers" );
var imageUrl = pix + 'lib/img/marker.png';
var size = new OpenLayers.Size(21,25);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var jz = new OpenLayers.Icon(imageUrl,size,offset);
for(var i=0;i<datas.length;i++) {
var point = new OpenLayers.Geometry.Point(Number(datas[i].x), Number(datas[i].y));
var style_point = {
strokeColor: '#000000',
strokeWidth: 1,
strokeDashstyle: "solid",
pointRadius: 1,
strokeOpacity: 0.8,
fillOpacity: 0.8,
label:datas[i].value,
fontSize:'12px',
fontFamily:'宋体',
labelXOffset:0,
labelYOffset:-15,
labelAlign:'m',
//fillColor: '#000000'
};
var pointFeature = new OpenLayers.Feature.Vector(point, null, style_point);
vectorLayer.addFeatures([pointFeature]);
//图片显示
var marker = new OpenLayers.Marker(new OpenLayers.LonLat(datas[i].x,datas[i].y),jz.clone());
markers.addMarker(marker);
map.addLayer(markers);
createPopup(marker, datas[i]);
}
if(!map.getCenter()){
map.zoomToMaxExtent();
}
}
//弹窗
function createPopup(marker, data) {
//鼠标悬浮到图标上的事件
var popup1;
marker.events.register("mouseover", marker, function(evt){
var html="<b> 宗地"+data.bh+"</b>";
popup1 = new OpenLayers.Popup("popup1", new OpenLayers.LonLat(data.x,data.y), new OpenLayers.Size(200,50), html, true);
popup1.setBackgroundColor("#ffffff");
popup1.setOpacity(12);
popup1.setBorder("1px solid #d91f12");
map.addPopup(popup1);
});
//鼠标移开事件
marker.events.register("mouseout", marker, function(evt){
popup1.hide();
});
}
function panToPoint() {
var bh = $("#addressCode").val();
if(isNaN(bh)){
alert('非正确的宗地编号!');
return;
}
var x = 0;
var y = 0;
switch(bh){
case '1':
x = 36406584.17574;
y = 3666485.5731947;
break;
case '2':
x = 36410889.17574;
y = 3663076.5731947;
break;
case '3':
x = 36408114.514741;
y = 3660008.0621932;
break;
default:
x = 36407201.524239;
y = 3661882.7404462;
break;
}
//放大到某一级
map.zoomTo(2);
//跳转到某个位置
map.panTo(new OpenLayers.LonLat(x, y)); //通过panTo方法定位到当前级别地图的某一点
}
function BuildMLCAlert() {
var sb = '<div id="MLCdialog" class="easyui-dialog" title="地图定位" style="left:800px;top:65px;width: 230px; height: 260px;padding:5px" resizable="true">' +
'<div id="toolspanelMLC" class="itembox">' +
'<div>' +
'<label>提示:请输入宗地编号</label><input id="addressCode" type="text"/>' +
'</div>'+
'<div style="margin-bottom:5px;">' +
'<button class="functionButton" style="background-color:white;width:90px;margin-left:50px;" id="Button1" title="定位到地图第5级的汉中红圈" onclick="moveToPoint()" >moveTo定位 </button>' +
'</div>'+
'<div style="padding-top:10px;border-top:1px dotted #A7C0DC;">' +
'<label>提示:(123)定位到红圈的位置</label>' +
'</div>' +
'<div >' +
'<button class="functionButton" style="background-color:white;width:90px;margin-left:50px;" id="Button2" title="定位到当前地图级别下的红圈" onclick="panToPoint()">panTo定位 </button>' +
'</div>' +
'</div>' +
'</div>';
$("#main").append(sb);
$("#MLCdialog").dialog({ closed: false, onClose: function () { closeMLC(); } });
}
function closeMLC() {
IsAddMLCCtrl = false;
}