Select to view content in your preferred language

[ArcGIS Server 10.0][NA Service] No route results after calling service

2306
1
Jump to solution
12-27-2012 04:31 AM
ab1
by
Deactivated User
Hello,

I have published a network analyst service and I'm trying to use it from the Flex API 3.1.
When I use the service in ArcMap or through the rest GUI in a browser, the service returns the right answer.
When I use the service from the Flex API 3.1, my object "routeResult" that contain the route returned by the server is null.
I get the error: "Error #1009: Cannot access a property or method of a null object reference." for the object routeResult.
Here my application code:
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"       xmlns:s="library://ns.adobe.com/flex/spark"       xmlns:mx="library://ns.adobe.com/flex/mx"       xmlns:esri="http://www.esri.com/2008/ags"       xmlns:layers="com.esri.ags.layers.*"       minWidth="1000" minHeight="600" viewSourceURL="Source/index.html">    <s:layout>   <s:BasicLayout/>  </s:layout>    <fx:Script>   <![CDATA[    import com.esri.ags.events.MapMouseEvent;    import com.esri.ags.events.RouteEvent;    import com.esri.ags.FeatureSet;    import com.esri.ags.Graphic;    import com.esri.ags.symbols.CompositeSymbol;    import com.esri.ags.symbols.SimpleMarkerSymbol;    import com.esri.ags.symbols.TextSymbol;    import com.esri.ags.tasks.supportClasses.RouteResult;        import mx.controls.Alert;    import mx.rpc.events.FaultEvent;        [Bindable]private var stops:FeatureSet = new FeatureSet([]);        [Bindable]private var lastRoute:Graphic;           private function mapClickHandler(event:MapMouseEvent):void    {     var stopSymbol:CompositeSymbol = new CompositeSymbol();     var circleSym:SimpleMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 20, 0x000099);     var textSym:TextSymbol = new TextSymbol(String(stops.features.length + 1));     textSym.textFormat = new TextFormat("Verdana", null, null, true);     textSym.color = 0xFFFFFF;     stopSymbol.symbols = [ circleSym, textSym ];                                      var stop:Graphic = new Graphic(event.mapPoint, stopSymbol);     inputsLayer.add(stop);     stops.features.push(stop);          if (stops.features.length > 1)     {      routeTask.solve(routeParams);     }    }        private function solveCompleteHandler(event:RouteEvent):void    {     var routeResult:RouteResult = event.routeSolveResult.routeResults[0];     lastRoute = routeResult.route;     lastRoute.toolTip = routeResult.routeName;     if (routeResult.route.attributes.Total_Time)     {      lastRoute.toolTip += " in " + Math.round(Number(routeResult.route.attributes.Total_Time)) + " minutes.";     }    }        private function faultHandler(event:FaultEvent):void    {     Alert.show(event.fault.faultString + "\n\n" + event.fault.faultDetail, "Routing Error " + event.fault.faultCode);     // Supprimer le dernier stop ou les deux s'il n'y en a pas plus.     if (stops.features.length <= 2)     {      inputsLayer.clear();      stops = new FeatureSet([]);     }     else     {      inputsLayer.remove(stops.features.pop());     }    }      ]]>  </fx:Script>     <fx:Declarations>     <esri:MapPoint id="mapPoint" x="655672" y="6861079"/>      <esri:RouteTask id="routeTask" concurrency="last" fault="faultHandler(event)"       requestTimeout="30" showBusyCursor="true"       solveComplete="solveCompleteHandler(event)"       url="http://serverIP:8399/arcgis/rest/services/na_service/MapServer/Route"/>      <esri:RouteParameters id="routeParams" stops="{stops}" returnDirections="false"/>      <esri:SimpleLineSymbol id="routeSymbol" width="5" alpha="0.6" color="0x000099"/>  </fx:Declarations>    <s:BorderContainer id="applicationHolder" width="100%" height="100%">         <s:layout>    <s:VerticalLayout/>   </s:layout>      <s:SkinnableContainer id="headerBar" width="100%" height="50" backgroundColor="0xcccccc">    <s:layout>     <s:HorizontalLayout verticalAlign="middle"/>    </s:layout>        <mx:Text id="titleText" fontSize="25" fontWeight="bold"       text="My application"/>    <mx:Spacer width="75"/>          </s:SkinnableContainer>      <esri:Map id="mainMap" width="100%" height="100%" center="{mapPoint}"       crosshairVisible="{crosshairsCheck.selected}" level="16"       mapClick="mapClickHandler(event)" panArrowsVisible="{panArrowsCheck.selected}">    <esri:ArcGISDynamicMapServiceLayer url="http://serverIP:8399/arcgis/rest/services/myMapService/MapServer"/>        <esri:GraphicsLayer graphicProvider="{lastRoute}" symbol="{routeSymbol}"/>    <esri:GraphicsLayer id="inputsLayer"/>   </esri:Map>     </s:BorderContainer> </s:Application>


Do you have any advice?

Regards
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ab1
by
Deactivated User
It was just a stupid mistake in the service url!
It's a NAServer not a MapServer!

View solution in original post

0 Kudos
1 Reply
ab1
by
Deactivated User
It was just a stupid mistake in the service url!
It's a NAServer not a MapServer!
0 Kudos