-
Notifications
You must be signed in to change notification settings - Fork 65
/
routing.js
42 lines (36 loc) · 1.38 KB
/
routing.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var tollCostCall = `https://fleet.ls.hereapi.com/2/calculateroute.json`+
`?apiKey=${window.hereCreds.JS_KEY}`+
`&waypoint0=52.53086235,13.38475371`+
`&waypoint1=53.13256,17.98909`+
`&mode=fastest;truck;traffic:enabled`+
`&alternatives=3`+
`&legAttributes=none`+
`&routeAttributes=none`+
`&driver_cost=10`+
`&vehicle_cost=0.5`+
`¤cy=EUR`+
`&customConsumptionDetails=40t`+
`&fuelType=Diesel`+
`&costPerConsumptionUnit=1.225`+
`&rollups=total,tollsys`+
`&trailersCount=1`+
`&weightPerAxle=10`+
`&tollVehicleType=3`+
`&trailerType=2`;
fetch(tollCostCall)
.then(response => response.json())
.then(response => {
console.log(response);
response.response.route.forEach(route=>{
document.getElementById("panel").innerHTML += `<br>`+ " Driver Cost: "+route.cost.details.driverCost+ " €"+
`<br>`+" Vehicle Cost: "+route.cost.details.vehicleCost+ " €"+
`<br>`+" Energy Cost: "+route.cost.details.energyCost+ " €";
route.tollCost.costsByTollSystem.forEach(tollSys =>{
document.getElementById("panel").innerHTML += `<br>`+ " Toll system Id: " + tollSys.tollSystemId + " Toll Amount "+tollSys.amountInTargetCurrency+ " €";
});
document.getElementById("panel").innerHTML += `<br>`+" Total Toll Cost: "+route.tollCost.totalCost.amountInTargetCurrency+ " €"+
`<br>`+" Total Cost: "+route.cost.totalCost+" €";
});
}, error =>{
console.error(error);
});