edit
This commit is contained in:
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user