Commit 244ef0fe806da11ede2526628d2550da4f9abb13
1 parent
d5a6f3bd
bf
Showing
3 changed files
with
256 additions
and
42 deletions
bsthLineProfiles/src/main/java/com/ruoyi/project/system/line/controller/BsthTLineController.java
| ... | ... | @@ -22,10 +22,7 @@ import org.springframework.web.bind.annotation.*; |
| 22 | 22 | import java.io.File; |
| 23 | 23 | import java.lang.reflect.Field; |
| 24 | 24 | import java.lang.reflect.Method; |
| 25 | -import java.util.ArrayList; | |
| 26 | -import java.util.HashMap; | |
| 27 | -import java.util.List; | |
| 28 | -import java.util.Map; | |
| 25 | +import java.util.*; | |
| 29 | 26 | |
| 30 | 27 | /** |
| 31 | 28 | * 【请填写功能名称】Controller |
| ... | ... | @@ -258,6 +255,23 @@ public class BsthTLineController extends BaseController |
| 258 | 255 | } |
| 259 | 256 | |
| 260 | 257 | |
| 258 | + @PostMapping("/getStations") | |
| 259 | + @ResponseBody | |
| 260 | + public AjaxResult getStations() | |
| 261 | + { | |
| 262 | + List<BsthTLine> bsthTLines=bsthTLineService.selectBsthTLineList(null); | |
| 263 | + List<String> result =new ArrayList<>(); | |
| 264 | + bsthTLines.forEach(bsthTLine -> { | |
| 265 | + String halfwayStation=bsthTLine.getHalfwayStation(); | |
| 266 | + String[] arr=halfwayStation.split("、"); | |
| 267 | + List<String> list=Arrays.asList(arr); | |
| 268 | + result.addAll(list); | |
| 269 | + }); | |
| 270 | + LinkedHashSet<String> stations=new LinkedHashSet<>(result); | |
| 271 | + AjaxResult ajaxResult=new AjaxResult(); | |
| 272 | + ajaxResult.put("stations",stations); | |
| 273 | + return ajaxResult; | |
| 274 | + } | |
| 261 | 275 | |
| 262 | 276 | /* |
| 263 | 277 | ... | ... |
bsthLineProfiles/src/main/resources/mybatis/mybatis/system/BsthTLineMapper.xml
bsthLineProfiles/src/main/resources/templates/system/line/map.html
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | <head> |
| 5 | 5 | |
| 6 | 6 | <th:block th:include="include :: header('地图查询')" /> |
| 7 | - | |
| 7 | +<th:block th:include="include :: select2-css" /> | |
| 8 | 8 | <style> |
| 9 | 9 | body, html, #container { |
| 10 | 10 | overflow: hidden; |
| ... | ... | @@ -40,10 +40,64 @@ body, html, #container { |
| 40 | 40 | </head> |
| 41 | 41 | <body> |
| 42 | 42 | <div class="info"> |
| 43 | - <input type="text" class="form-control" id="distance" | |
| 44 | - placeholder="查询范围(单位米)" value="500" /> | |
| 43 | + <ul class="nav nav-tabs" role="tablist"> | |
| 44 | + <li role="presentation" class="active"><a onclick="show('road','station')" role="tab" data-toggle="tab">站点查询</a></li> | |
| 45 | + <li role="presentation"><a onclick="show('station','road')" role="tab" data-toggle="tab">道路查询</a></li> | |
| 46 | + </ul> | |
| 47 | + | |
| 48 | + <div id="station"> | |
| 49 | + <div class="row"> | |
| 50 | + <h4></h4> | |
| 51 | + <label class="col-sm-3"><h4> 站点</h4></label> | |
| 52 | + <div class="col-sm-9" > | |
| 53 | + <select id='stations' > | |
| 54 | + <option value=""></option> | |
| 55 | + </select> | |
| 56 | + </div> | |
| 57 | + <h4></h4> | |
| 58 | + </div> | |
| 59 | + <div class="row"> | |
| 60 | + <h4></h4> | |
| 61 | + <label class="col-sm-3"><h4> 范围</h4></label> | |
| 62 | + <div class="col-sm-9"> | |
| 63 | + <input id="distance" class="form-control" type="text" placeholder="单位米"> | |
| 64 | + </div> | |
| 65 | + <h4></h4> | |
| 66 | + </div> | |
| 67 | + <div class="row"> | |
| 68 | + <h4></h4> | |
| 69 | + <div class="col-sm-4" > | |
| 70 | + <button type="button" class="el-button el-button--primary el-button--mini" onclick="searchStation()"><!----><i class="el-icon-search"></i><span>搜索</span></button> | |
| 71 | + </div> | |
| 72 | + <div class="col-sm-4"> | |
| 73 | + <button type="button" class="el-button el-button--default el-button--mini" onclick="$.form.reset();"><!----><i class="el-icon-refresh"></i><span>清除站点结果</span></button> | |
| 74 | + </div> | |
| 75 | + </div> | |
| 76 | + </div> | |
| 77 | + | |
| 78 | + <div id="road" style="display:none;"> | |
| 79 | + <div class="row"> | |
| 80 | + <h4></h4> | |
| 81 | + <label class="col-sm-3"><h4> 路名</h4></label> | |
| 82 | + <div class="col-sm-9"> | |
| 83 | + <input id="roadName" class="form-control" type="text"> | |
| 84 | + </div> | |
| 85 | + <h4></h4> | |
| 86 | + </div> | |
| 87 | + <div class="row"> | |
| 88 | + <h4></h4> | |
| 89 | + <div class="col-sm-4"> | |
| 90 | + <button type="button" class="el-button el-button--primary el-button--mini" onclick="searchRoad();"><!----><i class="el-icon-search"></i><span>搜索</span></button> | |
| 91 | + </div> | |
| 92 | + <div class="col-sm-4"> | |
| 93 | + <button type="button" class="el-button el-button--default el-button--mini" onclick="$.form.reset();"><!----><i class="el-icon-refresh"></i><span>清除站点结果</span></button> | |
| 94 | + </div> | |
| 95 | + </div> | |
| 96 | + </div> | |
| 97 | + | |
| 45 | 98 | </div> |
| 46 | 99 | |
| 100 | + | |
| 47 | 101 | <!-- <div class="info col-lg-6"> |
| 48 | 102 | <div class="input-group"> |
| 49 | 103 | <input type="text" class="form-control" id="text"> |
| ... | ... | @@ -66,6 +120,7 @@ body, html, #container { |
| 66 | 120 | <div id="container"></div> |
| 67 | 121 | <th:block th:include="include :: footer" /> |
| 68 | 122 | <th:block th:include="include :: bootstrap-suggest-js" /> |
| 123 | + <th:block th:include="include :: select2-js" /> | |
| 69 | 124 | <script> |
| 70 | 125 | var map = new BMapGL.Map('container'); // 创建Map实例 |
| 71 | 126 | map.centerAndZoom(new BMapGL.Point(121.528733, 31.237425), 12); // 初始化地图,设置中心点坐标和地图级别 |
| ... | ... | @@ -75,57 +130,196 @@ body, html, #container { |
| 75 | 130 | if (e.overlay) { |
| 76 | 131 | return; // 存在覆盖物退出 |
| 77 | 132 | } |
| 78 | - map.clearOverlays(); | |
| 79 | 133 | |
| 134 | + | |
| 135 | + }); | |
| 136 | + | |
| 137 | + var stations | |
| 138 | + $.ajax({ | |
| 139 | + // get请求地址 | |
| 140 | + url: "../line/getStations", | |
| 141 | + dataType: "json", | |
| 142 | + type:'POST', | |
| 143 | + success: function (data) { | |
| 144 | + stations=data.stations; | |
| 145 | + var arr = new Array(); | |
| 146 | + for (var i = 0; i < stations.length; i++) { | |
| 147 | + var station=new Object(); | |
| 148 | + station.id=stations[i]; | |
| 149 | + station.text=stations[i]; | |
| 150 | + station.value=stations[i]; | |
| 151 | + arr.push(station); | |
| 152 | + } | |
| 153 | + $("#stations").select2({ | |
| 154 | + data: arr, | |
| 155 | + placeholder:'请选择', | |
| 156 | + allowClear:true | |
| 157 | + }) | |
| 158 | + | |
| 159 | + } | |
| 160 | + }); | |
| 161 | + function searchStation(){ | |
| 162 | + var station=$('#stations').select2('val'); | |
| 163 | + var distance=$("#distance").val() | |
| 164 | + //创建地址解析器实例 | |
| 165 | + var myGeo = new BMapGL.Geocoder(); | |
| 166 | + // 将地址解析结果显示在地图上,并调整地图视野 | |
| 167 | + myGeo.getPoint(station, function(point){ | |
| 168 | + map.clearOverlays(); | |
| 169 | + map.centerAndZoom(point, 18); | |
| 170 | + a(point.lng,point.lat,distance) | |
| 171 | + /*if(point){ | |
| 172 | + map.centerAndZoom(point, 16); | |
| 173 | + map.addOverlay(new BMapGL.Marker(point, {title: station})) | |
| 174 | + }else{ | |
| 175 | + alert('您选择的地址没有解析到结果!'); | |
| 176 | + }*/ | |
| 177 | + }, '上海市') | |
| 178 | + /* var station=$('#stations').select2('val'); | |
| 179 | + console.log(station); | |
| 180 | + var local = new BMapGL.LocalSearch(map, { | |
| 181 | + renderOptions:{map: map} | |
| 182 | + }); | |
| 183 | + local.search(station);*/ | |
| 184 | + } | |
| 185 | + function searchRoad(){ | |
| 186 | + var roadName=$('#roadName').val(); | |
| 187 | + var distance=1000000000; | |
| 188 | + //创建地址解析器实例 | |
| 189 | + var myGeo = new BMapGL.Geocoder(); | |
| 190 | + // 将地址解析结果显示在地图上,并调整地图视野 | |
| 191 | + myGeo.getPoint(roadName, function(point){ | |
| 192 | + map.clearOverlays(); | |
| 193 | + map.centerAndZoom(point, 18); | |
| 194 | + b(point.lng,point.lat,distance,roadName) | |
| 195 | + /*if(point){ | |
| 196 | + map.centerAndZoom(point, 16); | |
| 197 | + map.addOverlay(new BMapGL.Marker(point, {title: station})) | |
| 198 | + }else{ | |
| 199 | + alert('您选择的地址没有解析到结果!'); | |
| 200 | + }*/ | |
| 201 | + }, '上海市') | |
| 202 | + } | |
| 203 | + function a(lng,lat,distance){ | |
| 80 | 204 | $.get("http://180.167.126.126:18991/prod-api/service/interfact/getStation?lng=" |
| 81 | - + e.latlng.lng + "&lat=" + e.latlng.lat + "&dis=" | |
| 82 | - + $("#distance").val() / 1000, function(data) { | |
| 205 | + +lng + "&lat=" + lat + "&dis=" | |
| 206 | + + distance / 1000, function(data) { | |
| 83 | 207 | if (data.code == "200") { |
| 84 | 208 | for ( var i in data.data) { |
| 85 | 209 | (function(){ |
| 86 | - var station = data.data[i]; | |
| 87 | - var marker = new BMapGL.Marker(new BMapGL.Point(station.lonBd, station.latBd),{title:station.standardStationCode}); | |
| 88 | - var label = new BMapGL.Label(station.stationName); | |
| 210 | + var station = data.data[i]; | |
| 211 | + var marker = new BMapGL.Marker(new BMapGL.Point(station.lonBd, station.latBd),{title:station.standardStationCode}); | |
| 212 | + /* var label = new BMapGL.Label(station.stationName); | |
| 89 | 213 | |
| 90 | - marker.setLabel(label); | |
| 214 | + marker.setLabel(label);*/ | |
| 91 | 215 | |
| 92 | - | |
| 93 | - marker.station = data.data[i]; | |
| 94 | - | |
| 95 | - var opts = { | |
| 96 | - width: 200, | |
| 97 | - height: 200, | |
| 98 | - title: station.stationName | |
| 216 | + marker.station = data.data[i]; | |
| 217 | + | |
| 218 | + var opts = { | |
| 219 | + width: 200, | |
| 220 | + height: 200, | |
| 221 | + title: station.stationName | |
| 99 | 222 | }; |
| 100 | - | |
| 101 | - var info = ""; | |
| 102 | - info += "<span>站点名称:" + data.data[i].stationName | |
| 103 | - + "</span><br/>"; | |
| 104 | - info += "<span>行业编码:" + data.data[i].standardStationCode | |
| 105 | - + "</span><br/>"; | |
| 106 | - info += "<span>站点编码:" + data.data[i].stationCode | |
| 107 | - + "</span><br/>"; | |
| 108 | - info += "<span>经过线路:" + data.data[i].lineList | |
| 109 | - + "</span><br/>"; | |
| 110 | - info += "<span>道路名称:" + data.data[i].roadName | |
| 111 | - + "</span><br/>"; | |
| 112 | - | |
| 113 | - var infoWindow = new BMapGL.InfoWindow(info, opts); | |
| 114 | - | |
| 115 | - | |
| 116 | - marker.addEventListener('click', function() { | |
| 117 | - map.openInfoWindow(infoWindow, new BMapGL.Point(station.lonBd, station.latBd)); // 开启信息窗口 | |
| 118 | - }); | |
| 223 | + var lineList=data.data[i].lineList; | |
| 224 | + var arr=lineList.split("、") | |
| 225 | + var str=''; | |
| 226 | + for ( var j in arr) { | |
| 227 | + str+="<a onClick='searchBus(\""+arr[j]+"\")'>"+arr[j]+"</a>、"; | |
| 228 | + } | |
| 229 | + var info = ""; | |
| 230 | + info += "<span>站点名称:" + data.data[i].stationName | |
| 231 | + + "</span><br/>"; | |
| 232 | + info += "<span>行业编码:" + data.data[i].standardStationCode | |
| 233 | + + "</span><br/>"; | |
| 234 | + info += "<span>站点编码:" + data.data[i].stationCode | |
| 235 | + + "</span><br/>"; | |
| 236 | + info += "<span>经过线路:" + str | |
| 237 | + + "</span><br/>"; | |
| 238 | + info += "<span>道路名称:" + data.data[i].roadName | |
| 239 | + + "</span><br/>"; | |
| 240 | + | |
| 241 | + var infoWindow = new BMapGL.InfoWindow(info, opts); | |
| 119 | 242 | |
| 120 | 243 | |
| 121 | - map.addOverlay(marker); | |
| 244 | + marker.addEventListener('click', function() { | |
| 245 | + map.openInfoWindow(infoWindow, new BMapGL.Point(station.lonBd, station.latBd)); // 开启信息窗口 | |
| 246 | + }); | |
| 247 | + map.addOverlay(marker); | |
| 122 | 248 | })(); |
| 123 | 249 | } |
| 124 | 250 | } |
| 125 | 251 | }); |
| 252 | + } | |
| 126 | 253 | |
| 127 | - }); | |
| 254 | + function b(lng,lat,distance,roadName){ | |
| 255 | + $.get("http://180.167.126.126:18991/prod-api/service/interfact/getStation?lng=" | |
| 256 | + +lng + "&lat=" + lat + "&dis=" | |
| 257 | + + distance / 1000, function(data) { | |
| 258 | + if (data.code == "200") { | |
| 259 | + for ( var i in data.data) { | |
| 260 | + (function(){ | |
| 261 | + var station = data.data[i]; | |
| 262 | + var marker = new BMapGL.Marker(new BMapGL.Point(station.lonBd, station.latBd),{title:station.standardStationCode}); | |
| 263 | + /* var label = new BMapGL.Label(station.stationName); | |
| 264 | + | |
| 265 | + marker.setLabel(label);*/ | |
| 266 | + | |
| 267 | + marker.station = data.data[i]; | |
| 268 | + | |
| 269 | + var opts = { | |
| 270 | + width: 200, | |
| 271 | + height: 200, | |
| 272 | + title: station.stationName | |
| 273 | + }; | |
| 274 | + | |
| 275 | + var lineList=data.data[i].lineList; | |
| 276 | + var arr=lineList.split("、") | |
| 277 | + var str=''; | |
| 278 | + for ( var j in arr) { | |
| 279 | + str+="<a onClick='searchBus(\""+arr[j]+"\")'>"+arr[j]+"</a>、"; | |
| 280 | + } | |
| 281 | + var info = ""; | |
| 282 | + info += "<span>站点名称:" + data.data[i].stationName | |
| 283 | + + "</span><br/>"; | |
| 284 | + info += "<span>行业编码:" + data.data[i].standardStationCode | |
| 285 | + + "</span><br/>"; | |
| 286 | + info += "<span>站点编码:" + data.data[i].stationCode | |
| 287 | + + "</span><br/>"; | |
| 288 | + info += "<span>经过线路:" + str | |
| 289 | + + "</span><br/>"; | |
| 290 | + info += "<span>道路名称:" + data.data[i].roadName | |
| 291 | + + "</span><br/>"; | |
| 128 | 292 | |
| 293 | + var infoWindow = new BMapGL.InfoWindow(info, opts); | |
| 294 | + | |
| 295 | + | |
| 296 | + marker.addEventListener('click', function() { | |
| 297 | + map.openInfoWindow(infoWindow, new BMapGL.Point(station.lonBd, station.latBd)); // 开启信息窗口 | |
| 298 | + }); | |
| 299 | + | |
| 300 | + if(data.data[i].roadName==roadName){ | |
| 301 | + map.addOverlay(marker); | |
| 302 | + } | |
| 303 | + | |
| 304 | + })(); | |
| 305 | + } | |
| 306 | + } | |
| 307 | + }); | |
| 308 | + } | |
| 309 | + | |
| 310 | + function searchBus(busName){ | |
| 311 | + console.log(busName) | |
| 312 | + var busline = new BMapGL.BusLineSearch(map,{ | |
| 313 | + renderOptions:{map:map,panel:"r-result"}, | |
| 314 | + onGetBusListComplete: function(result){ | |
| 315 | + if(result) { | |
| 316 | + var fstLine = result.getBusListItem(0);//获取第一个公交列表显示到map上 | |
| 317 | + busline.getBusLine(fstLine); | |
| 318 | + } | |
| 319 | + } | |
| 320 | + }); | |
| 321 | + busline.getBusList(busName); | |
| 322 | + } | |
| 129 | 323 | /* $("#text").bsSuggest({ |
| 130 | 324 | url : "/system/line/getListForMap", |
| 131 | 325 | effectiveFields : [ "lineName" ], |
| ... | ... | @@ -194,6 +388,10 @@ body, html, #container { |
| 194 | 388 | |
| 195 | 389 | } |
| 196 | 390 | }); */ |
| 391 | + function show(id1,id2){ | |
| 392 | + $('#'+id1).attr("style","display:none;"); | |
| 393 | + $('#'+id2).attr("style","display:show;"); | |
| 394 | + } | |
| 197 | 395 | </script> |
| 198 | 396 | |
| 199 | 397 | ... | ... |