Route result time and distance with units

1128
8
07-05-2019 09:39 AM
ADITYAKUMAR1
Occasional Contributor III

Hi ,

   I am using routeresult to get the result of my route. I am getting the length for each segment as well as time.

array.forEach(routeResult.directions.features, function (feature) {
var direction = feature.attributes;
directions.push(direction);

The output is 

1: {length: 0.01642324482308207, time: 0.15858421215735188, text: "Go northwest", ETA: -2209161600000, arriveTimeUTC: -2209161600000, …}

Can I get something like 

The unit as been set as esriMiles in my code.

Any suggestion will be really helpful.

Thanks

Kumar

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus

Kumar,

   Why are you setting the direction length units to esriMiles when you are wanting the output to be in Meters?...

0 Kudos
ADITYAKUMAR1
Occasional Contributor III

Hi Robert,

 The image is just for reference.I am getting miles for distance but I am not sure of time unit as I have not set any time unit there.

Thanks
 Kumar

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Kumar,

   In your output you have time and ETA...

{length: 0.01642324482308207, time: 0.15858421215735188, text: "Go northwest", ETA: -2209161600000, arriveTimeUTC: -2209161600000, …}

0 Kudos
ADITYAKUMAR1
Occasional Contributor III

Yes. 

What I want to know is the units of length: 0.01642324482308207(which I suppose is Miles) and unit for time: 0.15858421215735188?

I am not able to get the unit of time. Is it minute/sec/hr?

Thanks

Kumar

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Time is in milliseconds

ADITYAKUMAR1
Occasional Contributor III

Thanks a lot Robert. It resolved the issue. But is there any way where we can get the unit of time? Because at the total time its giving me 22.05 which i suppose is minutes

number.format(routeResult.directions.totalTime); 

Thanks

Kumar

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

As I mentioned the unit will be milliseconds. So you just need to format/convert the milliseconds to what ever unit of time you want.

ADITYAKUMAR1
Occasional Contributor III

Yes. 

What I want to know is the units of length: 0.01642324482308207(which I suppose is Miles) and unit for time: 0.15858421215735188?

I am not able to get the unit of time. Is it minute/sec/hr?

Thanks

Kumar

0 Kudos