Browse Source

[修改]修改路线查询bug

zhuzhou
邵佳豪 4 years ago
parent
commit
cb419fcabe
  1. 31
      src/app/gis-management/gis-labeling/gis-labeling.component.ts
  2. 24
      src/app/key-unit/router-gis/router-gis.component.ts

31
src/app/gis-management/gis-labeling/gis-labeling.component.ts

@ -915,12 +915,19 @@ export class GisLabelingComponent implements OnInit {
var autoComplete = new AMap.Autocomplete(autoOptions); var autoComplete = new AMap.Autocomplete(autoOptions);
autoComplete.search(keywords, function(status, result) { autoComplete.search(keywords, function(status, result) {
if (result && result.tips && result.tips.length) { //搜索到数据时 if (result && result.tips && result.tips.length) { //搜索到数据时
that._ngZone.run(()=>{ that._ngZone.run(()=>{
if(e == 0){ if(e == 0){//起点
that.routeStartList = result.tips that.routeStartList = result.tips
that.startCoordinate = new AMap.LngLat(result.tips[0].location.lng, result.tips[0].location.lat) if(result.tips.length != 0){
}else{ for (let index = 0; index < result.tips.length; index++) {
const element = result.tips[index];
if(element.location){
that.startCoordinate = new AMap.LngLat(element.location.lng, element.location.lat)
return
}
}
}
}else{//终点
that.routeEndList = result.tips that.routeEndList = result.tips
that.endCoordinate = new AMap.LngLat(result.tips[0].location.lng, result.tips[0].location.lat) that.endCoordinate = new AMap.LngLat(result.tips[0].location.lng, result.tips[0].location.lat)
} }
@ -986,6 +993,19 @@ export class GisLabelingComponent implements OnInit {
this.routeGIS = new AMap.Driving({ this.routeGIS = new AMap.Driving({
map: this.map, map: this.map,
}); });
if(!this.startCoordinate){
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('未查询到起点坐标信息,请输入有效地址','确定',config);
return
}else if(!this.startCoordinate){
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('未查询到终点坐标信息,请输入有效地址','确定',config);
return
}else{
this.routeGIS.search(this.startCoordinate,this.endCoordinate, this.routeGIS.search(this.startCoordinate,this.endCoordinate,
function(status, result) { function(status, result) {
if (status === 'complete') { if (status === 'complete') {
@ -995,6 +1015,8 @@ export class GisLabelingComponent implements OnInit {
); );
} }
}
//切换 导航模式 推荐方案/躲避拥堵 //切换 导航模式 推荐方案/躲避拥堵
toggleRoute (e) { toggleRoute (e) {
let that = this let that = this
@ -1006,6 +1028,7 @@ export class GisLabelingComponent implements OnInit {
policy: e==true? AMap.DrivingPolicy.LEAST_TIME : AMap.DrivingPolicy.REAL_TRAFFIC policy: e==true? AMap.DrivingPolicy.LEAST_TIME : AMap.DrivingPolicy.REAL_TRAFFIC
}); });
// 根据起终点名称规划驾车导航路线 // 根据起终点名称规划驾车导航路线
this.routeGIS.search(this.startCoordinate,this.endCoordinate, this.routeGIS.search(this.startCoordinate,this.endCoordinate,
function(status, result) { function(status, result) {
if (status === 'complete') { if (status === 'complete') {

24
src/app/key-unit/router-gis/router-gis.component.ts

@ -60,7 +60,15 @@ export class RouterGISComponent implements OnInit {
that._ngZone.run(()=>{ that._ngZone.run(()=>{
if(e == 0){ if(e == 0){
that.routeStartList = result.tips that.routeStartList = result.tips
that.startCoordinate = new AMap.LngLat(result.tips[0].location.lng, result.tips[0].location.lat) if(result.tips.length != 0){
for (let index = 0; index < result.tips.length; index++) {
const element = result.tips[index];
if(element.location){
that.startCoordinate = new AMap.LngLat(element.location.lng, element.location.lat)
return
}
}
}
}else{ }else{
that.routeEndList = result.tips that.routeEndList = result.tips
that.endCoordinate = new AMap.LngLat(result.tips[0].location.lng, result.tips[0].location.lat) that.endCoordinate = new AMap.LngLat(result.tips[0].location.lng, result.tips[0].location.lat)
@ -127,6 +135,19 @@ export class RouterGISComponent implements OnInit {
this.routeGIS = new AMap.Driving({ this.routeGIS = new AMap.Driving({
map: this.map, map: this.map,
}); });
if(!this.startCoordinate){
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('未查询到起点坐标信息,请输入有效地址','确定',config);
return
}else if(!this.startCoordinate){
let config = new MatSnackBarConfig();
config.verticalPosition = 'top';
config.duration = 3000
this.snackBar.open('未查询到终点坐标信息,请输入有效地址','确定',config);
return
}else{
this.routeGIS.search(this.startCoordinate,this.endCoordinate, this.routeGIS.search(this.startCoordinate,this.endCoordinate,
function(status, result) { function(status, result) {
if (status === 'complete') { if (status === 'complete') {
@ -134,6 +155,7 @@ export class RouterGISComponent implements OnInit {
} else { alert('获取驾驶规划路线失败') } } else { alert('获取驾驶规划路线失败') }
} }
); );
}
} else { } else {
const config = new MatSnackBarConfig(); const config = new MatSnackBarConfig();
config.verticalPosition = 'top'; config.verticalPosition = 'top';

Loading…
Cancel
Save