Greetings!To add to this thread, I am using a direct feed from a vehicle modem and just needed to use the coordinates or a MapPoint to create driving directions. Instead of using the searchTerm of the stopProvider for the coordinates, I set the location property of the stopProvider and use the searchTerm as a descriptor. This works very well. // create directions from the mobile vehicles current location to the selected call. var fromVehicle:DirectionsStop = drivingDirections.stopProvider[0]; fromVehicle.editable = false; var vehPT:MapPoint = vehGraphic.geometry as MapPoint; fromVehicle.location = vehPT; fromVehicle.searchTerm = "My Current Vehicle Location..."; // now get the call point var call:Call = ItemRenderer(event.target).data as Call; var toLocation:DirectionsStop = drivingDirections.stopProvider[1]; toLocation.editable = false; toLocation.searchTerm = call.address; toLocation.location = call.geometry; drivingDirections.getDirections();
// create directions from the mobile vehicles current location to the selected call. var fromVehicle:DirectionsStop = drivingDirections.stopProvider[0]; fromVehicle.editable = false; var vehPT:MapPoint = vehGraphic.geometry as MapPoint; fromVehicle.location = vehPT; fromVehicle.searchTerm = "My Current Vehicle Location..."; // now get the call point var call:Call = ItemRenderer(event.target).data as Call; var toLocation:DirectionsStop = drivingDirections.stopProvider[1]; toLocation.editable = false; toLocation.searchTerm = call.address; toLocation.location = call.geometry; drivingDirections.getDirections();
private function launchLandmarkDirections():void { landmarkDirectionComponent = new Directions; landmarkDirectionComponent.url = "http://tela.roktech.net/arcgis/rest/services/DigitalEgypt/EGIPA_NetworkStreet/NAServer/Route"; landmarkDirectionComponent.addEventListener(DirectionsEvent.DIRECTIONS_COMPLETE, landmarkDirectionsCompleteHandler); landmarkDirectionComponent.map = myMap; landmarkDirectionComponent.addEventListener(FlexEvent.CREATION_COMPLETE, setUpDirections) } private function setUpDirections(event:FlexEvent):void { var stop:DirectionsStop = landmarkDirectionComponent.stopProvider[0]; var driveString:String = new String; driveString = landmarkMapPoint.x + "," + landmarkMapPoint.y; trace(driveString); stop.searchTerm = driveString; }
Raffi, Is there a reason you are creating the Direction component programatically and not in the MXML markup? It is likely that the Directions component is not finished creating before you attempt to access it's stopprovider (timing issue).
Raffi, Don't create a new directionsStop just set the search term on the first one in the directions component. var stop:DirectionsStop = dir.stopProvider[0]; stop.editable = false; stop.searchTerm = '31.41189186200006,30.01863021300005';
var stop:DirectionsStop = dir.stopProvider[0]; stop.editable = false; stop.searchTerm = '31.41189186200006,30.01863021300005';
private function launchLandmarkDirections():void { landmarkDirectionComponent = new Directions; landmarkDirectionComponent.url = "http://tela.roktech.net/arcgis/rest/services/DigitalEgypt/EGIPA_NetworkStreet/NAServer/Route"; landmarkDirectionComponent.addEventListener(DirectionsEvent.DIRECTIONS_COMPLETE, landmarkDirectionsCompleteHandler); landmarkDirectionComponent.map = myMap; var stop:DirectionsStop = landmarkDirectionComponent.stopProvider[0]; stop.editable = false; stop.searchTerm = '31.41189186200006,30.01863021300005'; }
Wow, Great App Raffi. Its good to know that you can just send the XY to the stop provider. One of my requirement in the future will be to capture the mobile device location and use that as a stop -- stop[0]. This is going to come handy for me also in the near future.
private function launchLandmarkDirections():void{ var landmarkStopProvider = new DirectionsStop(); landmarkStopProvider.location = landmarkMapPoint; var stop2:DirectionsStop = new DirectionsStop(); trace(landmarkStopProvider.location); landmarkDirectionComponent = new Directions; landmarkDirectionComponent.url = "http://tela.roktech.net/arcgis/rest/services/DigitalEgypt/EGIPA_NetworkStreet/NAServer/Route"; landmarkDirectionComponent.addEventListener(DirectionsEvent.DIRECTIONS_COMPLETE, landmarkDirectionsCompleteHandler); landmarkDirectionComponent.map = myMap; landmarkDirectionComponent.stopProvider[0] = landmarkStopProvider; }
<?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:esri="http://www.esri.com/2008/ags" xmlns:mx="library://ns.adobe.com/flex/mx" pageTitle="Directions component sample"> <fx:Script> <![CDATA[ import com.esri.ags.SpatialReference; import com.esri.ags.components.supportClasses.DirectionsStop; import mx.events.FlexEvent; [Bindable] private var stop0:int=0; [Bindable] private var stop0Address:String="401 B Street, San Diego, California, 92101"; protected function dir_creationCompleteHandler(event:FlexEvent):void { var stop:DirectionsStop = dir.stopProvider[stop0]; stop.editable = false; stop.searchTerm = stop0Address; var i:int; var value:Object; var value2:Object; var stopCount:int=1; for (i=0; i<theAddress.length; i++) { value=theAddress.getItemAt(i); if(value.count==1) { var stop1:DirectionsStop = dir.stopProvider[1]; //set editable stop1.editable = true; stop1.searchTerm = value.addr; trace("Hello"+ value.addr); } if(value.count>1) { stopCount+=stopCount+1; //trace(value.addr); var st:DirectionsStop = new DirectionsStop(); st.stopId=stopCount; st.searchTerm = value.addr; dir.stopProvider.addItem(st); } } } ]]> </fx:Script> <fx:Declarations> <mx:ArrayCollection id="theAddress"> <fx:Object addr="1702 India St, San Diego, CA 92101" count="1" /> <fx:Object addr="1123 Island Ave, San Diego, California, 92102" count="2" /> <fx:Object addr="924 S 16th St, San Diego, California, 92102" count="3" /> <fx:Object addr="2025 L St, San Diego, California, 92102" count="4" /> </mx:ArrayCollection> </fx:Declarations> <s:layout> <s:HorizontalLayout paddingLeft="2"/> </s:layout> <esri:Directions width="320" height="100%" map="{map}" id="dir" creationComplete="dir_creationCompleteHandler(event)" url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/Route"/> <esri:Map id="map"> <esri:extent> <esri:WebMercatorExtent xmin="-13055785" ymin="3848161" xmax="-13025898" ymax="3866239" spatialReference="{new SpatialReference(102100)}"/> </esri:extent> <esri:ArcGISTiledMapServiceLayer/> </esri:Map> </s:Application>
<?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:esri="http://www.esri.com/2008/ags" pageTitle="Directions component sample"> <fx:Script> <![CDATA[ import com.esri.ags.SpatialReference; import com.esri.ags.components.supportClasses.DirectionsStop; import mx.events.FlexEvent; protected function dir_creationCompleteHandler(event:FlexEvent):void { var stop:DirectionsStop = dir.stopProvider[0]; stop.editable = false; stop.searchTerm = '1123 Island Ave, San Diego, California, 92102'; var stop2:DirectionsStop = dir.stopProvider[1]; stop2.editable = false; stop2.searchTerm = '924 S 16th St, San Diego, California, 92102'; var stop3:DirectionsStop = new DirectionsStop(); stop3.searchTerm = '2025 L St, San Diego, California, 92102' dir.stopProvider.addItem(stop3); } ]]> </fx:Script> <s:layout> <s:HorizontalLayout paddingLeft="2"/> </s:layout> <esri:Directions width="320" height="100%" map="{map}" id="dir" creationComplete="dir_creationCompleteHandler(event)" url="http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/NAServer/Route"/> <esri:Map id="map"> <esri:extent> <esri:WebMercatorExtent xmin="-13055785" ymin="3848161" xmax="-13025898" ymax="3866239" spatialReference="{new SpatialReference(102100)}"/> </esri:extent> <esri:ArcGISTiledMapServiceLayer/> </esri:Map> </s:Application>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.