0

im triying to get the toll cost from a route and its giving me the most of the times an error. I think its the height but previusly, the route chosed other route but now, throws this error instead of show an alternative route.

Couldn't reach way point 1 (start links.......issues: illegal access, height.

im using this:

  var vehicleTypeToll;
  
 
  switch(varRoute.vehicle_type){
    case "car": vehicleTypeToll=2;
      break;
    case "truck": vehicleTypeToll=3;
      break;

  }
  
  if(varRoute.vehicle_type=='car'){
    toll_height=1.5+'m';
    toll_width=1.5+'m';
  }else{
    toll_height=varRoute.height/1000 +'m';
    toll_width=varRoute.width/1000 +'m';
  }

  let api ='fleet.ls.hereapi.com/2/calculateroute.json&app_id=***&app_code=***',
  apiKey = '***',
  waypoint0 = param_origen,
  waypointDestino = param_destino,
  
  mode = 'fastest;'+varRoute.vehicle_type+';',
  representation ='linkPaging',
  
  tollVehicleType = vehicleTypeToll,
  rollups ='tollsys,country,total',
  
  height = toll_height,
  width = toll_width,
  total_weight= varRoute.total_weight/1000+'t',
  total_length = varRoute.total_length/1000+'m',
  routeattributes= 'sh,sm',
  currency= 'EUR',
  
 //&vehicle_type=${vehicle_type}&total_weight=${total_weight}&total_lenght=${total_lenght}&width=${width}&height=${height}   
  url = `https://${api}?apiKey=${apiKey}&currency=${currency}&height=${height}&width=${width}&alternatives=0&total_weight=${total_weight}&total_length=${total_length}&routeAttributes=${routeattributes}&mode=${mode}&representation=${representation}&tollVehicleType=${tollVehicleType}&rollups=${rollups}&waypoint0=${waypoint0};`;
 
  //param_puntos_intermedios es un string en el cual se van concatenando coordenadas separadas por | (lat,long|lat,long), asi conseguír un array de puntos.


  
  var waypoints=param_puntos_intermedios.split('|');
  
  if(param_puntos_intermedios===''){
    url +='&waypoint1='+waypointDestino+';';

  }else{
  
    for(i=0;i<waypoints.length;i++){
      url += '&waypoint'+(i+1)+'='+waypoints[i]+';';
    }
   
    url +='&waypoint'+(waypoints.length+1)+'='+waypointDestino+';';
  }
  //Aqui se hace la llamada a la api de fleet, donde se obtiene los peajes por los que pasa.
 
  fetch(url)
      .then(response => response.json())
      .then(response => {
          console.log(response);
          console.log(height);
          set_vfp_route_tollcost(response.response.route[0].cost.totalCost);
          
      
      }, error => {
          console.error(error);
      });
     ```

Idk what is happening, Thanks in advance.
  • Hi, I don't think there is enough info for debugging. you might wanna give us more context. who is calling this code where data is coming from and where data is going to. are you using a framework or it's pure Js? – Eric Aska Nov 08 '21 at 20:42
  • Hi, this is an script called from another app but its not important, the problem is the exceptión im getting when i do the fetch, i think the problem is in the url because previusly the result was an alternative route not an exception. @EricAska – Pavire18 Nov 10 '21 at 07:42

0 Answers0