<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RouteTask Help in ArcGIS API for Flex Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/routetask-help/m-p/185321#M4338</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am attempting to solve a route between two points and display a tool tip indicating the estimated time a GPS transmitting vehicle has left to reach its destination.&amp;nbsp; This was working just fine, until I made some changes.&amp;nbsp; Now, I get what appears to be the start time instead of the Total_Time for the route.&amp;nbsp; I will attempt to condese my code so you can see what I am doing.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my controller I create 4 global variables for the route.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;private var route:RouteTask = new RouteTask();
private var routeParams:RouteParameters = new RouteParameters();
private var stops:Array = new Array;
private var fs:FeatureSet;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;When the user double clicks a vehicle I push the currentTarget to the stops array&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;stops = new Array;
stops.push(e.currentTarget as Graphic);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;I then send an httpService request to a web service that queries our orders database to get a collection of orders...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I loop through the results to find if an order has an enroute status, if it does, I add that order as a graphic to the stops array&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;route.concurrency = "last";
route.requestTimeout = 30;
route.addEventListener(RouteEvent.SOLVE_COMPLETE, onRouteResult);
route.addEventListener(FaultEvent.FAULT, onRouteFault);
route.url= "http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route";
stops.push(orderGra);
Model.instance.activeOrder = orderGra;
fs = new FeatureSet(stops);
routeParams.stops = fs;
routeParams.outSpatialReference = Model.instance.map.spatialReference;
if (stops.length &amp;gt; 1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; route.solve(routeParams)
}&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;When the RouteTask is complete I run this function and the routeResult.route.attributes.Total_Time is equal to what looks to be the start time rather than Total_Time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;private function onRouteResult(e:RouteEvent):void{
var routeResult:RouteResult = e.routeSolveResult.routeResults[0];
Model.instance.routeLayer.clear();
var gra:Graphic = routeResult.route;
if( routeResult.route.attributes.Total_Time){
&amp;nbsp;&amp;nbsp; gra.toolTip = "Expected arrival in " + Math.round(Number(routeResult.route.attributes.Total_Time)) + " minutes";
&amp;nbsp;&amp;nbsp; gra.symbol = new SimpleLineSymbol("solid", 0x0000FF, .5, 5);
&amp;nbsp;&amp;nbsp; Model.instance.routeLayer.add(gra);
&amp;nbsp;&amp;nbsp; vehicleGroupAC.addItem(gra);
&amp;nbsp;&amp;nbsp; var extent:Extent = GraphicUtil.getGraphicsExtent(vehicleGroupAC.toArray());
&amp;nbsp;&amp;nbsp; if(extent){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Model.instance.map.extent = extent;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!Model.instance.map.extent.containsExtent(extent)){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Model.instance.map.level--;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }&amp;nbsp; 
}
}&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Casey&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Aug 2010 15:47:15 GMT</pubDate>
    <dc:creator>CaseyBentz</dc:creator>
    <dc:date>2010-08-16T15:47:15Z</dc:date>
    <item>
      <title>RouteTask Help</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/routetask-help/m-p/185321#M4338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am attempting to solve a route between two points and display a tool tip indicating the estimated time a GPS transmitting vehicle has left to reach its destination.&amp;nbsp; This was working just fine, until I made some changes.&amp;nbsp; Now, I get what appears to be the start time instead of the Total_Time for the route.&amp;nbsp; I will attempt to condese my code so you can see what I am doing.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my controller I create 4 global variables for the route.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;private var route:RouteTask = new RouteTask();
private var routeParams:RouteParameters = new RouteParameters();
private var stops:Array = new Array;
private var fs:FeatureSet;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;When the user double clicks a vehicle I push the currentTarget to the stops array&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;stops = new Array;
stops.push(e.currentTarget as Graphic);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;I then send an httpService request to a web service that queries our orders database to get a collection of orders...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I loop through the results to find if an order has an enroute status, if it does, I add that order as a graphic to the stops array&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;route.concurrency = "last";
route.requestTimeout = 30;
route.addEventListener(RouteEvent.SOLVE_COMPLETE, onRouteResult);
route.addEventListener(FaultEvent.FAULT, onRouteFault);
route.url= "http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route";
stops.push(orderGra);
Model.instance.activeOrder = orderGra;
fs = new FeatureSet(stops);
routeParams.stops = fs;
routeParams.outSpatialReference = Model.instance.map.spatialReference;
if (stops.length &amp;gt; 1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; route.solve(routeParams)
}&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;When the RouteTask is complete I run this function and the routeResult.route.attributes.Total_Time is equal to what looks to be the start time rather than Total_Time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;private function onRouteResult(e:RouteEvent):void{
var routeResult:RouteResult = e.routeSolveResult.routeResults[0];
Model.instance.routeLayer.clear();
var gra:Graphic = routeResult.route;
if( routeResult.route.attributes.Total_Time){
&amp;nbsp;&amp;nbsp; gra.toolTip = "Expected arrival in " + Math.round(Number(routeResult.route.attributes.Total_Time)) + " minutes";
&amp;nbsp;&amp;nbsp; gra.symbol = new SimpleLineSymbol("solid", 0x0000FF, .5, 5);
&amp;nbsp;&amp;nbsp; Model.instance.routeLayer.add(gra);
&amp;nbsp;&amp;nbsp; vehicleGroupAC.addItem(gra);
&amp;nbsp;&amp;nbsp; var extent:Extent = GraphicUtil.getGraphicsExtent(vehicleGroupAC.toArray());
&amp;nbsp;&amp;nbsp; if(extent){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Model.instance.map.extent = extent;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!Model.instance.map.extent.containsExtent(extent)){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Model.instance.map.level--;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp; }&amp;nbsp; 
}
}&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Casey&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Aug 2010 15:47:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/routetask-help/m-p/185321#M4338</guid>
      <dc:creator>CaseyBentz</dc:creator>
      <dc:date>2010-08-16T15:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: RouteTask Help</title>
      <link>https://community.esri.com/t5/arcgis-api-for-flex-questions/routetask-help/m-p/185322#M4339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I figured it out.&amp;nbsp; When I was creating the attributes for my vehicles, I had a Time field.&amp;nbsp; This time as being added to the route time.&amp;nbsp; So if I subtracted the Total_Time attribute from the Time field of the vehicle, I would get the actual route time.&amp;nbsp; I changed my field name to StatusTime and it now works as expected.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Casey&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Aug 2010 16:26:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-flex-questions/routetask-help/m-p/185322#M4339</guid>
      <dc:creator>CaseyBentz</dc:creator>
      <dc:date>2010-08-16T16:26:31Z</dc:date>
    </item>
  </channel>
</rss>

