Commit 69382307ff94fb2e8f271ae5ae3a9a9c69e319ec
1 parent
2df0767e
实时监控接入线路GPS数据
Showing
6 changed files
with
174 additions
and
57 deletions
src/main/resources/static/pages/mapmonitor/real/css/real.css
| @@ -53,6 +53,28 @@ label.BMapLabel{ | @@ -53,6 +53,28 @@ label.BMapLabel{ | ||
| 53 | 53 | ||
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | +.mapRightWrap.vehicle .slimScrollBar{ | ||
| 57 | + width: 6px !important; | ||
| 58 | + opacity: 0.5 !important; | ||
| 59 | + background: #e7ecf1 !important; | ||
| 60 | + border-radius: 5px !important; | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +.mapRightWrap.vehicle a.fixed-line{ | ||
| 64 | + text-decoration: none; | ||
| 65 | + position: fixed; | ||
| 66 | + top: 218.5px; | ||
| 67 | + width: 318px; | ||
| 68 | + left: 1586px; | ||
| 69 | + background-color: red; | ||
| 70 | + z-index: 2; | ||
| 71 | +} | ||
| 72 | + | ||
| 73 | +.mapRightWrap.vehicle a.fixed-line .head{ | ||
| 74 | + border-bottom: none; | ||
| 75 | + margin: 15px 15px 10px 15px; | ||
| 76 | +} | ||
| 77 | + | ||
| 56 | .mapRightWrap.to_searchPanel{ | 78 | .mapRightWrap.to_searchPanel{ |
| 57 | transform:rotateY(180deg); | 79 | transform:rotateY(180deg); |
| 58 | height: 200px; | 80 | height: 200px; |
| @@ -313,34 +335,35 @@ html{ | @@ -313,34 +335,35 @@ html{ | ||
| 313 | } | 335 | } |
| 314 | 336 | ||
| 315 | .mapRightWrap.vehicle p.head{ | 337 | .mapRightWrap.vehicle p.head{ |
| 316 | - color: #C0BDBD; | ||
| 317 | - font-size: 21px; | ||
| 318 | - border-bottom: 1px solid gray; | ||
| 319 | - padding-left: 15px; | ||
| 320 | - position: relative; | 338 | + color: #B7B7B7; |
| 339 | + font-size: 18px; | ||
| 340 | + border-bottom: 1px dashed #556471; | ||
| 341 | + position: relative; | ||
| 342 | + margin: 15px; | ||
| 343 | + padding-bottom: 10px; | ||
| 344 | + font-family: 微软; | ||
| 321 | } | 345 | } |
| 322 | 346 | ||
| 323 | /* .mapRightWrap.vehicle p.head:hover{ | 347 | /* .mapRightWrap.vehicle p.head:hover{ |
| 324 | box-shadow: 0 8px 17px 0 rgba(128, 123, 123, 0.2),0 6px 20px 0 rgba(86, 67, 67, 0.19); | 348 | box-shadow: 0 8px 17px 0 rgba(128, 123, 123, 0.2),0 6px 20px 0 rgba(86, 67, 67, 0.19); |
| 325 | } | 349 | } |
| 326 | */ | 350 | */ |
| 327 | -.mapRightWrap.vehicle p.head>span.icon>a{ | ||
| 328 | - position: absolute; | ||
| 329 | - right: 15px; | ||
| 330 | - top: -2px; | ||
| 331 | - font-size: 24px; | ||
| 332 | - color: #B9B9B9; | ||
| 333 | - | ||
| 334 | - transition: all .5s ease; | 351 | +.mapRightWrap.vehicle p.head>span.icon{ |
| 352 | + position: absolute; | ||
| 353 | + right: 10px; | ||
| 354 | + top: -6px; | ||
| 355 | + font-size: 24px; | ||
| 356 | + color: #7C8994; | ||
| 357 | + transition: all .5s ease; | ||
| 335 | 358 | ||
| 336 | } | 359 | } |
| 337 | 360 | ||
| 338 | -.mapRightWrap.vehicle p.head>span.icon>a.rotate{ | 361 | +.mapRightWrap.vehicle p.head>span.icon.rotate{ |
| 339 | transform:rotate(180deg); | 362 | transform:rotate(180deg); |
| 340 | } | 363 | } |
| 341 | 364 | ||
| 342 | 365 | ||
| 343 | -.mapRightWrap.vehicle p.head>span.icon>a:hover{ | 366 | +.mapRightWrap.vehicle p.head>span.icon:hover{ |
| 344 | color: #D8D5D5; | 367 | color: #D8D5D5; |
| 345 | } | 368 | } |
| 346 | 369 | ||
| @@ -489,7 +512,7 @@ html{ | @@ -489,7 +512,7 @@ html{ | ||
| 489 | } | 512 | } |
| 490 | 513 | ||
| 491 | .mapRightWrap.gaode.vehicle p.head{ | 514 | .mapRightWrap.gaode.vehicle p.head{ |
| 492 | - border-bottom: 1px solid #e5e5e5; | 515 | + border-bottom: 1px dashed #E2DFDF; |
| 493 | color: #7D7777; | 516 | color: #7D7777; |
| 494 | } | 517 | } |
| 495 | 518 |
src/main/resources/static/pages/mapmonitor/real/js/map_platform.js
| @@ -132,20 +132,24 @@ var realMap = (function() { | @@ -132,20 +132,24 @@ var realMap = (function() { | ||
| 132 | 132 | ||
| 133 | local.search(val); | 133 | local.search(val); |
| 134 | }, | 134 | }, |
| 135 | - drawLine: function(lineName, gpsList){ | ||
| 136 | - var drawCar = this.drawGpsMarker; | 135 | + drawLine: function(lineName, cb){ |
| 137 | //画线路 | 136 | //画线路 |
| 138 | var busline = new BMap.BusLineSearch(currentMap.map,{ | 137 | var busline = new BMap.BusLineSearch(currentMap.map,{ |
| 139 | renderOptions: {map: currentMap.map}, | 138 | renderOptions: {map: currentMap.map}, |
| 140 | onGetBusListComplete: function(result){ | 139 | onGetBusListComplete: function(result){ |
| 141 | - if(result) { | ||
| 142 | - var fstLine = result.getBusListItem(0); | ||
| 143 | - busline.getBusLine(fstLine); | ||
| 144 | - //画车 | ||
| 145 | - setTimeout(function(){ | ||
| 146 | - drawCar(gpsList); | ||
| 147 | - }, 500); | ||
| 148 | - } | 140 | + if(result) |
| 141 | + busline.getBusLine(result.getBusListItem(0)); | ||
| 142 | + else | ||
| 143 | + cb && cb(); | ||
| 144 | + }, | ||
| 145 | + onPolylinesSet: function(pline){ | ||
| 146 | + //pline.setStrokeColor('#333'); | ||
| 147 | + //console.log(pline.getStrokeColor()); | ||
| 148 | + console.log(pline); | ||
| 149 | + cb && cb(); | ||
| 150 | + }, | ||
| 151 | + onGetBusLineComplete: function(line){ | ||
| 152 | + line.getPolyline().setStrokeColor('#333'); | ||
| 149 | } | 153 | } |
| 150 | }); | 154 | }); |
| 151 | busline.getBusList(lineName); | 155 | busline.getBusList(lineName); |
| @@ -166,6 +170,9 @@ var realMap = (function() { | @@ -166,6 +170,9 @@ var realMap = (function() { | ||
| 166 | }); | 170 | }); |
| 167 | }, | 171 | }, |
| 168 | coordsConvert: function(list, cb){ | 172 | coordsConvert: function(list, cb){ |
| 173 | + if(list.length > 100) | ||
| 174 | + list = list.slice(0, 100); | ||
| 175 | + | ||
| 169 | var coords = ''; | 176 | var coords = ''; |
| 170 | //拼接GPS坐标,一次性转换 | 177 | //拼接GPS坐标,一次性转换 |
| 171 | for (var i = 0, item; item = list[i++];) | 178 | for (var i = 0, item; item = list[i++];) |
| @@ -313,10 +320,33 @@ var realMap = (function() { | @@ -313,10 +320,33 @@ var realMap = (function() { | ||
| 313 | function createLabel(gpsData){ | 320 | function createLabel(gpsData){ |
| 314 | var point = new BMap.Point(gpsData.bd_coord.x, gpsData.bd_coord.y) | 321 | var point = new BMap.Point(gpsData.bd_coord.x, gpsData.bd_coord.y) |
| 315 | //label | 322 | //label |
| 316 | - ,label = new BMap.Label(gpsData.nbbm, {position: point, offset: new BMap.Size(-25,-5)}); | ||
| 317 | - label.setStyle({borderColor: '#36C6D3',borderRadius: '5px', padding: '5px 9px 5px 9px', color: '#fff', backgroundColor: '#36C6D3'}); | 323 | + ,label = new BMap.Label(gpsData.nbbm.replace('-',''), {position: point, offset: new BMap.Size(-28,-10)}); |
| 324 | + label.setStyle({borderColor: bgColor(gpsData),borderRadius: '5px', padding: '3px 5px', color: tColor(gpsData), backgroundColor: bgColor(gpsData)}); | ||
| 318 | return label; | 325 | return label; |
| 319 | } | 326 | } |
| 320 | 327 | ||
| 328 | + /** | ||
| 329 | + * 颜色 | ||
| 330 | + */ | ||
| 331 | + var bgColor = function(g){ | ||
| 332 | + if(g.state == 0){ | ||
| 333 | + if(g.upDown == 0) | ||
| 334 | + return '#5E96D2'; | ||
| 335 | + else if(g.upDown == 1) | ||
| 336 | + return '#C92121'; | ||
| 337 | + else | ||
| 338 | + return 'red'; | ||
| 339 | + } | ||
| 340 | + else | ||
| 341 | + return "rgb(171, 171, 171)"; | ||
| 342 | + } | ||
| 343 | + | ||
| 344 | + var tColor = function(g){ | ||
| 345 | + if(g.state == 0) | ||
| 346 | + return "#fff"; | ||
| 347 | + else | ||
| 348 | + return "rgb(229, 229, 229)"; | ||
| 349 | + } | ||
| 350 | + | ||
| 321 | return real_map; | 351 | return real_map; |
| 322 | })(); | 352 | })(); |
| 323 | \ No newline at end of file | 353 | \ No newline at end of file |
src/main/resources/static/pages/mapmonitor/real/js/real.js
| @@ -87,15 +87,15 @@ | @@ -87,15 +87,15 @@ | ||
| 87 | $('#mapContainer').height($(pjaxContainer).height() + 49); | 87 | $('#mapContainer').height($(pjaxContainer).height() + 49); |
| 88 | 88 | ||
| 89 | mrw.html(spinnerLoad); | 89 | mrw.html(spinnerLoad); |
| 90 | - init(); | 90 | + realMap.init(); |
| 91 | + vehiclePanel.showDataLazy(); | ||
| 91 | 92 | ||
| 92 | - function init(){ | ||
| 93 | - //初始化地图 | 93 | + //function init(){ |
| 94 | + /*//初始化地图 | ||
| 94 | (function(){ | 95 | (function(){ |
| 95 | var f = arguments.callee; | 96 | var f = arguments.callee; |
| 96 | try { | 97 | try { |
| 97 | realMap.init(); | 98 | realMap.init(); |
| 98 | - console.log('realMap'); | ||
| 99 | } catch (e) { | 99 | } catch (e) { |
| 100 | setTimeout(f , 100); | 100 | setTimeout(f , 100); |
| 101 | } | 101 | } |
| @@ -108,6 +108,6 @@ | @@ -108,6 +108,6 @@ | ||
| 108 | } catch (e) { | 108 | } catch (e) { |
| 109 | setTimeout(f , 100); | 109 | setTimeout(f , 100); |
| 110 | } | 110 | } |
| 111 | - })(); | ||
| 112 | - } | 111 | + })();*/ |
| 112 | + //} | ||
| 113 | }(); | 113 | }(); |
| 114 | \ No newline at end of file | 114 | \ No newline at end of file |
src/main/resources/static/pages/mapmonitor/real/js/vehicle.js
| @@ -3,24 +3,83 @@ | @@ -3,24 +3,83 @@ | ||
| 3 | */ | 3 | */ |
| 4 | 4 | ||
| 5 | var vehiclePanel = (function() { | 5 | var vehiclePanel = (function() { |
| 6 | + | ||
| 6 | function getCurr(){ | 7 | function getCurr(){ |
| 7 | return realMap[realMap.getMap().fName]; | 8 | return realMap[realMap.getMap().fName]; |
| 8 | } | 9 | } |
| 10 | + var storage = window.localStorage; | ||
| 11 | + | ||
| 12 | + function closeAll(){ | ||
| 13 | + $('a[data-toggle=collapse]').collapse('hide'); | ||
| 14 | + } | ||
| 15 | + | ||
| 9 | 16 | ||
| 10 | // 手风琴收拢 | 17 | // 手风琴收拢 |
| 11 | $('.mapRightWrap').on('hide.bs.collapse', '.panel-collapse', function() { | 18 | $('.mapRightWrap').on('hide.bs.collapse', '.panel-collapse', function() { |
| 12 | - $(this).prev().find('span.icon a').addClass('rotate'); | 19 | + $(this).prev().find('span.icon').addClass('rotate'); |
| 13 | }); | 20 | }); |
| 14 | 21 | ||
| 15 | // 手风琴展开 | 22 | // 手风琴展开 |
| 16 | $('.mapRightWrap').on('show.bs.collapse', '.panel-collapse', function() { | 23 | $('.mapRightWrap').on('show.bs.collapse', '.panel-collapse', function() { |
| 17 | - $(this).prev().find('span.icon a').removeClass('rotate'); | 24 | + $(this).prev().find('span.icon').removeClass('rotate'); |
| 25 | + var lineCode = $(this).data('line'); | ||
| 26 | + | ||
| 27 | + //收拢其他 | ||
| 28 | + closeAll(); | ||
| 29 | + | ||
| 30 | + //该线路的GPS点 | ||
| 31 | + var showList = []; | ||
| 32 | + $.each(lineGps[lineCode], function(){ | ||
| 33 | + showList.push(allGps[this]); | ||
| 34 | + }) | ||
| 35 | + //在地图上画出线路 | ||
| 36 | + var mapObj = getCurr(); | ||
| 37 | + console.log('allGps', allGps, 'lineCode', lineCode); | ||
| 38 | + mapObj.drawLine($(this).data('name'), function(){ | ||
| 39 | + mapObj.drawGpsMarker(showList); | ||
| 40 | + }); | ||
| 41 | + | ||
| 42 | + //显示车辆列表 | ||
| 43 | + var htmlStr = template('vehicle_panel_collapse_temp', {list: showList}); | ||
| 44 | + $(this).html(htmlStr); | ||
| 45 | + }); | ||
| 46 | + | ||
| 47 | + //GPS刷新事件 | ||
| 48 | + var allGps = {}; | ||
| 49 | + var lineGps = {}; | ||
| 50 | + $('#mapContainer').on('gps_refresh', function(e, add, up){ | ||
| 51 | + var temp = add; | ||
| 52 | + if(up) | ||
| 53 | + temp = temp.concat(up); | ||
| 54 | + | ||
| 55 | + if(!$(this).is(":hidden")){ | ||
| 56 | + $.each(temp, function(){ | ||
| 57 | + allGps[this.deviceId] = this; | ||
| 58 | + }); | ||
| 59 | + | ||
| 60 | + $.each(add, function(){ | ||
| 61 | + if(!lineGps[this.lineId]) | ||
| 62 | + lineGps[this.lineId] = []; | ||
| 63 | + //线路和设备号映射 | ||
| 64 | + lineGps[this.lineId].push(this.deviceId); | ||
| 65 | + }) | ||
| 66 | + } | ||
| 18 | }); | 67 | }); |
| 19 | 68 | ||
| 20 | var exports = { | 69 | var exports = { |
| 21 | // 加载车辆信息 | 70 | // 加载车辆信息 |
| 22 | showData: function(){ | 71 | showData: function(){ |
| 23 | - var line = {code: 10103, name: '119路'}; | 72 | + //要展示的线路 |
| 73 | + var lines = JSON.parse(storage.getItem('lineControlItems')); | ||
| 74 | + | ||
| 75 | + var htmlStr = template('vehicle_panel_temp', {list: lines}); | ||
| 76 | + $('.mapRightWrap').html(htmlStr).addClass('vehicle'); | ||
| 77 | + //滚动条 | ||
| 78 | + $('.gps-line-wrap').slimscroll({ | ||
| 79 | + height: '100%', | ||
| 80 | + alwaysVisible: true | ||
| 81 | + }); | ||
| 82 | + /*var line = {code: 10103, name: '119路'}; | ||
| 24 | $get('/gps/real/line/' + line.code, null, function(data){ | 83 | $get('/gps/real/line/' + line.code, null, function(data){ |
| 25 | //过滤掉没有自编号和站点名为空的 | 84 | //过滤掉没有自编号和站点名为空的 |
| 26 | var newArray = []; | 85 | var newArray = []; |
| @@ -36,10 +95,10 @@ var vehiclePanel = (function() { | @@ -36,10 +95,10 @@ var vehiclePanel = (function() { | ||
| 36 | var mapObj; | 95 | var mapObj; |
| 37 | mapObj = getCurr(); | 96 | mapObj = getCurr(); |
| 38 | mapObj.drawLine(line.name, newArray); | 97 | mapObj.drawLine(line.name, newArray); |
| 39 | - }); | 98 | + });*/ |
| 40 | }, | 99 | }, |
| 41 | showDataLazy : function() { | 100 | showDataLazy : function() { |
| 42 | - setTimeout(exports.showData, 600); | 101 | + setTimeout(exports.showData, 1000); |
| 43 | } | 102 | } |
| 44 | }; | 103 | }; |
| 45 | 104 |
src/main/resources/static/pages/mapmonitor/real/real.html
| @@ -50,5 +50,4 @@ | @@ -50,5 +50,4 @@ | ||
| 50 | <script src="/pages/mapmonitor/real/js/temp.js"></script> | 50 | <script src="/pages/mapmonitor/real/js/temp.js"></script> |
| 51 | <script src="/pages/mapmonitor/real/js/real.js"></script> | 51 | <script src="/pages/mapmonitor/real/js/real.js"></script> |
| 52 | <script> | 52 | <script> |
| 53 | - console.log(111); | ||
| 54 | </script> | 53 | </script> |
src/main/resources/static/pages/mapmonitor/real/temps/vehicle.html
| 1 | <script id="vehicle_panel_temp" type="text/html"> | 1 | <script id="vehicle_panel_temp" type="text/html"> |
| 2 | +<div class="gps-line-wrap"> | ||
| 3 | +{{each list as line i}} | ||
| 4 | +<a data-toggle="collapse" href="#collapse_{{line.lineCode}}" aria-expanded="true" style="text-decoration:none"> | ||
| 2 | <p class="head" > | 5 | <p class="head" > |
| 3 | - 119路 | ||
| 4 | - <span class="icon"> | ||
| 5 | - <a data-toggle="collapse" href="#collapse_2_2" aria-expanded="true"> | 6 | + {{line.name}} |
| 7 | + <span class="icon rotate"> | ||
| 6 | <i class="fa fa-angle-double-down"></i> | 8 | <i class="fa fa-angle-double-down"></i> |
| 7 | - </a> | ||
| 8 | </span> | 9 | </span> |
| 9 | </p> | 10 | </p> |
| 10 | -<div id="collapse_2_2" class="panel-collapse collapse in"> | ||
| 11 | -{{each list as gpsObj i}} | ||
| 12 | - <div class="vehicle-item online" > | ||
| 13 | - <div class="text"> | ||
| 14 | - <span class="nbbm"><i class="fa fa-circle"></i> {{gpsObj.nbbm}}</span> | ||
| 15 | - | ||
| 16 | - <span style="font-size: 13px;">{{gpsObj.stationName}}站</span> | ||
| 17 | - </div> | ||
| 18 | - <div class="icon"> | ||
| 19 | - <i class="fa fa-angle-down"></i> | ||
| 20 | - </div> | ||
| 21 | - </div> | ||
| 22 | -{{/each}} | 11 | +</a> |
| 12 | +<div id="collapse_{{line.lineCode}}" class="panel-collapse collapse" data-line={{line.lineCode}} data-name={{line.name}}> | ||
| 23 | 13 | ||
| 24 | <!-- | 14 | <!-- |
| 25 | <div class="vehicle-item offline" > | 15 | <div class="vehicle-item offline" > |
| @@ -34,4 +24,20 @@ | @@ -34,4 +24,20 @@ | ||
| 34 | </div> | 24 | </div> |
| 35 | --> | 25 | --> |
| 36 | </div> | 26 | </div> |
| 27 | +{{/each}} | ||
| 28 | +</div> | ||
| 29 | +</script> | ||
| 30 | +<script id="vehicle_panel_collapse_temp" type="text/html"> | ||
| 31 | +{{each list as gpsObj i}} | ||
| 32 | + <div class="vehicle-item online" > | ||
| 33 | + <div class="text"> | ||
| 34 | + <span class="nbbm"><i class="fa fa-circle"></i> {{gpsObj.nbbm}}</span> | ||
| 35 | + | ||
| 36 | + <span style="font-size: 13px;">{{gpsObj.stationName}}</span> | ||
| 37 | + </div> | ||
| 38 | + <div class="icon"> | ||
| 39 | + <i class="fa fa-file-text-o"></i> | ||
| 40 | + </div> | ||
| 41 | + </div> | ||
| 42 | +{{/each}} | ||
| 37 | </script> | 43 | </script> |
| 38 | \ No newline at end of file | 44 | \ No newline at end of file |