How to calculate the travel time in the Network Analysis?

3654
3
Jump to solution
01-17-2016 07:42 PM
LinQing
New Contributor II

Hello everybody,

I am new for ArcGIS JS development. I want to get the travel time between 2 or more stops using ArcGIS API for JS, but I don't know which API I could use.

I have the network server pulished by myself and it has the fields of road length and speed limit. I just want to get the travel time between 2 places.

Appreciate for any suggestion.

Lin        

0 Kudos
1 Solution

Accepted Solutions
ChrisSmith7
Frequent Contributor

Also,

This sample may help as well:

Get driving directions | ArcGIS API for JavaScript

Here's the money line for travel time:

var totalLength = number.format(directions.totalTime);

Note, the sample isn't actually doing anything with it, but it does return (verified by console.log).

View solution in original post

3 Replies
ChrisSmith7
Frequent Contributor

Lin,

There's an Esri sample for travel time:

Analysis - Calculate travel time and distance | ArcGIS API for JavaScript

This particular sample uses ConnectOriginsToDestinations , which is "...part of the Analysis service in ArcGIS Online.Analysisis a subscription-based service available through ArcGIS Online".

You mentioned you have the network service available; I would have a look at RouteTask | API Reference | ArcGIS API for JavaScript

Note, you will need ArcGIS Server 9.3.1+ You cannot use an earlier version of ArcGIS Server if you wish to use RouteTask in the JSAPI.

Here's a sample:

Find a route | ArcGIS API for JavaScript

ChrisSmith7
Frequent Contributor

Also,

This sample may help as well:

Get driving directions | ArcGIS API for JavaScript

Here's the money line for travel time:

var totalLength = number.format(directions.totalTime);

Note, the sample isn't actually doing anything with it, but it does return (verified by console.log).

LinQing
New Contributor II

Thank you very much for your advice! I will try those methods and my ArcGIS Server is 10.2.^.^

0 Kudos