Commit 88b397665cc75d5ee4fcc694cc82e74b457414b3

Authored by yiming
1 parent 86222fd7

配置子路径xlda 地图新增线路查询

bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/domain/BsthTLine.java
@@ -5,6 +5,7 @@ import com.ruoyi.common.utils.StringUtils; @@ -5,6 +5,7 @@ import com.ruoyi.common.utils.StringUtils;
5 import com.ruoyi.framework.aspectj.lang.annotation.Excel; 5 import com.ruoyi.framework.aspectj.lang.annotation.Excel;
6 import com.ruoyi.framework.web.domain.BaseEntity; 6 import com.ruoyi.framework.web.domain.BaseEntity;
7 7
  8 +import java.math.BigDecimal;
8 import java.util.Date; 9 import java.util.Date;
9 10
10 /** 11 /**
@@ -443,16 +444,16 @@ public class BsthTLine extends BaseEntity @@ -443,16 +444,16 @@ public class BsthTLine extends BaseEntity
443 444
444 public String getLineDistance() { 445 public String getLineDistance() {
445 int i=0; 446 int i=0;
446 - double k=0; 447 + BigDecimal k=new BigDecimal(0);
447 if(!StringUtils.isEmpty(mileageUp)&&Double.parseDouble(mileageUp)>0){ 448 if(!StringUtils.isEmpty(mileageUp)&&Double.parseDouble(mileageUp)>0){
448 i++; 449 i++;
449 - k+=Double.parseDouble(mileageUp); 450 + k=k.add(new BigDecimal(mileageUp));
450 } 451 }
451 if(!StringUtils.isEmpty(mileageDown)&&Double.parseDouble(mileageDown)>0){ 452 if(!StringUtils.isEmpty(mileageDown)&&Double.parseDouble(mileageDown)>0){
452 i++; 453 i++;
453 - k+=Double.parseDouble(mileageDown); 454 + k=k.add(new BigDecimal(mileageDown));
454 } 455 }
455 - lineDistance=i>0?String.valueOf(k/i):null; 456 + lineDistance=i>0?String.valueOf(k.divide(new BigDecimal(i))):null;
456 return lineDistance; 457 return lineDistance;
457 } 458 }
458 459
bsthLineProfiles/src/main/resources/application.yml
@@ -20,7 +20,7 @@ server: @@ -20,7 +20,7 @@ server:
20 port: 9999 20 port: 9999
21 servlet: 21 servlet:
22 # 应用的访问路径 22 # 应用的访问路径
23 - context-path: / 23 + context-path: /xlda/
24 tomcat: 24 tomcat:
25 # tomcat的URI编码 25 # tomcat的URI编码
26 uri-encoding: UTF-8 26 uri-encoding: UTF-8
bsthLineProfiles/src/main/resources/mybatis/mybatis/system/BsthTLineMapper.xml
@@ -1375,7 +1375,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -1375,7 +1375,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
1375 1375
1376 <select id="usedBsthTLineReport" parameterType="BsthTLine" resultMap="BsthTLineResult"> 1376 <select id="usedBsthTLineReport" parameterType="BsthTLine" resultMap="BsthTLineResult">
1377 SELECT * from bsth_t_line_history 1377 SELECT * from bsth_t_line_history
1378 - WHERE id IN(SELECT max(id) FROM `bsth_t_line_history` where update_status=-1 1378 + WHERE id IN(SELECT max(id) FROM `bsth_t_line_history` where 1=1
1379 <if test="createTimeEnd != null and createTimeEnd != ''"> and create_time &lt;= #{createTimeEnd}</if> 1379 <if test="createTimeEnd != null and createTimeEnd != ''"> and create_time &lt;= #{createTimeEnd}</if>
1380 GROUP BY line_name) 1380 GROUP BY line_name)
1381 1381
@@ -1405,7 +1405,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -1405,7 +1405,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
1405 h1.vehicles_number vehiclesNumber,h1.number_vehicles_large numberVehiclesLarge,h1.number_vehicles_middle numberVehiclesMiddle, 1405 h1.vehicles_number vehiclesNumber,h1.number_vehicles_large numberVehiclesLarge,h1.number_vehicles_middle numberVehiclesMiddle,
1406 h1.car_plate carPlate,h1.number_person numberPerson,h1.number_person_driver numberPersonDriver,h1.number_person_sales numberPersonSales, 1406 h1.car_plate carPlate,h1.number_person numberPerson,h1.number_person_driver numberPersonDriver,h1.number_person_sales numberPersonSales,
1407 h1.bus_ev_number busEvNumber,h1.directions directions,h1.halfway_station halfwayStation, 1407 h1.bus_ev_number busEvNumber,h1.directions directions,h1.halfway_station halfwayStation,
1408 - h1.divide_level divideLevel,h1.nightParking nightParking 1408 + h1.divide_level divideLevel,h1.nightParking nightParking,
1409 h1.has_timelists hasTimelists,h1.is_metro isMetro,h1.metro_time metroTime,h1.cold_bonus_type coldBonusType, 1409 h1.has_timelists hasTimelists,h1.is_metro isMetro,h1.metro_time metroTime,h1.cold_bonus_type coldBonusType,
1410 h1.line_update_type lineUpdateType,h1.revenue_type revenueType, 1410 h1.line_update_type lineUpdateType,h1.revenue_type revenueType,
1411 h1.firstHub firstHub,h1.firstHubAddress firstHubAddress,h1.lastHub lastHub,h1.lastHubAddress lastHubAddress, 1411 h1.firstHub firstHub,h1.firstHubAddress firstHubAddress,h1.lastHub lastHub,h1.lastHubAddress lastHubAddress,
@@ -1424,7 +1424,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -1424,7 +1424,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
1424 h2.vehicles_number vehiclesNumberOld,h2.number_vehicles_large numberVehiclesLargeOld,h2.number_vehicles_middle numberVehiclesMiddleOld, 1424 h2.vehicles_number vehiclesNumberOld,h2.number_vehicles_large numberVehiclesLargeOld,h2.number_vehicles_middle numberVehiclesMiddleOld,
1425 h2.car_plate carPlateOld,h2.number_person numberPersonOld,h2.number_person_driver numberPersonDriverOld,h2.number_person_sales numberPersonSalesOld, 1425 h2.car_plate carPlateOld,h2.number_person numberPersonOld,h2.number_person_driver numberPersonDriverOld,h2.number_person_sales numberPersonSalesOld,
1426 h2.bus_ev_number busEvNumberOld,h2.directions directionsOld,h2.halfway_station halfwayStationOld, 1426 h2.bus_ev_number busEvNumberOld,h2.directions directionsOld,h2.halfway_station halfwayStationOld,
1427 - h2.divide_level divideLevelOld,h2.nightParking nightParkingOld 1427 + h2.divide_level divideLevelOld,h2.nightParking nightParkingOld,
1428 h2.has_timelists hasTimelistsOld,h2.is_metro isMetroOld,h2.metro_time metroTimeOld,h2.cold_bonus_type coldBonusTypeOld, 1428 h2.has_timelists hasTimelistsOld,h2.is_metro isMetroOld,h2.metro_time metroTimeOld,h2.cold_bonus_type coldBonusTypeOld,
1429 h2.line_update_type lineUpdateTypeOld,h2.revenue_type revenueTypeOld, 1429 h2.line_update_type lineUpdateTypeOld,h2.revenue_type revenueTypeOld,
1430 h2.firstHub firstHubOld,h2.firstHubAddress firstHubAddressOld,h2.lastHub lastHubOld,h2.lastHubAddress lastHubAddressOld 1430 h2.firstHub firstHubOld,h2.firstHubAddress firstHubAddressOld,h2.lastHub lastHubOld,h2.lastHubAddress lastHubAddressOld
bsthLineProfiles/src/main/resources/templates/system/line/map.html
@@ -13,7 +13,7 @@ body, html, #container { @@ -13,7 +13,7 @@ body, html, #container {
13 margin: 0; 13 margin: 0;
14 font-family: "微软雅黑"; 14 font-family: "微软雅黑";
15 } 15 }
16 - 16 +ul li {list-style: none;}
17 .info { 17 .info {
18 z-index: 999; 18 z-index: 999;
19 width: auto; 19 width: auto;
@@ -59,17 +59,46 @@ body, html, #container { @@ -59,17 +59,46 @@ body, html, #container {
59 .lf{ 59 .lf{
60 padding-left: 25px; 60 padding-left: 25px;
61 } 61 }
  62 +
  63 +
  64 +.drawing-panel {
  65 + z-index: 999;
  66 + position: fixed;
  67 + bottom: 3.5rem;
  68 + margin-left: 3rem;
  69 + padding: 1rem 1rem;
  70 + border-radius: .25rem;
  71 + background-color: #fff;
  72 + box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
  73 +}
  74 +.draw-btn {
  75 + width: 75px;
  76 + height: 30px;
  77 + background-color: #fff;
  78 + color: rgba(27, 142, 236, 1);
  79 + border:1px solid rgba(27, 142, 236, 1);
  80 + border-radius: 5px;
  81 + margin: 0 5px;
  82 +}
  83 +label.BMapLabel.BMap_disLabel{
  84 + display: inline-block;
  85 + min-width: 100px;
  86 + margin-bottom: 5px;
  87 + font-weight: 700;
  88 +}
  89 +
62 </style> 90 </style>
63 <script 91 <script
64 src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script> 92 src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script>
65 </head> 93 </head>
66 <body> 94 <body>
67 - <div class="info" style="width: 450px"> 95 + <div class="info" style="width: 40%">
68 <ul class="nav nav-tabs" role="tablist"> 96 <ul class="nav nav-tabs" role="tablist">
69 - <li role="presentation" class="active"><a onclick="show('station','road','line','area')" role="tab" data-toggle="tab">地点查询</a></li>  
70 - <li role="presentation"><a onclick="show('road','station','line','area')" role="tab" data-toggle="tab">道路查询</a></li>  
71 - <li role="presentation"><a onclick="show('line','road','station','area')" role="tab" data-toggle="tab">途经线路</a></li>  
72 - <li role="presentation"><a onclick="show('area','road','station','line')" role="tab" data-toggle="tab">区域查询</a></li> 97 + <li role="presentation" class="active"><a onclick="show('station','road','line','area','lineSeach')" role="tab" data-toggle="tab">地点查询</a></li>
  98 + <li role="presentation"><a onclick="show('road','station','line','area','lineSeach')" role="tab" data-toggle="tab">道路查询</a></li>
  99 + <li role="presentation"><a onclick="show('line','road','station','area','lineSeach')" role="tab" data-toggle="tab">途经线路</a></li>
  100 + <li role="presentation"><a onclick="show('area','road','station','line','lineSeach')" role="tab" data-toggle="tab">区域查询</a></li>
  101 + <li role="presentation"><a onclick="show('lineSeach','area','road','station','line',)" role="tab" data-toggle="tab">线路查询</a></li>
73 </ul> 102 </ul>
74 103
75 <form id="station"> 104 <form id="station">
@@ -125,7 +154,7 @@ body, html, #container { @@ -125,7 +154,7 @@ body, html, #container {
125 <div class="row"> 154 <div class="row">
126 <h4></h4> 155 <h4></h4>
127 156
128 - <div id="bus" class="col-sm-12" style="padding-left: 20px;width: 440px"> 157 + <div id="bus" class="col-sm-12">
129 </div> 158 </div>
130 159
131 <h4 ></h4> 160 <h4 ></h4>
@@ -163,24 +192,50 @@ body, html, #container { @@ -163,24 +192,50 @@ body, html, #container {
163 </div> 192 </div>
164 </div> 193 </div>
165 </form> 194 </form>
  195 +
  196 + <form id="lineSeach" style="display: none">
  197 + <div class="row">
  198 + <h4></h4>
  199 + <label class="col-sm-3"><h4 class="lf">线路名</h4></label>
  200 + <div class="col-sm-9">
  201 + <input id="lineName" class="form-control" type="text">
  202 + </div>
  203 + <h4></h4>
  204 + </div>
  205 + <div class="row">
  206 + <h4></h4>
  207 + <div class="col-sm-4">
  208 + <button type="button" class="el-button el-button--primary el-button--mini" onclick="searchRoad();"><!----><i class="el-icon-search"></i><span>搜索</span></button>
  209 + </div>
  210 + <div class="col-sm-4">
  211 + <button type="button" class="el-button el-button--default el-button--mini" onclick="clearAll()"><!----><i class="el-icon-refresh"></i><span>清除站点结果</span></button>
  212 + </div>
  213 + </div>
  214 + </form>
  215 +
166 </div> 216 </div>
167 217
168 218
169 <div class="info stationInfo"> 219 <div class="info stationInfo">
170 <div id="stationInfo"></div> 220 <div id="stationInfo"></div>
171 </div> 221 </div>
172 -  
173 <div id="container"></div> 222 <div id="container"></div>
  223 + <ul class = "drawing-panel">
  224 + <input type="button" class="draw-btn" value="开启测距" onclick="myDis.open()">
  225 + <input type="button" class="draw-btn" value="关闭测距" onclick="myDis.close()">
  226 + </ul>
174 <th:block th:include="include :: footer" /> 227 <th:block th:include="include :: footer" />
175 <th:block th:include="include :: bootstrap-suggest-js" /> 228 <th:block th:include="include :: bootstrap-suggest-js" />
176 <th:block th:include="include :: select2-js" /> 229 <th:block th:include="include :: select2-js" />
  230 + <script type="text/javascript" src="//mapopen.cdn.bcebos.com/github/BMapGLLib/DistanceTool/src/DistanceTool.min.js"></script>
177 <script> 231 <script>
178 //tab栏控制 232 //tab栏控制
179 - function show(id1,id2,id3,id4){ 233 + function show(id1,id2,id3,id4,id5){
180 $('#'+id1).attr("style","display:show;"); 234 $('#'+id1).attr("style","display:show;");
181 $('#'+id2).attr("style","display:none;"); 235 $('#'+id2).attr("style","display:none;");
182 $('#'+id3).attr("style","display:none;"); 236 $('#'+id3).attr("style","display:none;");
183 $('#'+id4).attr("style","display:none;"); 237 $('#'+id4).attr("style","display:none;");
  238 + $('#'+id5).attr("style","display:none;");
184 } 239 }
185 240
186 //地图的初始化 241 //地图的初始化
@@ -223,15 +278,21 @@ body, html, #container { @@ -223,15 +278,21 @@ body, html, #container {
223 //道路查询 278 //道路查询
224 function searchRoad(){ 279 function searchRoad(){
225 var roadName=$('#roadName').val(); 280 var roadName=$('#roadName').val();
226 - var distance=20000;  
227 - //创建地址解析器实例  
228 - var myGeo = new BMapGL.Geocoder();  
229 - // 将地址解析结果显示在地图上,并调整地图视野  
230 - myGeo.getPoint(roadName, function(point){  
231 - map.clearOverlays();  
232 - map.centerAndZoom(point, 17);  
233 - b(point.lng,point.lat,distance,roadName)  
234 - }, '上海市') 281 + var lineName=$('#lineName').val();
  282 + if (roadName!=''){
  283 + var distance=20000;
  284 + //创建地址解析器实例
  285 + var myGeo = new BMapGL.Geocoder();
  286 + // 将地址解析结果显示在地图上,并调整地图视野
  287 + myGeo.getPoint(roadName, function(point){
  288 + map.clearOverlays();
  289 + map.centerAndZoom(point, 17);
  290 + b(point.lng,point.lat,distance,roadName)
  291 + }, '上海市')
  292 + }else if(lineName!=''){
  293 + searchBus(lineName);
  294 + }
  295 +
235 } 296 }
236 297
237 //区域查询 298 //区域查询
@@ -486,14 +547,27 @@ body, html, #container { @@ -486,14 +547,27 @@ body, html, #container {
486 for(var i=1;i<=5;i++){ 547 for(var i=1;i<=5;i++){
487 document.getElementById('c'+i).innerHTML=''; 548 document.getElementById('c'+i).innerHTML='';
488 } 549 }
489 - 550 + document.getElementById('bus').innerHTML='';
  551 + document.getElementById('count').innerHTML='';
490 } 552 }
491 553
492 function clearAll(){ 554 function clearAll(){
493 $.form.reset(); 555 $.form.reset();
  556 + $('#roadName').val('');
  557 + $('#lineName').val('');
494 $('#distance2').val(''); 558 $('#distance2').val('');
495 clearline(); 559 clearline();
496 } 560 }
  561 +
  562 + var myDis = new BMapGL.DistanceTool(map);
  563 +
  564 + // 监听测距过程中的鼠标事件
  565 + myDis.addEventListener('drawend', function(e) {
  566 + });
  567 + myDis.addEventListener("addpoint", function(e) {
  568 + });
  569 + myDis.addEventListener("removepolyline", function(e) {
  570 + });
497 </script> 571 </script>
498 572
499 573
bsthLineProfiles/src/main/resources/templates/system/line/map2.html 0 → 100644
  1 +<!DOCTYPE html>
  2 +<html lang="zh" xmlns:th="http://www.thymeleaf.org"
  3 + xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
  4 +<head>
  5 +
  6 +<th:block th:include="include :: header('地图查询')" />
  7 +<th:block th:include="include :: select2-css" />
  8 +<style>
  9 +body, html, #container {
  10 + overflow: hidden;
  11 + width: 100%;
  12 + height: 100%;
  13 + margin: 0;
  14 + font-family: "微软雅黑";
  15 +}
  16 +
  17 +.info {
  18 + z-index: 20;
  19 + width: 95%;
  20 + min-width: 22rem;
  21 + padding: .75rem 1.25rem;
  22 + margin-left: 1rem;
  23 + position: fixed;
  24 + top: 1rem;
  25 + background-color: #f5f5f5d4;
  26 + border-radius: .25rem;
  27 + font-size: 14px;
  28 + color: #666;
  29 + box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
  30 +}
  31 +.myDiv {
  32 + z-index: 21;
  33 + width: 10%;
  34 + padding: .95rem 1.25rem;
  35 + position: fixed;
  36 + border-radius: .25rem;
  37 +}
  38 +.stationInfo {
  39 + right: 0px;
  40 + top: 100px;
  41 + display: none;
  42 +}
  43 +
  44 +.tangram-suggestion-main {
  45 + z-index: 999999;
  46 +}
  47 +.subContainer {
  48 + position: relative;
  49 + padding-bottom: 10px;
  50 +}
  51 +.opt {
  52 + position: relative;
  53 + padding-top: 10px;
  54 +}
  55 +.optTitle {
  56 + width: 60px;
  57 + height: 28px;
  58 + line-height: 28px;
  59 + font-size: 14px;
  60 + text-align: center;
  61 + background: #c5464a;
  62 + color: #fff;
  63 + border-radius: 5px 0 0 5px;
  64 +}
  65 +.lf{
  66 + padding-left: 25px;
  67 +}
  68 +
  69 +.nav-tabs>li>a {
  70 + color: #A7B1C2;
  71 + font-weight: 600;
  72 + padding: 10px 10px 10px 15px;
  73 + font-size: 80%;
  74 +}
  75 +
  76 +</style>
  77 +<script
  78 + src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=IGGrr4UjwIYzatoCRFKEL8sT"></script>
  79 +</head>
  80 +<body>
  81 + <span class="myDiv">
  82 + <i class="fa fa-align-justify" style="font-size: 150%" onclick="infoShow()"></i>
  83 + </span>
  84 +
  85 + <div class="info" id="info">
  86 + <ul class="nav nav-tabs" role="tablist" >
  87 + <li role="presentation" class="active"><a onclick="show('station','road','line','area')" style="margin-left:1rem;" role="tab" data-toggle="tab" >地点查询</a></li>
  88 + <li role="presentation"><a onclick="show('road','station','line','area')" role="tab" data-toggle="tab" >道路/线路查询</a></li>
  89 + <li role="presentation"><a onclick="show('line','road','station','area')" role="tab" data-toggle="tab" >途经线路</a></li>
  90 + <li role="presentation"><a onclick="show('area','road','station','line')" role="tab" data-toggle="tab" s>区域查询</a></li>
  91 + </ul>
  92 +
  93 + <form id="station">
  94 + <div class="row">
  95 + <h5></h5>
  96 + <label class="col-sm-3"><h5 class="lf">地点</h5></label>
  97 + <div class="col-sm-9" >
  98 + <input type="text" class="form-control" id="stations">
  99 + <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
  100 + </div>
  101 + <h5></h5>
  102 + </div>
  103 + <div class="row">
  104 + <h5></h5>
  105 + <label class="col-sm-3"><h5 class="lf">范围(米)</h5></label>
  106 + <div class="col-sm-9">
  107 + <input id="distance" class="form-control" type="text" placeholder="单位米">
  108 + </div>
  109 + <h5></h5>
  110 + </div>
  111 + <div class="row">
  112 + <div class="col-sm-4" >
  113 + <button type="button" class="el-button el-button--primary el-button--mini" onclick="searchStation()"><!----><i class="el-icon-search"></i><span>搜索</span></button>
  114 + <button type="button" class="el-button el-button--default el-button--mini" onclick="clearAll()"><!----><i class="el-icon-refresh"></i><span>清除站点结果</span></button>
  115 + </div>
  116 + </div>
  117 + </form>
  118 +
  119 + <form id="road" style="display: none">
  120 + <div class="row">
  121 + <h5></h5>
  122 + <label class="col-sm-3"><h5 class="lf">路名</h5></label>
  123 + <div class="col-sm-9">
  124 + <input id="roadName" class="form-control" type="text">
  125 + </div>
  126 + <h5></h5>
  127 + </div>
  128 + <div class="row">
  129 + <div class="col-sm-4" >
  130 + <button type="button" class="el-button el-button--primary el-button--mini" onclick="searchRoad()"><!----><i class="el-icon-search"></i><span>搜索</span></button>
  131 + <button type="button" class="el-button el-button--default el-button--mini" onclick="clearAll()"><!----><i class="el-icon-refresh"></i><span>清除站点结果</span></button>
  132 + </div>
  133 + </div>
  134 + </form>
  135 + <form id="line" style="display: none">
  136 +
  137 + <div class="row">
  138 + <h5></h5>
  139 +
  140 + <div id="bus" class="col-sm-12" style="padding-left: 20px;width: 100%">
  141 + </div>
  142 +
  143 + <h5 ></h5>
  144 + <div class="lf">
  145 + <i class="fa fa-minus " style="color:#5298ff" id="c1"></i>
  146 + <i class="fa fa-minus " style="color:#E0312A" id="c2"></i>
  147 + <i class="fa fa-minus " style="color:#30e868" id="c3"></i>
  148 + <i class="fa fa-minus " style="color:#A80FE4" id="c4"></i>
  149 + <i class="fa fa-minus " style="color:#0010eb" id="c5"></i>
  150 + </div>
  151 + <h5></h5>
  152 + <h5 class="lf" id="count"></h5>
  153 + <div class="col-sm-4">
  154 + <button type="button" class="el-button el-button--default el-button--mini" onclick="clearline();"><!----><i class="el-icon-refresh"></i><span>清除线路</span></button>
  155 + </div>
  156 +
  157 + </div>
  158 + </form>
  159 + <form id="area" style="display: none">
  160 + <div class="row">
  161 + <h5></h5>
  162 + <label class="col-sm-3"><h5 class="lf">范围(米)</h5></label>
  163 + <div class="col-sm-9">
  164 + <input id="distance2" class="form-control" type="text" placeholder="单位米">
  165 + </div>
  166 + <h5></h5>
  167 + </div>
  168 + <div class="row">
  169 + <div class="col-sm-4" >
  170 + <button type="button" class="el-button el-button--primary el-button--mini" onclick="searchArea()"><!----><i class="el-icon-search"></i><span>搜索</span></button>
  171 + <button type="button" class="el-button el-button--default el-button--mini" onclick="clearAll()"><!----><i class="el-icon-refresh"></i><span>清除站点结果</span></button>
  172 + </div>
  173 + </div>
  174 + </form>
  175 + </div>
  176 +
  177 +
  178 +
  179 + <div class="info stationInfo">
  180 + <div id="stationInfo"></div>
  181 + </div>
  182 +
  183 + <div id="container"></div>
  184 + <th:block th:include="include :: footer" />
  185 + <th:block th:include="include :: bootstrap-suggest-js" />
  186 + <th:block th:include="include :: select2-js" />
  187 + <script>
  188 + //tab栏控制
  189 + function show(id1,id2,id3,id4){
  190 + $('#'+id1).attr("style","display:show;");
  191 + $('#'+id2).attr("style","display:none;");
  192 + $('#'+id3).attr("style","display:none;");
  193 + $('#'+id4).attr("style","display:none;");
  194 + }
  195 +
  196 + //地图的初始化
  197 + var map = new BMapGL.Map('container'); // 创建Map实例
  198 + map.centerAndZoom(new BMapGL.Point(121.528733, 31.237425), 12); // 初始化地图,设置中心点坐标和地图级别
  199 + map.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放
  200 +
  201 +
  202 +
  203 + /*map.addEventListener('click', function(e) {
  204 + if (e.overlay) {
  205 + return; // 存在覆盖物退出
  206 + }
  207 + });
  208 + var stations
  209 + */
  210 + var sp;
  211 + var myicon = new BMapGL.Icon(
  212 + 'http://webmap0.map.bdstatic.com/wolfman/static/common/images/us_cursor_9517a2b.png', // 百度图片
  213 + new BMapGL.Size(18,26), // 视窗大小
  214 + {
  215 + imageSize: new BMapGL.Size(144,92), // 引用图片实际大小
  216 + imageOffset:new BMapGL.Size(18,22) // 图片相对视窗的偏移
  217 + }
  218 + );
  219 + //地点查询
  220 + function searchStation(){
  221 + var distance=$("#distance").val();
  222 + if(distance==''){
  223 + return;
  224 + }
  225 + map.clearOverlays();
  226 + map.centerAndZoom(sp, 16);
  227 + var marker = new BMapGL.Marker(sp);
  228 + marker.setIcon(myicon);
  229 + map.addOverlay(marker); //添加标注
  230 + a(sp.lng,sp.lat,distance);
  231 + }
  232 +
  233 + //道路查询
  234 + function searchRoad(){
  235 + var roadName=$('#roadName').val();
  236 + console.log(roadName);
  237 + if(roadName==''){
  238 + return false;
  239 + }
  240 + var distance=20000;
  241 + //创建地址解析器实例
  242 + var myGeo = new BMapGL.Geocoder();
  243 + // 将地址解析结果显示在地图上,并调整地图视野
  244 + myGeo.getPoint(roadName, function(point){
  245 + map.clearOverlays();
  246 + map.centerAndZoom(point, 16);
  247 + b(point.lng,point.lat,distance,roadName)
  248 + }, '上海市')
  249 + }
  250 +
  251 + //区域查询
  252 + function searchArea(){
  253 + var distance=$("#distance2").val();
  254 + map.clearOverlays();
  255 + var lng=p.latLng.lng;
  256 + var lat=p.latLng.lat;
  257 + map.centerAndZoom(new BMapGL.Point(lng,lat), 16);
  258 + map.addOverlay(p);
  259 + a(lng,lat,distance);
  260 + }
  261 +
  262 + //站点标注
  263 + function a(lng,lat,distance){
  264 + $.get("../line/getStation?lng="
  265 + +lng + "&lat=" + lat + "&dis="
  266 + + distance*2/ 1000, function(data) {
  267 + if (data.code == "0") {
  268 + var bus=new Array();
  269 + for ( var i in data.data) {
  270 + (function(){
  271 + var station = data.data[i];
  272 + var marker = new BMapGL.Marker(new BMapGL.Point(station.lonBd, station.latBd),{title:station.standardStationCode});
  273 +
  274 + marker.station = data.data[i];
  275 +
  276 + var opts = {
  277 + width: 200,
  278 + height: 200,
  279 + title: station.stationName,
  280 + enableCloseOnClick:false
  281 + };
  282 + var lineList=data.data[i].lineList;
  283 + var arr=lineList.split("、")
  284 + Array.prototype.push.apply(bus, arr);
  285 + var str='';
  286 + for ( var j in arr) {
  287 + str+="<a onClick='searchBus(\""+arr[j]+"\")'>"+arr[j]+"</a>&nbsp;&nbsp;";
  288 + }
  289 +
  290 + var info = "";
  291 + info += "<span>站点名称:" + data.data[i].stationName
  292 + + "</span><br/>";
  293 + info += "<span>行业编码:" + data.data[i].standardStationCode
  294 + + "</span><br/>";
  295 + info += "<span>站点编码:" + data.data[i].stationCode
  296 + + "</span><br/>";
  297 + info += "<span>经过线路:" + str
  298 + + "</span><br/>";
  299 + info += "<span>道路名称:" + data.data[i].roadName
  300 + + "</span><br/>";
  301 + var infoWindow = new BMapGL.InfoWindow(info, opts);
  302 + marker.addEventListener('click', function() {
  303 + map.openInfoWindow(infoWindow, new BMapGL.Point(station.lonBd, station.latBd)); // 开启信息窗口
  304 + });
  305 + map.addOverlay(marker);
  306 + })();
  307 + }
  308 + bus=Array.from(new Set(bus));
  309 + var str='';
  310 + for ( var j in bus) {
  311 + str+=" &nbsp;&nbsp;<a onClick='searchBus(\""+bus[j]+"\")'>"+bus[j]+"</a>";
  312 + }
  313 + document.getElementById('bus').innerHTML=str;
  314 + document.getElementById('count').innerHTML='共'+data.data.length+'个站点 &nbsp;&nbsp;&nbsp; 共'+bus.length+'条线路';
  315 + // 绘制圆
  316 + var circle = new BMapGL.Circle(new BMapGL.Point(lng,lat), distance, {
  317 + strokeColor: 'blue',
  318 + strokeWeight: 2,
  319 + strokeOpacity: 0.5
  320 + });
  321 + map.addOverlay(circle);
  322 + }
  323 + });
  324 + }
  325 +
  326 + //站点标注用来查道路的 多了个站点筛选和 去除 圆形范围
  327 + function b(lng,lat,distance,roadName){
  328 + $.get("../line/getStation?lng="
  329 + +lng + "&lat=" + lat + "&dis="
  330 + + distance*2/ 1000, function(data) {
  331 + if (data.code == "0") {
  332 + var bus=new Array();
  333 + var c=0;
  334 + for ( var i in data.data) {
  335 + (function(){
  336 + var station = data.data[i];
  337 + var marker = new BMapGL.Marker(new BMapGL.Point(station.lonBd, station.latBd),{title:station.standardStationCode});
  338 +
  339 + marker.station = data.data[i];
  340 +
  341 + var opts = {
  342 + width: 200,
  343 + height: 200,
  344 + title: station.stationName
  345 + };
  346 +
  347 +
  348 + if(data.data[i].roadName==roadName){
  349 + c++;
  350 + var lineList=data.data[i].lineList;
  351 + var arr=lineList.split("、");
  352 + Array.prototype.push.apply(bus, arr);
  353 + var str='';
  354 + for ( var j in arr) {
  355 + str+="<a onClick='searchBus(\""+arr[j]+"\")'>"+arr[j]+"</a>&nbsp;&nbsp;";
  356 + }
  357 + var info = "";
  358 + info += "<span>站点名称:" + data.data[i].stationName
  359 + + "</span><br/>";
  360 + info += "<span>行业编码:" + data.data[i].standardStationCode
  361 + + "</span><br/>";
  362 + info += "<span>站点编码:" + data.data[i].stationCode
  363 + + "</span><br/>";
  364 + info += "<span>经过线路:" + str
  365 + + "</span><br/>";
  366 + info += "<span>道路名称:" + data.data[i].roadName
  367 + + "</span><br/>";
  368 +
  369 + var infoWindow = new BMapGL.InfoWindow(info, opts);
  370 +
  371 +
  372 + marker.addEventListener('click', function() {
  373 + map.openInfoWindow(infoWindow, new BMapGL.Point(station.lonBd, station.latBd)); // 开启信息窗口
  374 + });
  375 + map.addOverlay(marker);
  376 + }
  377 +
  378 + })();
  379 + }
  380 + bus=Array.from(new Set(bus));
  381 + var str='';
  382 + for ( var j in bus) {
  383 + str+=" &nbsp;&nbsp;<a onClick='searchBus(\""+bus[j]+"\")'>"+bus[j]+"</a>";
  384 + }
  385 +
  386 + document.getElementById('count').innerHTML=' 共'+c+'个站点 &nbsp;&nbsp;&nbsp; 共'+bus.length+'条线路';
  387 +
  388 + document.getElementById('bus').innerHTML=str;
  389 + }
  390 + });
  391 + }
  392 +
  393 +
  394 + //百度下拉列表
  395 + function G(id) {
  396 + return document.getElementById(id);
  397 + }
  398 + var ac = new BMapGL.Autocomplete( //建立一个自动完成的对象
  399 + {"input" : "stations"
  400 + ,"location" : map
  401 + });
  402 + ac.addEventListener("onhighlight", function(e) { //鼠标放在下拉列表上的事件
  403 + var str = "";
  404 + var _value = e.fromitem.value;
  405 + var value = "";
  406 + if (e.fromitem.index > -1) {
  407 + value = _value.province + _value.city + _value.district + _value.street + _value.business;
  408 + }
  409 + str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;
  410 +
  411 + value = "";
  412 + if (e.toitem.index > -1) {
  413 + _value = e.toitem.value;
  414 + value = _value.province + _value.city + _value.district + _value.street + _value.business;
  415 + }
  416 + str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
  417 + G("stations").innerHTML = str;
  418 + });
  419 +
  420 + var myValue;
  421 + ac.addEventListener("onconfirm", function(e) { //鼠标点击下拉列表后的事件
  422 + var _value = e.item.value;
  423 + myValue = _value.province + _value.city + _value.district + _value.street + _value.business;
  424 + G("stations").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
  425 + setPlace();
  426 + });
  427 + function setPlace(){
  428 + function myFun(){
  429 + sp = local.getResults().getPoi(0).point; //获取第一个智能搜索的结果
  430 + }
  431 + var local = new BMapGL.LocalSearch(map, { //智能搜索
  432 + onSearchComplete: myFun
  433 + });
  434 + local.search(myValue);
  435 + }
  436 +
  437 +
  438 + //多线路查询
  439 + var ll=new Array();//存放折线
  440 + var sl=new Array();//存放站点
  441 + var readyAdd=new Array();//存放线路
  442 +
  443 + function searchBus(line){
  444 + if (readyAdd.length>=5) {
  445 + alert("最多5条线路");
  446 + return false
  447 + }
  448 + if ($.inArray(line, readyAdd) == -1) {
  449 + bus.getBusList(line);
  450 + readyAdd.push(line); //readyAdd为空数组,用于存储已添加的线路名
  451 + document.getElementById('c'+readyAdd.length).innerHTML=line;
  452 + } else {
  453 + alert("该路线已添加");
  454 + }
  455 + }
  456 +
  457 + var colors=['#5298ff','#E0312A','#30e868','#A80FE4','#0010eb']
  458 + var bus = new BMapGL.BusLineSearch(map, {
  459 + renderOptions:{map:map,panel:"r-result"},
  460 + onGetBusListComplete: function onGetBusListComplete (result) {
  461 + let fstLine = result.getBusListItem(0);//通过线路名查询线路列表默认第一条
  462 + bus.getBusLine(fstLine);
  463 + },onPolylinesSet: function onPolylinesSet(polyline){//添加公交线时候回调函数.参数:ply:Polyline 公交线路几何对象
  464 + //通过删除api自带的折线 然后改变颜色重新渲染
  465 + map.clearOverlays();
  466 + //https://mapopen-pub-jsapi.bj.bcebos.com/jsapi/reference/jsapi_webgl_1_0.html#a3b0
  467 + polyline.setStrokeColor(colors[ll.length]);//颜色
  468 + polyline.setStrokeWeight(4);//宽度
  469 + polyline.setStrokeOpacity(0.9);//透明度
  470 + ll.push(polyline);
  471 + for(let i in ll){
  472 + var polyline2=ll[i];
  473 + map.addOverlay(polyline2); //添加折线覆盖物
  474 + }
  475 + },onMarkersSet : function onMarkersSet(array){//添加公交站点时候回调函数.参数:sts:Array 公交站坐标组成的Marker对象数组
  476 + Array.prototype.push.apply(sl, array);
  477 + for(var i in sl){
  478 + map.addOverlay(sl[i]);
  479 + }
  480 + }
  481 + });
  482 +
  483 +
  484 + //双击标记坐标
  485 + var p;
  486 + map.addEventListener('dblclick', function(e){
  487 + var pt = e.latlng;
  488 + var marker = new BMapGL.Marker(new BMapGL.Point(pt.lng, pt.lat));
  489 + marker.setIcon(myicon);
  490 + map.removeOverlay(p);
  491 + p=marker;
  492 + map.addOverlay(p);
  493 + })
  494 +
  495 + function clearline(){
  496 + ll=new Array();//存放折线
  497 + sl=new Array();//存放站点
  498 + readyAdd=new Array();//存放线路
  499 + map.clearOverlays();
  500 + for(var i=1;i<=5;i++){
  501 + document.getElementById('c'+i).innerHTML='';
  502 + }
  503 +
  504 + }
  505 +
  506 + function clearAll(){
  507 + $.form.reset();
  508 + $('#distance2').val('');
  509 + clearline();
  510 + }
  511 + var showFlag=true;
  512 + function infoShow(){
  513 + if(showFlag==true){
  514 + $("#info").hide();
  515 + showFlag=false;
  516 + }else {
  517 + $("#info").show();
  518 + showFlag=true;
  519 + }
  520 + }
  521 + function f() {
  522 + console.log("aa");
  523 + }
  524 + </script>
  525 +
  526 +
  527 +
  528 +</body>
  529 +</html>
0 \ No newline at end of file 530 \ No newline at end of file