Commit f5ea96b03ea3d018285485284b981d4bc8d46b81
1 parent
e350383f
1.
Showing
1 changed file
with
121 additions
and
36 deletions
src/main/resources/static/pages/base/stationroute/js/routes-operation.js
| ... | ... | @@ -17,6 +17,8 @@ var RoutesOperation = (function () { |
| 17 | 17 | var road_win_show_p; |
| 18 | 18 | // 被编辑的路段 |
| 19 | 19 | var editPolyline; |
| 20 | + // 前置站点 | |
| 21 | + var premise; | |
| 20 | 22 | var styleOptions = { |
| 21 | 23 | strokeColor : "blue", |
| 22 | 24 | fillColor : "blue", |
| ... | ... | @@ -30,6 +32,16 @@ var RoutesOperation = (function () { |
| 30 | 32 | strokeWeight: 2, |
| 31 | 33 | strokeOpacity: 0.7 |
| 32 | 34 | } |
| 35 | + var polygonDmOptions = { | |
| 36 | + isOpen : false, | |
| 37 | + enableDrawingTool : false, | |
| 38 | + drawingToolOptions : { | |
| 39 | + anchor : BMAP_ANCHOR_TOP_RIGHT, | |
| 40 | + offset : new BMap.Size(5, 5), | |
| 41 | + scale : 0.8 | |
| 42 | + }, | |
| 43 | + polygonOptions : styleOptions | |
| 44 | + } | |
| 33 | 45 | var operation = { |
| 34 | 46 | getAddStationRoute: function () { |
| 35 | 47 | return addStationRoute; |
| ... | ... | @@ -72,16 +84,18 @@ var RoutesOperation = (function () { |
| 72 | 84 | } |
| 73 | 85 | RoutesService.getAllLineVersions(lineId, function(lineVersions) { |
| 74 | 86 | $('#versions option').remove(); |
| 75 | - for (var i = 0;i < lineVersions.length;i++) { | |
| 76 | - var lineVersion = lineVersions[i], selected = false; | |
| 87 | + for (var i = 0, selected = 0;i < lineVersions.length;i++) { | |
| 88 | + var lineVersion = lineVersions[i]; | |
| 77 | 89 | if (lineVersion.status == 1 || i == lineVersions.length - 1) { |
| 78 | - operation.TreeUpOrDown(lineId, '0', lineVersion.versions); | |
| 79 | - operation.TreeUpOrDown(lineId, '1', lineVersion.versions); | |
| 80 | 90 | status = lineVersion.status; |
| 81 | 91 | versions = lineVersion.versions; |
| 82 | - selected = true; | |
| 92 | + selected++; | |
| 93 | + } | |
| 94 | + $('#versions').append('<option value="' + lineVersion.versions + '" status="' + lineVersion.status + (selected === 1 ? '" selected' : '"') + '>' + lineVersion.name + ' (' + lineVersion.versions + ')' + '</option>'); | |
| 95 | + if (selected === 1) { | |
| 96 | + operation.TreeUpOrDown(lineId, '0', lineVersion.versions); | |
| 97 | + operation.TreeUpOrDown(lineId, '1', lineVersion.versions); | |
| 83 | 98 | } |
| 84 | - $('#versions').append('<option value=' + lineVersion.versions + ' status=' + lineVersion.status + (selected ? ' selected' : '') + '>' + lineVersion.name + ' (' + lineVersion.versions + ')' + '</option>'); | |
| 85 | 99 | } |
| 86 | 100 | operation.setTiteText(lineId); |
| 87 | 101 | operation.registerEvents(); |
| ... | ... | @@ -118,7 +132,7 @@ var RoutesOperation = (function () { |
| 118 | 132 | |
| 119 | 133 | $("#versions").on('change', function() { |
| 120 | 134 | versions = $(this).val(); |
| 121 | - status = $($(this).find("option:selected")[0]).prop("status"); | |
| 135 | + status = $('option:selected', $(this)).attr('status'); | |
| 122 | 136 | $('#upLine').click(); |
| 123 | 137 | |
| 124 | 138 | if (status > 0) { |
| ... | ... | @@ -405,14 +419,22 @@ var RoutesOperation = (function () { |
| 405 | 419 | |
| 406 | 420 | if(status > 0){ |
| 407 | 421 | htm += '<div>' + |
| 408 | - '<button class="info_win_btn" onclick="RoutesOperation.editCenterPoint(' + stationRoute.id+','+stationRoute.directions + ')">站级中心点</button>' + | |
| 409 | 422 | '<button class="info_win_btn" onclick="RoutesOperation.editStation(' + stationRoute.id+','+stationRoute.directions + ')">修改</button>' + |
| 410 | 423 | '<button class="info_win_btn" onclick="RoutesOperation.destroyStation('+ stationRoute.id + ','+stationRoute.line.id+','+stationRoute.directions+')">撤销</button>' + |
| 411 | - '<button class="info_win_btn" id="addBetweenStationRoad" onclick="RoutesOperation.addBetweenStationRoad(' + stationRoute.id + ')">添加站点间路段</button>' + | |
| 412 | - '</div>'; | |
| 424 | + '<button class="info_win_btn" onclick="RoutesOperation.editCenterPoint(' + stationRoute.id+','+stationRoute.directions + ')">站级中心点</button>'; | |
| 425 | + if (stationRoute.stationMark == 'E') { | |
| 426 | + htm += '<button class="info_win_btn" onclick="RoutesOperation.geoPremise(' + stationRoute.id + ')">前置电子围栏</button></div>'; | |
| 427 | + } else { | |
| 428 | + htm += '<button class="info_win_btn" id="addBetweenStationRoad" onclick="RoutesOperation.addBetweenStationRoad(' + stationRoute.id + ')">添加站点间路段</button></div>'; | |
| 429 | + } | |
| 413 | 430 | } |
| 414 | 431 | // 创建信息窗口 |
| 415 | 432 | var infoWindow = new BMap.InfoWindow(htm, opts); |
| 433 | + infoWindow.addEventListener('close', function() { | |
| 434 | + if (premise) { | |
| 435 | + baiduMap.removeOverlay(premise); | |
| 436 | + } | |
| 437 | + }) | |
| 416 | 438 | setTimeout(function () { |
| 417 | 439 | //开启信息窗口 |
| 418 | 440 | baiduMap.openInfoWindow(infoWindow, point); |
| ... | ... | @@ -1025,6 +1047,83 @@ var RoutesOperation = (function () { |
| 1025 | 1047 | }, |
| 1026 | 1048 | |
| 1027 | 1049 | /** |
| 1050 | + * 前置电子围栏 | |
| 1051 | + * @param stationRouteId | |
| 1052 | + */ | |
| 1053 | + geoPremise: function (stationRouteId) { | |
| 1054 | + if (premise) { | |
| 1055 | + baiduMap.removeOverlay(premise); | |
| 1056 | + } | |
| 1057 | + RoutesService.findGeoPremise(stationRouteId, function (res) { | |
| 1058 | + if (res.id) { | |
| 1059 | + var coords = res.coords.split(', '), points = []; | |
| 1060 | + for (var i = 0;i < coords.length;i++) { | |
| 1061 | + var coordinates = coords[i].split(' '); | |
| 1062 | + points.push(new BMap.Point(coordinates[0], coordinates[1])); | |
| 1063 | + } | |
| 1064 | + premise = new BMap.Polygon(points); | |
| 1065 | + premise.cdata = res; | |
| 1066 | + premise.enableEditing(true); | |
| 1067 | + premise.addEventListener('dblclick', operation.premiseDblclickHandler); | |
| 1068 | + baiduMap.addOverlay(premise); | |
| 1069 | + } else { | |
| 1070 | + layer.confirm('没有电子围栏,是否添加!', { | |
| 1071 | + btn : [ '确认', '取消' ] | |
| 1072 | + },function () { | |
| 1073 | + layer.closeAll(); | |
| 1074 | + var drawingManager = new BMapLib.DrawingManager(baiduMap, polygonDmOptions); | |
| 1075 | + drawingManager.setDrawingMode(BMAP_DRAWING_POLYGON); | |
| 1076 | + drawingManager.open(); | |
| 1077 | + drawingManager.addEventListener('polygoncomplete', function(polygon) { | |
| 1078 | + drawingManager.close(); | |
| 1079 | + baiduMap.removeOverlay(polygon); | |
| 1080 | + var points = polygon.getPath(); | |
| 1081 | + if (points.length < 3) { | |
| 1082 | + layer.msg('坐标点不能小于三个,请点击"退出编辑"后重新修改'); | |
| 1083 | + baiduMap.removeOverlay(polygon); | |
| 1084 | + | |
| 1085 | + return false; | |
| 1086 | + } else { | |
| 1087 | + var bufferPolygonWkt = new Array(); | |
| 1088 | + for(var i = 0;i < points.length;i++) { | |
| 1089 | + bufferPolygonWkt.push(points[i].lng + ' ' + points[i].lat) | |
| 1090 | + } | |
| 1091 | + bufferPolygonWkt.push(points[0].lng + ' ' + points[0].lat) | |
| 1092 | + RoutesService.saveGeoPremise({id: stationRouteId, coords: bufferPolygonWkt.join(', ')}, function(res) { | |
| 1093 | + if (res.status == 'SUCCESS') { | |
| 1094 | + layer.msg('前置电子围栏保存成功!'); | |
| 1095 | + } else { | |
| 1096 | + layer.msg('前置电子围栏保存失败!'); | |
| 1097 | + } | |
| 1098 | + }) | |
| 1099 | + } | |
| 1100 | + }); | |
| 1101 | + | |
| 1102 | + }); | |
| 1103 | + } | |
| 1104 | + }) | |
| 1105 | + }, | |
| 1106 | + | |
| 1107 | + /** | |
| 1108 | + * 前置围栏双击保存 | |
| 1109 | + */ | |
| 1110 | + premiseDblclickHandler: function (event) { | |
| 1111 | + var points = event.target.getPath(), cdata = event.target.cdata; | |
| 1112 | + var bufferPolygonWkt = new Array(); | |
| 1113 | + for(var i = 0;i < points.length;i++) { | |
| 1114 | + bufferPolygonWkt.push(points[i].lng + ' ' + points[i].lat) | |
| 1115 | + } | |
| 1116 | + bufferPolygonWkt.push(points[0].lng + ' ' + points[0].lat) | |
| 1117 | + RoutesService.saveGeoPremise({id: cdata.id, coords: bufferPolygonWkt.join(', ')}, function(res) { | |
| 1118 | + if (res.status == 'SUCCESS') { | |
| 1119 | + layer.msg('前置电子围栏保存成功!'); | |
| 1120 | + } else { | |
| 1121 | + layer.msg('前置电子围栏保存失败!'); | |
| 1122 | + } | |
| 1123 | + }) | |
| 1124 | + }, | |
| 1125 | + | |
| 1126 | + /** | |
| 1028 | 1127 | * 关闭modal时的清理 |
| 1029 | 1128 | * @param station |
| 1030 | 1129 | */ |
| ... | ... | @@ -1919,16 +2018,17 @@ var RoutesOperation = (function () { |
| 1919 | 2018 | var harr = new Array, i = 0; |
| 1920 | 2019 | for (i = 0;i < points.length;i++) { |
| 1921 | 2020 | harr.push('<option value="', points[i].stationName, '_station">', points[i].stationName, '</option>'); |
| 1922 | - points[i].bdPoint = points[i].station.bJwpoints; | |
| 1923 | - points[i].bdPoints = points[i].station.bdPolygon; | |
| 1924 | - points[i].shapesType = points[i].station.shapesType; | |
| 1925 | - points[i].radius = points[i].station.radius; | |
| 2021 | + points[i].bdPoint = points[i].station.centerPointWkt; | |
| 2022 | + points[i].bdPoints = points[i].bufferPolygonWkt; | |
| 2023 | + points[i].shapedType = points[i].shapedType; | |
| 2024 | + points[i].radius = points[i].radius; | |
| 1926 | 2025 | name2Point[points[i].stationName + '_station'] = points[i]; |
| 1927 | 2026 | } |
| 1928 | 2027 | harr.push('<option value="', carpark.parkName, '_park">', carpark.parkName, '</option>'); |
| 1929 | 2028 | carpark.bdPoint = carpark.bCenterPoint; |
| 1930 | 2029 | carpark.bdPoints = carpark.bParkPoint; |
| 1931 | 2030 | carpark.stationName = carpark.parkName; |
| 2031 | + carpark.shapedType = carpark.shapesType; | |
| 1932 | 2032 | name2Point[carpark.parkName + '_park'] = carpark; |
| 1933 | 2033 | |
| 1934 | 2034 | return harr.join(''); |
| ... | ... | @@ -1980,20 +2080,20 @@ var RoutesOperation = (function () { |
| 1980 | 2080 | var routes = result1.data.routes, rootNode; |
| 1981 | 2081 | operation.clearMarkAndOverlays(); |
| 1982 | 2082 | var startPoint = name2Point[start.join('_')], endPoint = name2Point[end.join('_')], point, points; |
| 1983 | - if (startPoint.shapesType === 'r') { | |
| 1984 | - point = startPoint.bdPoint.split(' '); | |
| 2083 | + if (startPoint.shapedType === 'r') { | |
| 2084 | + point = startPoint.bdPoint.replace('POINT(', '').replace(')', '').split(' '); | |
| 1985 | 2085 | operation.drawCircle({lng : point[0], lat : point[1]}, startPoint.radius, startPoint.stationName, true); |
| 1986 | - } else if (startPoint.shapesType === 'd') { | |
| 2086 | + } else if (startPoint.shapedType === 'd') { | |
| 1987 | 2087 | points = startPoint.bdPoints; |
| 1988 | 2088 | points = points.replace('POLYGON ((', '').replace('POLYGON((', '').replaceAll(', ', ',').replace('))', ''); |
| 1989 | 2089 | points = points.split(',') |
| 1990 | 2090 | operation.drawPolygon(points, startPoint.stationName, true); |
| 1991 | 2091 | } |
| 1992 | 2092 | |
| 1993 | - if (endPoint.shapesType === 'r') { | |
| 1994 | - point = endPoint.bdPoint.split(' '); | |
| 2093 | + if (endPoint.shapedType === 'r') { | |
| 2094 | + point = endPoint.bdPoint.replace('POINT(', '').replace(')', '').split(' '); | |
| 1995 | 2095 | operation.drawCircle({lng : point[0], lat : point[1]}, endPoint.radius, endPoint.stationName, true); |
| 1996 | - } else if (endPoint.shapesType === 'd') { | |
| 2096 | + } else if (endPoint.shapedType === 'd') { | |
| 1997 | 2097 | points = endPoint.bdPoints; |
| 1998 | 2098 | points = points.replace('POLYGON ((', '').replace('POLYGON((', '').replaceAll(', ', ',').replace('))', ''); |
| 1999 | 2099 | points = points.split(',') |
| ... | ... | @@ -2351,22 +2451,7 @@ var RoutesOperation = (function () { |
| 2351 | 2451 | |
| 2352 | 2452 | /***************************************************drawingmanager*******************************************************/ |
| 2353 | 2453 | initStationDrawingManager: function() { |
| 2354 | - stationDrawingManager = new BMapLib.DrawingManager(baiduMap, { | |
| 2355 | - //是否开启绘制模式 | |
| 2356 | - isOpen : false, | |
| 2357 | - //是否显示工具栏 | |
| 2358 | - enableDrawingTool : false, | |
| 2359 | - drawingToolOptions : { | |
| 2360 | - //位置 | |
| 2361 | - anchor : BMAP_ANCHOR_TOP_RIGHT, | |
| 2362 | - //偏离值 | |
| 2363 | - offset : new BMap.Size(5, 5), | |
| 2364 | - //工具栏缩放比例 | |
| 2365 | - scale : 0.8 | |
| 2366 | - }, | |
| 2367 | - //线的样式 | |
| 2368 | - polygonOptions : styleOptions | |
| 2369 | - }); | |
| 2454 | + stationDrawingManager = new BMapLib.DrawingManager(baiduMap, polygonDmOptions); | |
| 2370 | 2455 | |
| 2371 | 2456 | // 添加绘画完成事件 |
| 2372 | 2457 | stationDrawingManager.addEventListener('polygoncomplete', function(polygon) { | ... | ... |