-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
489 lines (472 loc) · 18 KB
/
index.html
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<title>洋山港</title>
<!--bootstrap-->
<link rel="stylesheet" href="dist/bootstrap.min.css">
<!--ol-->
<link rel="stylesheet" href="dist/ol.min.css">
<!--ol-editor-->
<link rel="stylesheet" href="dist/ol.editor.css">
<!--ol-ex-search-->
<link rel="stylesheet" href="dist/ex/control/searchcontrol.css">
<!--ol-ex-overlay-->
<link rel="stylesheet" href="dist/ex/control/popupoverlay.css">
<link rel="stylesheet" href="dist/ex/control/popupoverlay.anim.css">
<!--custom css-->
<link rel="stylesheet" type="text/css" href="dist/custom.css">
<link rel="shortcut icon" href="favicon.ico">
<!---->
<link href="dist/bootstrap/css/bootstrap-datetimepicker.min.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- <iframe src="http://localhost:1886/Scripts/selection/jsp/Selection.html" z-index=1000></iframe> -->
<div class="application pinned-toolbar pinned-layermanager">
<!--菜单栏-->
<div id="menubar" class="menubar">
<!-- a.pin -->
<a href="#toolbar" class="pin active" title="Pin/unpin menubar"><i class="glyphicon glyphicon-pushpin"></i></a>
<ul>
<!-- <li id="exit" class="li-left"><img src="res/exit.png"></li>
<li id='condition' class="li-left"><img src="res/condition.png"></li> -->
<li class="active"><a href="#maptools" role="tab" data-toggle="tab"><img src="res/tools.png"></a></li>
<li><a href="#equipments" role="tab" data-toggle="tab"><img src="res/print.png"></a></li>
</ul>
</div>
<!--工具条-->
<div id="toolbar" class="toolbar tab-content pinned">
<div id="maptools" class="tab-pane active showing"></div>
<div id="equipments" class="tab-pane">
</div>
</div>
<!--地图容器-->
<div class="map-container">
<!--图层管理器-->
<div id="layermanager" class="layermanager pinned">
<div class="bar-title"><a href="#layermanager" class="pin active" title="Pin/unpin layer manager"><i class="glyphicon glyphicon-pushpin"></i></a> 图层管理</div>
</div>
<!--属性管理器-->
<div id="attributemanager" class="attributemanager">
<div class="bar-title"><a href="#attributemanager" class="pin" title="Pin/unpin attribute manager"><i class="glyphicon glyphicon-pushpin"></i></a> 属性管理</div>
</div>
<!-- 地图 -->
<div id="map" class="map" tabindex="-1" style="cursor:default"></div>
<!-- 属性-->
<div id="classify">
<div class="bar-title"><a href="#" class="pin" title="Pin/unpin attribute manager"><i class="glyphicon glyphicon-pushpin"></i></a></div>
</div>
</div>
<!-- 状态栏 -->
<div id="statusbar" class="statusbar"></div>
<!--查询条件对话框-->
<div id="querydlg" class="modal fade" role='dialog' tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<form id='queryform'>
<div class="modal-header">
<button type="button" class="close" data-dismiss='modal'>×</button>
<h4 class="modal-title"></h4>
</div>
<dir class="modal-body">
<div class="form-horizontal">
<div class="form-group">
<label class="control-label input-sm col-sm-3">开始时间:</label>
<div class="col-sm-3 input-append date form_datetime">
<input type="text" name="start_time" class="form-control input-sm" value="" readonly="">
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="form-group">
<label class="control-label input-sm col-sm-3">结束时间:</label>
<div class="col-sm-3 input-append date form_datetime">
<input type="text" name="end_time" class="form-control input-sm" value="" readonly="">
<span class="add-on"><i class="icon-th"></i></span>
</div>
</div>
<div class="form-group">
<label class="control-label input-sm col-sm-3">
<input type="checkbox" name="camera">摄像机</label>
<label class="control-label input-sm col-sm-3">
<input type="checkbox" name="jika">集卡</label>
<label class="control-label input-sm col-sm-3">
<input type="checkbox" name="agv"> AGV</label>
</div>
<div class="form-group">
<label class="control-label input-sm col-sm-3">
<input type="checkbox" name="ldiao">龙门吊</label>
<label class="control-label input-sm col-sm-3">
<input type="checkbox" name="qdiao">桥吊</label>
<label class="control-label input-sm col-sm-3">
<input type="checkbox" name="gdiao">轨道吊</label>
</div>
<div class="form-group">
<label class="control-label input-sm col-sm-3">
<input type="checkbox" name="tirediao">轮胎吊</label>
<label class="control-label input-sm col-sm-3">
<input type="checkbox" name="qiuji">球机</label>
<label class="control-label input-sm col-sm-3">
<input type="checkbox" name="qiangji">枪机</label>
</div>
</div>
</dir>
<div class="modal-footer">
<button type="submit" class="btn btn-sm btn-primary">确定</button>
<button type="button" class="btn btn-sm btn-default" data-dismiss="modal">取消</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- 脚本 -->
<!--jquery-->
<script src="dist/jquery.min.js"></script>
<script src="dist/bootstrap.min.js"></script>
<!--proj4-->
<script src="dist/proj4.js"></script>
<!--ol-->
<script src="dist/ol-debug.js"></script>
<!--ol-editor-->
<script src="dist/ol.editor.js"></script>
<!--ol-ex-->
<script src="dist/ex/control/searchcontrol.js"></script>
<script src="dist/ex/control/searchfeaturecontrol.js"></script>
<script src="dist/ex/control/popupoverlay.js"></script>
<!--video-->
<script src="dist/ex/control/videoPopupOverlay.js"></script>
<!--style-->
<script src="dist/styles.js"></script>
<!--mq-->
<script src="dist/rabbitmq/sockjs-0.3.js"></script>
<script src="dist/rabbitmq/stomp.js"></script>
<!--bootstrap-->
<script src="dist/bootstrap/js/bootstrap-datetimepicker.min.js"></script>
<script src="dist/bootstrap/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script>
styleFunction=function(feature,resolution){
var zoom=editor.getView().getZoom();
var style=null;
var properties=feature.getProperties();
if(properties.type===1){
style=styles['car'];
}
else if(properties.type===2){
style=styles['camera'];
}
else if (properties.type===3) {
style=styles['agv'];
}
else if (properties.type===4) {
style=styles['qdiao'];
}
else if (properties.type===5) {
style=styles['gdiao'];
}
else if (properties.type===6) {
style=styles['ldiao'];
}
else if (properties.type===7) {
style=styles['alarm'];
}
else if (properties.type===8) {
style=styles['pos'];
}
else{
style=styles['pos'];
}
if (zoom===12) {
return [styles['point']];
}
else{
style.getImage().setScale(zoom/25);
return [style];
}
};
//选择
var selectClick=new ol.interaction.Select({
});
var attributeManager=new ol.control.AttributeManager({ target: 'attributemanager' });
//attributeManager.setMap(map);
// proj4.defs("EPSG:23700","+title=HD72 EOV +proj=somerc +lat_0=47.14439372222222 +lon_0=19.04857177777778 +k_0=0.99993 +x_0=650000 +y_0=200000 +ellps=GRS67 +towgs84=52.17,-71.82,-14.9,0,0,0,0 +units=m +no_defs");
var eov = new ol.proj.Projection({
code: 'EPSG:3857',
extent: [13582066.888853556, 3587359.445355572,
13585173.06488047, 3588705.080676691],
worldExtent: [73,3, 135, 53]
});
//地图设置
//动态图层
var realTimeLayer=new ol.layer.Vector({
name:'动态图层',
source:new ol.source.Vector({
url:"data/ldiao.geojson",
format:new ol.format.GeoJSON()}),
style:styleFunction
});
realTimeLayer.set('type','geomcollection');
realTimeLayer.set('id','realTimeLayerID');
//search
var search = new ol.control.SearchFeature(
{
//target: $("#search").get(0),
source: realTimeLayer.getSource(),//设置查询的图层
property: 'id'
});
// Popup overlay
var popup = new ol.Overlay.Popup (
{ popupClass: "default", //"tooltips", "warning" "black" "default", "tips", "shadow",
closeBox: true,
onclose: function(){ console.log("关闭窗口!"); },
positioning: 'auto',
autoPan: true,
autoPanAnimation: { duration: 100 },
id:'1'
});
// map
editor = new ol.Editor({
overlays:[popup],
target: 'map',
view: new ol.View({
//projection: 'EPSG:4326',
extent: [13582065, 3587358,13585174, 3588706],
center: [13583806.359,3588119.431],
zoom: 14,
minZoom: 12,
maxZoom: 23,
rotation:-15*Math.PI/180.0
}),
layers: [
new ol.layer.Tile({
name: 'OpenStreetMap',
source: new ol.source.OSM()
}),
// new ol.layer.Tile({
// visible: false,
// name:'ysg-tile',
// source: new ol.source.TileWMS({
// url: 'http://localhost:8080/geoserver/ysg/wms',
// params: {'FORMAT': 'image/png',
// 'VERSION': '1.1.1',
// tiled: true,
// STYLES: '',
// LAYERS: 'ysg:jizhuangxiang',
// tilesOrigin: 13582132.823772825 + "," + 3587341.8755370886
// }
// })
// }),
new ol.layer.Image({
name:'洋山港-边界',
source: new ol.source.ImageWMS({
url: 'http://192.168.5.239:8080/geoserver/ysg/wms',
params: {'LAYERS': 'ysg:bianjie1','VERSION':'1.1.0'},
serverType: 'geoserver',
})
}),
new ol.layer.Image({
name:'洋山港-集装箱',
source: new ol.source.ImageWMS({
url: 'http://192.168.5.239:8080/geoserver/ysg/wms',
params: {'LAYERS': 'ysg:jizhuangxiang','VERSION':'1.1.0'},
serverType: 'geoserver',
})
}),
new ol.layer.Image({
name:'洋山港-道路',
source: new ol.source.ImageWMS({
url: 'http://192.168.5.239:8080/geoserver/ysg/wms',
params: {'LAYERS': 'ysg:road','VERSION':'1.1.0'},
serverType: 'geoserver',
})
}),
new ol.layer.Image({
name:'洋山港-设备',
source: new ol.source.ImageWMS({
url: 'http://192.168.5.239:8080/geoserver/ysg/wms',
params: {'LAYERS': 'ysg:shebei','VERSION':'1.1.0'},
serverType: 'geoserver',
})
}),
realTimeLayer
],
//地图控件加载
controls: [
//new ol.control.Add({target:'ysgceshi',tipLabel:'相机标定'}),
new ol.control.Exit(),
new ol.control.Condition(),
new ol.control.FullScreen(),
new ol.control.Rotate(),
new ol.control.ScaleLine(),
new ol.control.ZoomSlider(),
new ol.control.Attribution({ collapsible: false }),
new ol.control.LayerManager({ target: 'layermanager' }),
attributeManager,
new ol.control.Zoom({ target: 'maptools',zoomOutLabel:'', zoomInTipLabel:'放大',zoomOutTipLabel:'缩小' }),
new ol.control.ZoomHistory({ target: 'maptools' , backTipLabel:'向前',nextTipLabel:'向后'}),
new ol.control.ZoomToExtent({ target: 'maptools', label: ' ',tipLabel:'全局' ,extent: eov.getExtent()}),
new ol.control.ZoomToSelection({ target: 'maptools' }),
new ol.control.SelectionControls({ target: 'maptools' }),
new ol.control.Measure({ target: 'maptools' }),
new ol.control.Message({ target: 'statusbar' }),
new ol.control.QueryField({target:'statusbar'}),
new ol.control.MousePosition({
target: 'statusbar',
className: 'ol-mouse-position ol-control ol-unselectable',
coordinateFormat: ol.coordinate.createStringXY(3)
}),
new ol.control.Rotation({ target: 'statusbar'}),
new ol.control.Projection({
target: 'statusbar',
projections: ['EPSG:3857']
}),
search,
new ol.control.Alarm({target:'equipments'}),
new ol.control.Route({target:'equipments'}),
new ol.control.Equipments({target:'equipments'}),
new ol.control.RealTime({target:'equipments'})
],
loadTilesWhileAnimating: true,
loadTilesWhileInteracting: true,
logo: false
});
//editor.getView().SetRotation(-14*Math.PI/180);
//地图加载时,操作
var showing = false;
$(document).ready(function() {
//日期控件
$('.form_datetime').datetimepicker({format: 'yyyy-mm-dd,hh:ii:ss',
autoclose:true,
todayBtn:true,
pickerPosition:'bottom-right',
language:'zh-CN'});
//传递参数调用后天方法
document.getElementById('queryform').addEventListener('submit', function (evt) {
evt.preventDefault();//阻止提交网页
console.log(this.start_time.value);
console.log(this.end_time.value);
console.log(this.jika.checked);
console.log(this.camera.checked);
$('#querydlg').modal('hide');
});
//关闭右键功能
$(document).bind("contextmenu",function(e){
return false;
});
//menubar的第一层ul第一层li第一层a
$(document).on('click', '#menubar>ul>li>a', function(e) {
var elementToShow = $(this).attr('href');
if (!showing) {
showing = true;
setTimeout(function() {
$(elementToShow).addClass('slide-out');
}, 100);
} else {
if (!$(elementToShow).hasClass('showing')) {
$(elementToShow).addClass('showing');
}
if ($(elementToShow).hasClass('slide-out')) {
$(elementToShow).removeClass('slide-out');
}
}
$(elementToShow).addClass('active');
});
//menubar ul li a
$(document).click(function(e) {
var tabs = $('#menubar>ul>li>a');
//选择除了.pinned以外的所有第一层div
var containers = $('#toolbar:not(.pinned)>div');
if ((!containers.is(e.target) && containers.has(e.target).length === 0)
&& (!tabs.is(e.target) && tabs.has(e.target).length === 0)
) {
containers.removeClass('slide-out');
containers.removeClass('showing');
containers.removeClass('active');
$('.application:not(.pinned-toolbar) #menubar>ul>li').removeClass('active');
showing = false;
}
});
//pin
$(document).on('click', 'a.pin', function(e) {
e.preventDefault();
$(this).toggleClass('active');
var target = $(this).attr('href');
$(target).toggleClass('pinned');
if (target == '#toolbar') { // activate the first
$('#menubar>ul>li>a[data-toggle=tab]').first().trigger('click');
}
$($(this).closest('.application')).toggleClass('pinned-' + $(this).attr('href').substr(1));
editor.updateSize(); // soo static
});
//tooltip
$('#toolbar [title], #map [title], #statusbar [title]').tooltip({
placement: 'auto bottom',
container: 'body'
});
//通过URL获取参数,并执行相应的操作
var myurl=GetQueryString("minx");
if(myurl !=null)
{
var minx=GetQueryString('minx');
var miny=GetQueryString('miny');
var maxx=GetQueryString('maxx');
var maxy=GetQueryString('maxy');
editor.getView().fit([minx,miny,maxx,maxy]);
}
});
//通过URL获取参数
function GetQueryString(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
// Select feature when click on the reference index
// var select = new ol.interaction.Select({});
editor.addInteraction(select);
//On selected => show/hide popup
select.getFeatures().on(['add'], function(e)
{
var feature = e.element;
if (feature.get('type')!==undefined) {
var content = feature.getProperties();
var table="<table class='table table-striped table-collapsed'>";
Object.keys(content).forEach(function(key){
if (key!=='geometry') {
table+="<tr><td>"+key+"</td>"+"<td>"+feature.get(key)+"</td></tr>";
}
});
table+="</table>";
content += feature.get("type");
popup.show(feature.getGeometry().getCoordinates(),table);
}
})
select.getFeatures().on(['remove'], function(e)
{ popup.hide();
})
search.on('select', function(e)
{
// select.getFeatures().clear();
// select.getFeatures().push (e.search);
var feature=e.search;
var p = feature.getGeometry().getFirstCoordinate();
if (feature.get('type')!==null) {
editor.getView().animate({ center:p });
var content = feature.getProperties();
var table="<table class='ptable'>";
Object.keys(content).forEach(function(key){
if (key!=='geometry') {
table+="<tr><td>"+key+"</td>"+"<td>"+feature.get(key)+"</td></tr>";
}
});
table+="</table>";
//content += feature.get("type");
popup.show(p,table);
}
});
</script>
</body>
</html>