var networkLayer= new Layer("my_url.../NaServer") //make a request on the rest api to get all the details of the NAServer Layer var details = networkLayer.getDetails() // in the details, get the network_attributes : I can then get the several cost existing in my Network var costs=details.network_attributes
<?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" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)"> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <fx:Script> <![CDATA[ import com.esri.serialization.json.JSON; import mx.events.FlexEvent; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.rpc.http.HTTPService; import mx.utils.ObjectUtil; private var httpServ:HTTPService; private function xmlResult(event:ResultEvent):void { var Info:Object = JSON.decode(event.result.toString()); trace(ObjectUtil.toString(Info.networkDataset.networkAttributes)); } private function xmlFault(event:FaultEvent):void { var sInfo:String = "Error: "; sInfo += "Event Target: " + event.target + "\n\n"; sInfo += "Event Type: " + event.type + "\n\n"; sInfo += "Fault Code: " + event.fault.faultCode + "\n\n"; sInfo += "Fault Info: " + event.fault.faultString; trace(sInfo); } protected function application1_creationCompleteHandler(event:FlexEvent):void { httpServ = new HTTPService; httpServ.url = "http://tasks.arcgisonline.com/ArcGIS/rest/services/NetworkAnalysis/ESRI_Route_NA/NAServer/Route?f=pjson"; httpServ.addEventListener(ResultEvent.RESULT, xmlResult); httpServ.addEventListener(FaultEvent.FAULT, xmlFault); httpServ.send(); } ]]> </fx:Script> </s:Application>