Commit b84f5d16b64eca3b7cd4a12e07a8e3a85ef9954b

Authored by 王通
1 parent 3409b06a

1.闵行将线调->地图用做线路规划

src/main/resources/static/real_control_v2/mapmonitor/js/gps_tree.js
1 -var gb_map_gps_tree = (function () {  
2 -  
3 - var idBefore = 'map_tree_';  
4 - var _devices;  
5 -  
6 - var treeObj;  
7 - var jstreeChanged = function (e, node, event) {  
8 - gb_map_overlay_mge.refresh();  
9 - };  
10 -  
11 - var readyStatus;  
12 -  
13 - var init = function (cb) {  
14 - var allGps = gb_data_gps.allGps;  
15 - _devices = gb_common.get_keys(allGps);  
16 - //设备树  
17 - var treeData = gb_common.get_device_tree_data(allGps, idBefore);  
18 - treeObj = $('.real_right_gps_panel .gps_tree_list')  
19 - //节点初始化完成  
20 - .on('ready.jstree', function () {  
21 - //treeObj.jstree(true).open_all();  
22 - //删掉tree node a标签的 href值(避免鼠标悬停浏览器出现状态条)  
23 - $('.gps_tree_list .jstree-container-ul a.jstree-anchor').removeAttr('href');  
24 - })  
25 - //state插件 状态恢复完成  
26 - .on('state_ready.jstree', function () {  
27 - //绑定checkbox状态切换事件  
28 - treeObj.on('check_node.jstree uncheck_node.jstree', jstreeChanged);  
29 - readyStatus = true;  
30 - cb && cb();  
31 - })  
32 - .on('activate_node.jstree', function (e, n) {  
33 - var node = n.node;  
34 - if (node.a_attr && node.a_attr.type == 'device' && node.state.checked) {  
35 - var device = node.a_attr.device;  
36 - gb_map_overlay_mge._focus(device);  
37 - }  
38 - })  
39 - .jstree({  
40 - 'core': {  
41 - 'data': treeData,  
42 - 'check_callback': true  
43 - },  
44 - 'checkbox': {  
45 - 'keep_selected_style': false,  
46 - 'whole_node': false,  
47 - 'tie_selection': false  
48 - },  
49 - //local storage里的key  
50 - 'state': {  
51 - 'key': 'jstree_map_devices'  
52 - },  
53 - 'plugins': ['checkbox', 'state']  
54 - });  
55 - };  
56 -  
57 - var refresh = function () {  
58 - var jstreeInts = treeObj.jstree(true);  
59 - var oldChecks = jstreeInts.get_checked(true);  
60 - var treeData = gb_common.get_device_tree_data(gb_data_gps.allGps, idBefore);  
61 - jstreeInts.settings.core.data = treeData;  
62 - jstreeInts.refresh();  
63 - //恢复选中状态  
64 - setTimeout(function () {  
65 - $.each(oldChecks, function () {  
66 - jstreeInts.check_node(jstreeInts.get_node(this.a_attr.id));  
67 - });  
68 - }, 700);  
69 - };  
70 -  
71 - //創建新節點  
72 - var create_node = function (array, create_end_cb) {  
73 - if (!isArray(array))  
74 - array = [array];  
75 -  
76 - var jstreeInts = treeObj.jstree(true);  
77 - var len = array.length, i = 0;  
78 - (function () {  
79 - var f = arguments.callee;  
80 - if (i >= len) {  
81 - create_end_cb && create_end_cb();  
82 - return;  
83 - }  
84 -  
85 - var gps = array[i],  
86 - pId = idBefore + 'route_' + gps.lineId + '_' + gps.upDown;  
87 - //上下行节点  
88 - var routeNode = jstreeInts.get_node(pId);  
89 - if (!routeNode) {  
90 - //父节点不存在  
91 - create_route_node(gps.lineId, function () {  
92 - //重新获取上下行节点  
93 - routeNode = jstreeInts.get_node(pId);  
94 - appendDeviceNode(routeNode, gps, function () {  
95 - _devices.push(gps.deviceId);  
96 - i++;  
97 - f();  
98 - });  
99 - });  
100 - }  
101 - else {  
102 - appendDeviceNode(routeNode, gps, function () {  
103 - _devices.push(gps.deviceId);  
104 - i++;  
105 - f();  
106 - });  
107 - }  
108 - })();  
109 - };  
110 -  
111 - //创建线路和上下行节点  
112 - var create_route_node = function (lineCode, cb) {  
113 - var lineName = gb_data_basic.codeToLine[lineCode].name;  
114 - var id = treeObj.jstree(true).create_node('#', {  
115 - 'text': lineName,  
116 - 'a_attr': {'type': 'line', 'id': idBefore + 'line_' + lineCode},  
117 - 'state': {'opened': true},  
118 - 'children': [{  
119 - 'text': '上行',  
120 - 'a_attr': {  
121 - 'type': 'route',  
122 - 'route': lineCode + '_0',  
123 - 'id': idBefore + 'route_' + lineCode + '_0',  
124 - 'state': {'opened': true}  
125 - }  
126 - }, {  
127 - 'text': '下行',  
128 - 'a_attr': {  
129 - 'type': 'route',  
130 - 'route': lineCode + '_1',  
131 - 'id': idBefore + 'route_' + lineCode + '_1',  
132 - 'state': {'opened': true}  
133 - }  
134 - }]  
135 - }, 'last', cb);  
136 - };  
137 -  
138 - var appendDeviceNode = function (routeNode, gps, cb) {  
139 - if (!routeNode) {  
140 - return;  
141 - }  
142 -  
143 - //添加车辆節點  
144 - treeObj.jstree(true).create_node(routeNode, {  
145 - 'text': gps.nbbm,  
146 - 'a_attr': {  
147 - 'type': 'device',  
148 - 'device': gps.deviceId  
149 - },  
150 - 'data': {lineId: gps.lineId, upDown: gps.upDown},  
151 - 'icon': 'uk-icon-bus'  
152 - }, 'last', cb);  
153 - };  
154 -  
155 - var openLineNode = function (lineId, cb) {  
156 - var tree = treeObj.jstree(true);  
157 - tree.open_node(tree.get_node('map_tree_line_' + lineId), function () {  
158 - var upNode = tree.get_node('map_tree_route_' + lineId + '_0')  
159 - ,downNode = tree.get_node('map_tree_route_' + lineId + '_1');  
160 -  
161 - tree.open_node(upNode, function () {  
162 - tree.open_node(downNode, cb);  
163 - });  
164 - });  
165 - };  
166 -  
167 - var moveNode = function (i, gps) {  
168 - var tree = treeObj.jstree(true)  
169 - ,lineId = gps.lineId;  
170 - openLineNode(lineId, function () {  
171 - var node = tree.get_node('map_tree_device_' + gps.nbbm);  
172 - //移动节点  
173 - var parent = tree.get_node('map_tree_route_' + lineId + '_' + gps.upDown);  
174 - treeObj.jstree(true).move_node(node, parent);  
175 - });  
176 - };  
177 -  
178 - /**  
179 - * 上下行改变  
180 - * @param changeArray  
181 - */  
182 - var changeUpDown = function (changeArray) {  
183 - $.each(changeArray, moveNode);  
184 - };  
185 -  
186 - /**  
187 - * 更新节点  
188 - */  
189 - var abnormalsMapp = {  
190 - 'outBounds': '越界',  
191 - 'overspeed': '超速'  
192 - };  
193 - var update_node = function (ups) {  
194 - var tree = treeObj.jstree(true)  
195 - ,node,suffix;  
196 - $.each(ups, function () {  
197 - node = tree.get_node('map_tree_device_' + this.nbbm);  
198 - suffix=abnormalsMapp[this['abnormalStatus']];  
199 - suffix = suffix?'<a class="gps_tree_abnormal '+this['abnormalStatus']+'">'+suffix+'</a>':'';  
200 - tree.set_text(node, this.nbbm + suffix);  
201 - });  
202 - };  
203 -  
204 -  
205 - /**  
206 - * 搜索  
207 - */  
208 - var autocom = '.real_right_gps_panel .ral-gps-autocom'  
209 - ,_input = $('input', autocom);  
210 -  
211 - var autocomplete_source = function(release) {  
212 - var rs = [],  
213 - v = _input.val().toUpperCase(), count=0;  
214 -  
215 - $.each(gb_common.get_vals(gb_data_gps.allGps), function () {  
216 - if(this.nbbm.indexOf(v) != -1){  
217 - rs.push({  
218 - value: this.nbbm,  
219 - stationName: this.stationName?this.stationName:'',  
220 - dateStr: this.dateStr  
221 - });  
222 - count++;  
223 - }  
224 - if(count > 11)  
225 - return false;  
226 - });  
227 - release && release(rs);  
228 - };  
229 -  
230 - var selectitem = function (event, data, acobject) {  
231 -  
232 - var tree = treeObj.jstree(true)  
233 - var deviceId = gb_data_basic.nbbm2deviceMap()[data.value]  
234 - ,gps = gb_data_gps.findOne(deviceId);  
235 -  
236 - if(gps.upDown==-1){  
237 - UIkit.notify(data.value + " 未知上下行!", {pos:'top-center'});  
238 - return;  
239 - }  
240 - //展开线路节点  
241 - tree.open_node(tree.get_node('map_tree_line_' + gps.lineId), function () {  
242 - //展开走向节点  
243 - tree.open_node(tree.get_node('map_tree_route_' + gps.lineId + '_' + gps.upDown), function () {  
244 - //选中车辆  
245 - var id = 'map_tree_device_' + data.value;  
246 - var node = tree.get_node(id);  
247 - tree.check_node(node);  
248 -  
249 - var $e = $('#'+id);  
250 - treeObj.animate({  
251 - scrollTop: $e.offset().top - treeObj.offset().top + treeObj.scrollTop()  
252 - }, 500);  
253 - //地图定位  
254 - gb_map_overlay_mge._focus(gb_data_basic.nbbm2deviceMap()[data.value]);  
255 - }, false);  
256 - });  
257 - };  
258 - var result_template = '<script type="text/autocomplete">' +  
259 - ' <ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results ral-gps-autocom-results">' +  
260 - ' {{~items}}' +  
261 - ' <li data-value="{{ $item.value }}">' +  
262 - ' <a>' +  
263 - ' {{ $item.value }} <small class="desc"> {{ $item.stationName }}</small>' +  
264 - ' <div class="desc"><span>{{$item.dateStr}}</span></div>' +  
265 - ' </a>' +  
266 - ' </li>' +  
267 - ' {{/items}}' +  
268 - ' </ul>' +  
269 - '</script>';  
270 -  
271 - $(autocom).append(result_template);  
272 - UIkit.autocomplete(autocom, {  
273 - minLength: 1,  
274 - delay: 10,  
275 - source: autocomplete_source  
276 - }).on('selectitem.uk.autocomplete', selectitem);  
277 -  
278 -  
279 -  
280 - return {  
281 - init: init,  
282 - readyStatus: function () {  
283 - return readyStatus;  
284 - },  
285 - getChecked: function () {  
286 - return treeObj.jstree(true).get_checked(true);  
287 - },  
288 - all_devices: function () {  
289 - return _devices;  
290 - },  
291 - create_node: create_node,  
292 - changeUpDown: changeUpDown,  
293 - update_node: update_node,  
294 - refresh: refresh,  
295 - selectitem: selectitem  
296 - }; 1 +var gb_map_gps_tree = (function () {
  2 +
  3 + var idBefore = 'map_tree_';
  4 + var _devices;
  5 +
  6 + var treeObj;
  7 + var jstreeChanged = function (e, node, event) {
  8 + gb_map_overlay_mge.refresh();
  9 + };
  10 +
  11 + var readyStatus;
  12 +
  13 + var init = function (cb) {
  14 + var allGps = gb_data_gps.allGps;
  15 + _devices = gb_common.get_keys(allGps);
  16 + //设备树
  17 + var treeData = gb_common.get_device_tree_data(allGps, idBefore);
  18 + treeObj = $('.real_right_gps_panel .gps_tree_list')
  19 + //节点初始化完成
  20 + .on('ready.jstree', function () {
  21 + //treeObj.jstree(true).open_all();
  22 + //删掉tree node a标签的 href值(避免鼠标悬停浏览器出现状态条)
  23 + $('.gps_tree_list .jstree-container-ul a.jstree-anchor').removeAttr('href');
  24 + })
  25 + //state插件 状态恢复完成
  26 + .on('state_ready.jstree', function () {
  27 + //绑定checkbox状态切换事件
  28 + treeObj.on('check_node.jstree uncheck_node.jstree', jstreeChanged);
  29 + readyStatus = true;
  30 + cb && cb();
  31 + })
  32 + .on('activate_node.jstree', function (e, n) {
  33 + var node = n.node;
  34 + if (node.a_attr && node.a_attr.type == 'device' && node.state.checked) {
  35 + var device = node.a_attr.device;
  36 + gb_map_overlay_mge._focus(device);
  37 + }
  38 + })
  39 + .jstree({
  40 + 'core': {
  41 + 'data': treeData,
  42 + 'check_callback': true
  43 + },
  44 + 'checkbox': {
  45 + 'keep_selected_style': false,
  46 + 'whole_node': false,
  47 + 'tie_selection': false
  48 + },
  49 + //local storage里的key
  50 + 'state': {
  51 + 'key': 'jstree_map_devices'
  52 + },
  53 + 'plugins': ['checkbox', 'state']
  54 + });
  55 + };
  56 +
  57 + var refresh = function () {
  58 + var jstreeInts = treeObj.jstree(true);
  59 + var oldChecks = jstreeInts.get_checked(true);
  60 + var treeData = gb_common.get_device_tree_data(gb_data_gps.allGps, idBefore);
  61 + jstreeInts.settings.core.data = treeData;
  62 + jstreeInts.refresh();
  63 + jstreeInts.bind("refresh.jstree", function (event, data) {
  64 + $.each(oldChecks, function () {
  65 + jstreeInts.check_node(jstreeInts.get_node(this.a_attr.id));
  66 + });
  67 + $.each(gb_data_basic.activeLines, function (i) {
  68 + var lineNode = jstreeInts.get_node(idBefore + 'line_' + this.lineCode);
  69 + if (!lineNode) {
  70 + create_route_node(this.lineCode);
  71 + }
  72 + });
  73 + })
  74 + };
  75 +
  76 + //創建新節點
  77 + var create_node = function (array, create_end_cb) {
  78 + if (!isArray(array))
  79 + array = [array];
  80 +
  81 + var jstreeInts = treeObj.jstree(true);
  82 + var len = array.length, i = 0;
  83 + (function () {
  84 + var f = arguments.callee;
  85 + if (i >= len) {
  86 + create_end_cb && create_end_cb();
  87 + return;
  88 + }
  89 +
  90 + var gps = array[i],
  91 + pId = idBefore + 'route_' + gps.lineId + '_' + gps.upDown;
  92 + //上下行节点
  93 + var routeNode = jstreeInts.get_node(pId);
  94 + if (!routeNode) {
  95 + //父节点不存在
  96 + create_route_node(gps.lineId, function () {
  97 + //重新获取上下行节点
  98 + routeNode = jstreeInts.get_node(pId);
  99 + appendDeviceNode(routeNode, gps, function () {
  100 + _devices.push(gps.deviceId);
  101 + i++;
  102 + f();
  103 + });
  104 + });
  105 + }
  106 + else {
  107 + appendDeviceNode(routeNode, gps, function () {
  108 + _devices.push(gps.deviceId);
  109 + i++;
  110 + f();
  111 + });
  112 + }
  113 + })();
  114 + };
  115 +
  116 + //创建线路和上下行节点
  117 + var create_route_node = function (lineCode, cb) {
  118 + var lineName = gb_data_basic.codeToLine[lineCode].name;
  119 + var id = treeObj.jstree(true).create_node('#', {
  120 + 'text': lineName,
  121 + 'a_attr': {'type': 'line', 'id': idBefore + 'line_' + lineCode},
  122 + 'state': {'opened': true},
  123 + 'children': [{
  124 + 'text': '上行',
  125 + 'a_attr': {
  126 + 'type': 'route',
  127 + 'route': lineCode + '_0',
  128 + 'id': idBefore + 'route_' + lineCode + '_0',
  129 + 'state': {'opened': true}
  130 + }
  131 + }, {
  132 + 'text': '下行',
  133 + 'a_attr': {
  134 + 'type': 'route',
  135 + 'route': lineCode + '_1',
  136 + 'id': idBefore + 'route_' + lineCode + '_1',
  137 + 'state': {'opened': true}
  138 + }
  139 + }]
  140 + }, 'last', cb);
  141 + };
  142 +
  143 + var appendDeviceNode = function (routeNode, gps, cb) {
  144 + if (!routeNode) {
  145 + return;
  146 + }
  147 +
  148 + //添加车辆節點
  149 + treeObj.jstree(true).create_node(routeNode, {
  150 + 'text': gps.nbbm,
  151 + 'a_attr': {
  152 + 'type': 'device',
  153 + 'device': gps.deviceId
  154 + },
  155 + 'data': {lineId: gps.lineId, upDown: gps.upDown},
  156 + 'icon': 'uk-icon-bus'
  157 + }, 'last', cb);
  158 + };
  159 +
  160 + var openLineNode = function (lineId, cb) {
  161 + var tree = treeObj.jstree(true);
  162 + tree.open_node(tree.get_node('map_tree_line_' + lineId), function () {
  163 + var upNode = tree.get_node('map_tree_route_' + lineId + '_0')
  164 + ,downNode = tree.get_node('map_tree_route_' + lineId + '_1');
  165 +
  166 + tree.open_node(upNode, function () {
  167 + tree.open_node(downNode, cb);
  168 + });
  169 + });
  170 + };
  171 +
  172 + var moveNode = function (i, gps) {
  173 + var tree = treeObj.jstree(true)
  174 + ,lineId = gps.lineId;
  175 + openLineNode(lineId, function () {
  176 + var node = tree.get_node('map_tree_device_' + gps.nbbm);
  177 + //移动节点
  178 + var parent = tree.get_node('map_tree_route_' + lineId + '_' + gps.upDown);
  179 + treeObj.jstree(true).move_node(node, parent);
  180 + });
  181 + };
  182 +
  183 + /**
  184 + * 上下行改变
  185 + * @param changeArray
  186 + */
  187 + var changeUpDown = function (changeArray) {
  188 + $.each(changeArray, moveNode);
  189 + };
  190 +
  191 + /**
  192 + * 更新节点
  193 + */
  194 + var abnormalsMapp = {
  195 + 'outBounds': '越界',
  196 + 'overspeed': '超速'
  197 + };
  198 + var update_node = function (ups) {
  199 + var tree = treeObj.jstree(true)
  200 + ,node,suffix;
  201 + $.each(ups, function () {
  202 + node = tree.get_node('map_tree_device_' + this.nbbm);
  203 + suffix=abnormalsMapp[this['abnormalStatus']];
  204 + suffix = suffix?'<a class="gps_tree_abnormal '+this['abnormalStatus']+'">'+suffix+'</a>':'';
  205 + tree.set_text(node, this.nbbm + suffix);
  206 + });
  207 + };
  208 +
  209 +
  210 + /**
  211 + * 搜索
  212 + */
  213 + var autocom = '.real_right_gps_panel .ral-gps-autocom'
  214 + ,_input = $('input', autocom);
  215 +
  216 + var autocomplete_source = function(release) {
  217 + var rs = [],
  218 + v = _input.val().toUpperCase(), count=0;
  219 +
  220 + $.each(gb_common.get_vals(gb_data_gps.allGps), function () {
  221 + if(this.nbbm.indexOf(v) != -1){
  222 + rs.push({
  223 + value: this.nbbm,
  224 + stationName: this.stationName?this.stationName:'',
  225 + dateStr: this.dateStr
  226 + });
  227 + count++;
  228 + }
  229 + if(count > 11)
  230 + return false;
  231 + });
  232 + release && release(rs);
  233 + };
  234 +
  235 + var selectitem = function (event, data, acobject) {
  236 +
  237 + var tree = treeObj.jstree(true)
  238 + var deviceId = gb_data_basic.nbbm2deviceMap()[data.value]
  239 + ,gps = gb_data_gps.findOne(deviceId);
  240 +
  241 + if(gps.upDown==-1){
  242 + UIkit.notify(data.value + " 未知上下行!", {pos:'top-center'});
  243 + return;
  244 + }
  245 + //展开线路节点
  246 + tree.open_node(tree.get_node('map_tree_line_' + gps.lineId), function () {
  247 + //展开走向节点
  248 + tree.open_node(tree.get_node('map_tree_route_' + gps.lineId + '_' + gps.upDown), function () {
  249 + //选中车辆
  250 + var id = 'map_tree_device_' + data.value;
  251 + var node = tree.get_node(id);
  252 + tree.check_node(node);
  253 +
  254 + var $e = $('#'+id);
  255 + treeObj.animate({
  256 + scrollTop: $e.offset().top - treeObj.offset().top + treeObj.scrollTop()
  257 + }, 500);
  258 + //地图定位
  259 + gb_map_overlay_mge._focus(gb_data_basic.nbbm2deviceMap()[data.value]);
  260 + }, false);
  261 + });
  262 + };
  263 + var result_template = '<script type="text/autocomplete">' +
  264 + ' <ul class="uk-nav uk-nav-autocomplete uk-autocomplete-results ral-gps-autocom-results">' +
  265 + ' {{~items}}' +
  266 + ' <li data-value="{{ $item.value }}">' +
  267 + ' <a>' +
  268 + ' {{ $item.value }} <small class="desc"> {{ $item.stationName }}</small>' +
  269 + ' <div class="desc"><span>{{$item.dateStr}}</span></div>' +
  270 + ' </a>' +
  271 + ' </li>' +
  272 + ' {{/items}}' +
  273 + ' </ul>' +
  274 + '</script>';
  275 +
  276 + $(autocom).append(result_template);
  277 + UIkit.autocomplete(autocom, {
  278 + minLength: 1,
  279 + delay: 10,
  280 + source: autocomplete_source
  281 + }).on('selectitem.uk.autocomplete', selectitem);
  282 +
  283 +
  284 +
  285 + return {
  286 + init: init,
  287 + readyStatus: function () {
  288 + return readyStatus;
  289 + },
  290 + getChecked: function () {
  291 + return treeObj.jstree(true).get_checked(true);
  292 + },
  293 + all_devices: function () {
  294 + return _devices;
  295 + },
  296 + create_node: create_node,
  297 + changeUpDown: changeUpDown,
  298 + update_node: update_node,
  299 + refresh: refresh,
  300 + selectitem: selectitem
  301 + };
297 })(); 302 })();
298 \ No newline at end of file 303 \ No newline at end of file
src/main/resources/static/real_control_v2/mapmonitor/js/map_overlay_manager.js
1 -var gb_map_overlay_mge = (function () {  
2 -  
3 - var storage = window.localStorage;  
4 -  
5 - var temps;  
6 - $.get('/real_control_v2/mapmonitor/fragments/map_infowindow.html', function (dom) {  
7 - temps = gb_common.compileTempByDom(dom, {compress: true});  
8 - });  
9 -  
10 - var $abnormNoticePanel = $('.c_b_abnorm_notice');  
11 - var gpsRefresh = function (addArr, upArr, upDownChange, overspeedList) {  
12 - if(!$('.main-container .map-panel').is(':visible'))  
13 - return;  
14 - //如果地图正在重绘,暂时不刷新GPS  
15 - if(reDrawing)  
16 - return;  
17 - //var all = addArr.concat(upArr).concat(upDownChange);  
18 - gpsRefreshAll(addArr, upArr, upDownChange);  
19 -  
20 - //渲染超速信息  
21 - overspeedList.sort(overspeed_sort);  
22 - var htmlStr = template('map_abnorm_overspeed_list-temp', {list: overspeedList});  
23 - $abnormNoticePanel.html(htmlStr).scrollTop($abnormNoticePanel[0].scrollHeight);  
24 - };  
25 -  
26 - var overspeed_sort = function (a, b) {  
27 - if(a.ets && !b.ets)  
28 - return -1;  
29 - if(!a.ets && b.ets)  
30 - return 1;  
31 - return a.st - b.st;  
32 - };  
33 -  
34 - /**  
35 - * 超速点击  
36 - */  
37 - $abnormNoticePanel.on('click', '.c_b_item', function () {  
38 - var nbbm = $(this).data('nbbm');  
39 - gb_map_gps_tree.selectitem(null, {value: nbbm});  
40 - });  
41 -  
42 - var gpsRefreshAll = function (addArr, upArr, upDownChange) {  
43 - //更新设备树菜单  
44 - if(gb_map_gps_tree.readyStatus()){  
45 - gb_map_gps_tree.create_node(addArr);  
46 - gb_map_gps_tree.update_node(upArr);  
47 - gb_map_gps_tree.changeUpDown(upDownChange);  
48 - }  
49 -  
50 - //更新地图  
51 - var all = addArr.concat(upArr).concat(upDownChange);  
52 - gb_map_imap.call('drawRealGpsMarker', {gpsList: all});  
53 - };  
54 -  
55 - var reload_gps = function () {  
56 - var array = gb_common.get_vals(gb_data_gps.allGps);  
57 - gb_map_gps_tree.refresh();  
58 - gb_map_imap.call('drawRealGpsMarker', {gpsList: array});  
59 - };  
60 -  
61 - var deviceFilter = function (node) {  
62 - return node.a_attr && node.a_attr.type=='device';  
63 - };  
64 -  
65 - //绘制线路走向  
66 - var drawAllSection=function () {  
67 - //绘制线路走向  
68 - var lines=JSON.parse(storage.getItem('lineControlItems'));  
69 - $.each(lines, function () {  
70 - //从storage里获取路由数据  
71 - var lineCode=this.lineCode;  
72 - var route = JSON.parse(storage.getItem(lineCode + '_route'));  
73 - //上行  
74 - gb_map_imap.call('drawLine', {  
75 - route: route,  
76 - style: {strokeWeight:6, strokeColor: gb_map_config.getConfig().section.color.up},  
77 - id: lineCode+'_0',  
78 - upDown: 0,  
79 - hide: true  
80 - });  
81 - //下行  
82 - gb_map_imap.call('drawLine', {  
83 - route: route,  
84 - style: {strokeWeight:6, strokeColor: gb_map_config.getConfig().section.color.down},  
85 - id: lineCode+'_1',  
86 - upDown: 1,  
87 - hide: true  
88 - });  
89 -  
90 - });  
91 - };  
92 -  
93 - //根据选中项显示路段  
94 - var showSection = function (chs) {  
95 - var idx = {};  
96 - $.each(chs, function () {  
97 - idx[this.data.lineId+'_'+this.data.upDown]=1;  
98 - });  
99 -  
100 - gb_map_imap.call('refreshPolyline', {idx: gb_common.get_keys(idx)});  
101 - };  
102 -  
103 -  
104 - //是否正在重绘  
105 - var reDrawing;  
106 - var reDraw = function () {  
107 - reDrawing = true;  
108 -  
109 - gb_map_imap.call('clearAll');  
110 -  
111 - try{  
112 - drawAllSection();  
113 - }catch (e){  
114 - console.log(e);  
115 - }  
116 - //重绘GPS  
117 - gb_map_imap.call('drawRealGpsMarker', {gpsList: gb_common.get_vals(gb_data_gps.allGps)});  
118 -  
119 - showOverlayByChecks();  
120 - //显示路段  
121 - showSection(getCheckedDevice());  
122 -  
123 - reDrawing = false;  
124 - };  
125 -  
126 - //重绘GPS  
127 - var reDrawGps = function () {  
128 - reDrawing = true;  
129 - gb_map_imap.call('clearAllGps');  
130 - //重绘GPS  
131 - gb_map_imap.call('drawRealGpsMarker', {gpsList: gb_common.get_vals(gb_data_gps.allGps)});  
132 -  
133 - showOverlayByChecks();  
134 - reDrawing = false;  
135 - };  
136 -  
137 - var init = function () {  
138 - reDraw();  
139 - //注册GPS刷新事件  
140 - gb_data_gps.registerCallback(gpsRefresh);  
141 -  
142 - centerToRational();  
143 - };  
144 -  
145 -  
146 - var showOverlayByChecks = function () {  
147 - var chs = getCheckedDevice(),chsMap={};  
148 - $.each(chs, function () {  
149 - chsMap[this.a_attr.device]=true;  
150 - });  
151 -  
152 - gb_map_imap.call('showGpsMarker', {chs: chsMap});  
153 -  
154 - //路段  
155 - showSection(chs);  
156 -  
157 - };  
158 -  
159 - var _focus = function (deviceId) {  
160 - gb_map_imap.call('goToMarker', {deviceId: deviceId});  
161 - //打开信息窗口  
162 - gb_map_imap.call('openWindow',{deviceId: deviceId});  
163 - };  
164 -  
165 - //站点获得焦点  
166 - var _focus_station = function (station) {  
167 - gb_map_imap.call('goToStation', station.stationCode);  
168 - };  
169 -  
170 - //停车场获得焦点  
171 - var _focus_carpark = function (carpark) {  
172 - //console.log('_focus_carpark', carpark);  
173 - gb_map_imap.call('goToCarpark', carpark.parkCode);  
174 - };  
175 -  
176 - function getCheckedDevice() {  
177 - return gb_map_gps_tree.getChecked().filter(deviceFilter);  
178 - }  
179 -  
180 - //绘制站点  
181 - var drawStation = function () {  
182 - var list = gb_map_spatial_data.getCheckedStation();  
183 - //绘制站点  
184 - gb_map_imap.call('drawStationMarker', {list: list});  
185 - //绘制电子围栏  
186 - drawElectronicFence(list);  
187 - };  
188 -  
189 - //绘制电子围栏  
190 - var drawElectronicFence = function (list) {  
191 - var config = gb_map_config.getConfig().spatialData;  
192 - if(!config.electronicFence)  
193 - return;  
194 -  
195 - if(!list){  
196 - list = gb_map_spatial_data.getCheckedStation();  
197 - }  
198 -  
199 -  
200 - gb_map_imap.call('hideAllCircles');  
201 - $.each(list, function () {  
202 - fun=this.shapesType=='r'?drawCircle:drawPolygon;  
203 - fun(this);  
204 - });  
205 - };  
206 -  
207 - //绘制停车场  
208 - var drawCarpark = function () {  
209 - var list = gb_map_spatial_data.gteCheckedCarpark();  
210 - gb_map_imap.call('drawCarpark', {list: list});  
211 - };  
212 -  
213 - var drawCircle=function (data) {  
214 - var config = gb_map_config.getConfig().section.color;  
215 - var color = data.directions==0?config.up:config.down;  
216 -  
217 - var opt = {  
218 - lon: data.lon,  
219 - lat: data.lat,  
220 - text: data.stationName,  
221 - color: color,  
222 - weight: 2,  
223 - radius: parseFloat(data.radius),  
224 - id: data.stationCode  
225 - };  
226 -  
227 - gb_map_imap.call('drawCircle', opt);  
228 - };  
229 -  
230 - var drawPolygon=function (data) {  
231 - var config = gb_map_config.getConfig().section.color;  
232 - var color = data.directions==0?config.up:config.down;  
233 -  
234 - var opt = {  
235 - //id:data.stationCode,  
236 - color: color,  
237 - weight: 2,  
238 - station: data  
239 - };  
240 -  
241 - gb_map_imap.call('drawPolygon', opt);  
242 - };  
243 -  
244 - //地图居中至合理的位置  
245 - var centerToRational=function () {  
246 - var chs=getCheckedDevice();  
247 - if(chs && chs.length > 0){  
248 - var id=chs[0].data.lineId+'_'+chs[0].data.upDown;  
249 - gb_map_imap.call('centerToLine', {id: id});  
250 - }  
251 - };  
252 -  
253 - return {  
254 - init: init,  
255 - refresh: showOverlayByChecks,  
256 - _focus: _focus,  
257 - _focus_station: _focus_station,  
258 - _focus_carpark: _focus_carpark,  
259 - map_gps_win_temp: function (data) {  
260 - return temps['map-win-gps-detail-temp'](data);  
261 - },  
262 - map_station_win_temp: function (data) {  
263 - return temps['map-win-station-detail-temp'](data);  
264 - },  
265 - map_carpark_win_temp: function (data) {  
266 - return temps['map-win-carpark-detail-temp'](data);  
267 - },  
268 - reDraw: reDraw,  
269 - reDrawGps: reDrawGps,  
270 - getCheckedDevice: getCheckedDevice,  
271 - drawStation: drawStation,  
272 - drawElectronicFence: drawElectronicFence,  
273 - drawCarpark: drawCarpark,  
274 - centerToRational:centerToRational,  
275 - reload_gps: reload_gps  
276 - }; 1 +var gb_map_overlay_mge = (function () {
  2 +
  3 + var storage = window.localStorage;
  4 +
  5 + var temps;
  6 + $.get('/real_control_v2/mapmonitor/fragments/map_infowindow.html', function (dom) {
  7 + temps = gb_common.compileTempByDom(dom, {compress: true});
  8 + });
  9 +
  10 + var $abnormNoticePanel = $('.c_b_abnorm_notice');
  11 + var gpsRefresh = function (addArr, upArr, upDownChange, overspeedList) {
  12 + if(!$('.main-container .map-panel').is(':visible'))
  13 + return;
  14 + //如果地图正在重绘,暂时不刷新GPS
  15 + if(reDrawing)
  16 + return;
  17 + //var all = addArr.concat(upArr).concat(upDownChange);
  18 + gpsRefreshAll(addArr, upArr, upDownChange);
  19 +
  20 + //渲染超速信息
  21 + overspeedList.sort(overspeed_sort);
  22 + var htmlStr = template('map_abnorm_overspeed_list-temp', {list: overspeedList});
  23 + $abnormNoticePanel.html(htmlStr).scrollTop($abnormNoticePanel[0].scrollHeight);
  24 + };
  25 +
  26 + var overspeed_sort = function (a, b) {
  27 + if(a.ets && !b.ets)
  28 + return -1;
  29 + if(!a.ets && b.ets)
  30 + return 1;
  31 + return a.st - b.st;
  32 + };
  33 +
  34 + /**
  35 + * 超速点击
  36 + */
  37 + $abnormNoticePanel.on('click', '.c_b_item', function () {
  38 + var nbbm = $(this).data('nbbm');
  39 + gb_map_gps_tree.selectitem(null, {value: nbbm});
  40 + });
  41 +
  42 + var gpsRefreshAll = function (addArr, upArr, upDownChange) {
  43 + //更新设备树菜单
  44 + if(gb_map_gps_tree.readyStatus()){
  45 + gb_map_gps_tree.create_node(addArr);
  46 + gb_map_gps_tree.update_node(upArr);
  47 + gb_map_gps_tree.changeUpDown(upDownChange);
  48 + }
  49 +
  50 + //更新地图
  51 + var all = addArr.concat(upArr).concat(upDownChange);
  52 + gb_map_imap.call('drawRealGpsMarker', {gpsList: all});
  53 + };
  54 +
  55 + var reload_gps = function () {
  56 + var array = gb_common.get_vals(gb_data_gps.allGps);
  57 + gb_map_gps_tree.refresh();
  58 + gb_map_imap.call('drawRealGpsMarker', {gpsList: array});
  59 + };
  60 +
  61 + var deviceFilter = function (node) {
  62 + return node.a_attr && node.a_attr.type=='device';
  63 + };
  64 +
  65 + var routeFilter = function (node) {
  66 + return node.a_attr && node.a_attr.type=='route';
  67 + };
  68 +
  69 + //绘制线路走向
  70 + var drawAllSection=function () {
  71 + //绘制线路走向
  72 + var lines=JSON.parse(storage.getItem('lineControlItems'));
  73 + $.each(lines, function () {
  74 + //从storage里获取路由数据
  75 + var lineCode=this.lineCode;
  76 + var route = JSON.parse(storage.getItem(lineCode + '_route'));
  77 + //上行
  78 + gb_map_imap.call('drawLine', {
  79 + route: route,
  80 + style: {strokeWeight:6, strokeColor: gb_map_config.getConfig().section.color.up},
  81 + id: lineCode+'_0',
  82 + upDown: 0,
  83 + hide: true
  84 + });
  85 + //下行
  86 + gb_map_imap.call('drawLine', {
  87 + route: route,
  88 + style: {strokeWeight:6, strokeColor: gb_map_config.getConfig().section.color.down},
  89 + id: lineCode+'_1',
  90 + upDown: 1,
  91 + hide: true
  92 + });
  93 +
  94 + });
  95 + };
  96 +
  97 + //根据选中项显示路段
  98 + var showSection = function (chr) {
  99 + var idx = {};
  100 + $.each(chr, function () {
  101 + idx[this.a_attr.route]=1;
  102 + });
  103 +
  104 + gb_map_imap.call('refreshPolyline', {idx: gb_common.get_keys(idx)});
  105 + };
  106 +
  107 + //是否正在重绘
  108 + var reDrawing;
  109 + var reDraw = function () {
  110 + reDrawing = true;
  111 +
  112 + gb_map_imap.call('clearAll');
  113 +
  114 + try{
  115 + drawAllSection();
  116 + }catch (e){
  117 + console.log(e);
  118 + }
  119 + //重绘GPS
  120 + gb_map_imap.call('drawRealGpsMarker', {gpsList: gb_common.get_vals(gb_data_gps.allGps)});
  121 +
  122 + showOverlayByChecks();
  123 + //显示路段
  124 + showSection(getCheckedRoute());
  125 +
  126 + reDrawing = false;
  127 + };
  128 +
  129 + //重绘GPS
  130 + var reDrawGps = function () {
  131 + reDrawing = true;
  132 + gb_map_imap.call('clearAllGps');
  133 + //重绘GPS
  134 + gb_map_imap.call('drawRealGpsMarker', {gpsList: gb_common.get_vals(gb_data_gps.allGps)});
  135 +
  136 + showOverlayByChecks();
  137 + reDrawing = false;
  138 + };
  139 +
  140 + var init = function () {
  141 + reDraw();
  142 + //注册GPS刷新事件
  143 + gb_data_gps.registerCallback(gpsRefresh);
  144 +
  145 + centerToRational();
  146 + };
  147 +
  148 +
  149 + var showOverlayByChecks = function () {
  150 + var chs = getCheckedDevice(),chsMap={},chr = getCheckedRoute();
  151 + $.each(chs, function () {
  152 + chsMap[this.a_attr.device]=true;
  153 + });
  154 +
  155 + gb_map_imap.call('showGpsMarker', {chs: chsMap});
  156 +
  157 + //路段
  158 + showSection(chr);
  159 +
  160 + };
  161 +
  162 + var _focus = function (deviceId) {
  163 + gb_map_imap.call('goToMarker', {deviceId: deviceId});
  164 + //打开信息窗口
  165 + gb_map_imap.call('openWindow',{deviceId: deviceId});
  166 + };
  167 +
  168 + //站点获得焦点
  169 + var _focus_station = function (station) {
  170 + gb_map_imap.call('goToStation', station.stationCode);
  171 + };
  172 +
  173 + //停车场获得焦点
  174 + var _focus_carpark = function (carpark) {
  175 + //console.log('_focus_carpark', carpark);
  176 + gb_map_imap.call('goToCarpark', carpark.parkCode);
  177 + };
  178 +
  179 + function getCheckedDevice() {
  180 + return gb_map_gps_tree.getChecked().filter(deviceFilter);
  181 + }
  182 +
  183 + function getCheckedRoute() {
  184 + return gb_map_gps_tree.getChecked().filter(routeFilter);
  185 + }
  186 +
  187 + //绘制站点
  188 + var drawStation = function () {
  189 + var list = gb_map_spatial_data.getCheckedStation();
  190 + //绘制站点
  191 + gb_map_imap.call('drawStationMarker', {list: list});
  192 + //绘制电子围栏
  193 + drawElectronicFence(list);
  194 + };
  195 +
  196 + //绘制电子围栏
  197 + var drawElectronicFence = function (list) {
  198 + var config = gb_map_config.getConfig().spatialData;
  199 + if(!config.electronicFence)
  200 + return;
  201 +
  202 + if(!list){
  203 + list = gb_map_spatial_data.getCheckedStation();
  204 + }
  205 +
  206 +
  207 + gb_map_imap.call('hideAllCircles');
  208 + $.each(list, function () {
  209 + fun=this.shapesType=='r'?drawCircle:drawPolygon;
  210 + fun(this);
  211 + });
  212 + };
  213 +
  214 + //绘制停车场
  215 + var drawCarpark = function () {
  216 + var list = gb_map_spatial_data.gteCheckedCarpark();
  217 + gb_map_imap.call('drawCarpark', {list: list});
  218 + };
  219 +
  220 + var drawCircle=function (data) {
  221 + var config = gb_map_config.getConfig().section.color;
  222 + var color = data.directions==0?config.up:config.down;
  223 +
  224 + var opt = {
  225 + lon: data.lon,
  226 + lat: data.lat,
  227 + text: data.stationName,
  228 + color: color,
  229 + weight: 2,
  230 + radius: parseFloat(data.radius),
  231 + id: data.stationCode
  232 + };
  233 +
  234 + gb_map_imap.call('drawCircle', opt);
  235 + };
  236 +
  237 + var drawPolygon=function (data) {
  238 + var config = gb_map_config.getConfig().section.color;
  239 + var color = data.directions==0?config.up:config.down;
  240 +
  241 + var opt = {
  242 + //id:data.stationCode,
  243 + color: color,
  244 + weight: 2,
  245 + station: data
  246 + };
  247 +
  248 + gb_map_imap.call('drawPolygon', opt);
  249 + };
  250 +
  251 + //地图居中至合理的位置
  252 + var centerToRational=function () {
  253 + var chs=getCheckedDevice();
  254 + if(chs && chs.length > 0){
  255 + var id=chs[0].data.lineId+'_'+chs[0].data.upDown;
  256 + gb_map_imap.call('centerToLine', {id: id});
  257 + }
  258 + };
  259 +
  260 + return {
  261 + init: init,
  262 + refresh: showOverlayByChecks,
  263 + _focus: _focus,
  264 + _focus_station: _focus_station,
  265 + _focus_carpark: _focus_carpark,
  266 + map_gps_win_temp: function (data) {
  267 + return temps['map-win-gps-detail-temp'](data);
  268 + },
  269 + map_station_win_temp: function (data) {
  270 + return temps['map-win-station-detail-temp'](data);
  271 + },
  272 + map_carpark_win_temp: function (data) {
  273 + return temps['map-win-carpark-detail-temp'](data);
  274 + },
  275 + reDraw: reDraw,
  276 + reDrawGps: reDrawGps,
  277 + getCheckedDevice: getCheckedDevice,
  278 + drawStation: drawStation,
  279 + drawElectronicFence: drawElectronicFence,
  280 + drawCarpark: drawCarpark,
  281 + centerToRational:centerToRational,
  282 + reload_gps: reload_gps
  283 + };
277 })(); 284 })();
278 \ No newline at end of file 285 \ No newline at end of file