I am currently in the process of developing a web application that needs to generate a large number of routes and display their distances. The starting waypoint remains constant for all routes. My approach to achieving this is as follows:
function calculateRouteFromAtoB (platform, end) {
var router = platform.getRoutingService(),
routeRequestParams = {
mode: 'fastest;truck;traffic:enabled',
height: '7',
weightPerAxle: '4',
trailersCount: '1',
routeattributes : 'sh,bb,gr',
dirtRoad: '-3',
tollroad:'-3',
//tunnelCategory: 'E',
//maneuverattributes: 'direction,action',
'waypoint0': '50.6431675,29.9479832',
'waypoint1': end
};
router.calculateRoute(
routeRequestParams,
onSuccess,
onError
);
}
var tt;
for(tt=0;tt<array_with_endpoints.length;tt++){
calculateRouteFromAtoB(platform,array_with_endpoints[tt]);
}
The calculateRouteFromAtoB
function adds the route to the map along with its distance on the panel. However, there seems to be an issue as the displayed route length on the panel does not accurately represent the real route length. It appears that endpoints are being randomly chosen. If you have any suggestions on how to modify the code so that it selects endpoints in order, please share your insights.