This commit is contained in:
Taric Xin
2022-03-09 16:00:58 +08:00
parent 2769384b9f
commit ebdad86950
4 changed files with 95 additions and 245 deletions

View File

@ -1,5 +1,5 @@
/*
* @Description :
* @Description :
* @Version : 1.0
* @Author : Shiming
* @Date : 2021-12-24 15:37:00
@ -24,8 +24,8 @@ export class AmapService {
sub = new Subject<any>();
currentSub = new Subject<any>();
//计算路径驾车最优路线的长度与所需时间
drivingCompute(starts: any[], ends: any[]): Observable<any> {
//计算路径驾车最优路线的长度与所需时间
drivingCompute(starts: any[], ends: any[]): Observable<any> {
AMap.plugin('AMap.Driving', () => {
let driving = new AMap.Driving({
// 驾车路线规划策略AMap.DrivingPolicy.LEAST_TIME是最快捷模式
@ -35,7 +35,10 @@ export class AmapService {
return { keyword: item.detailedAddress, city: item.city };
});
driving.search(points, (status: any, result: any) => {
const repData = { distance: (result?.routes?.[0]?.distance / 1000).toFixed(2), time: (result?.routes?.[0]?.time / 60 / 60).toFixed(2) };
const repData = {
distance: (result?.routes?.[0]?.distance / 1000).toFixed(2),
time: (result?.routes?.[0]?.time / 60 / 60).toFixed(2)
};
this.sub.next(repData);
});
});