mySelectedRouteLayer.clear(); var graphic:Graphic; graphic = List(event.currentTarget).selectedItem as Graphic; var selectedRoute:int = graphic.attributes["ROUTE"]; query_Selection.where = "ROUTE = " + selectedRoute + ""; mySelectedRouteLayer.selectFeatures(query_Selection, FeatureLayer.SELECTION_NEW); mySelectedRouteLayer.selectionColor = NaN; // Zoomto the Extent of mySelectedRouteLayer
Solved! Go to Solution.
protected function routeList_changeHandler(event:IndexChangeEvent):void { mySelectedRouteLayer.clear(); var graphic:Graphic = List(event.currentTarget).selectedItem as Graphic; var selectedRoute:int = graphic.attributes["ROUTE"]; query_Selection.where = "ROUTE = " + selectedRoute + ""; mySelectedRouteLayer.selectFeatures(query_Selection, FeatureLayer.SELECTION_NEW); mySelectedRouteLayer.selectionColor = NaN; highlightStops(graphic); myMap.zoomTo(graphic.geometry.extent); }
var ac:ArrayCollection = mySelectedRouteLayer.graphicProvider as ArrayCollection; myMap.zoomTo(GraphicUtil.getGraphicsExtent( ac.toArray()) );
John,
In your selectionComplete function you use the AsyncToken that is returned and get the features array and feed that array to a GraphicUtil object and call the getGraphicsExtent method to get a extent and then you feed that to the myMap.zoomTo.
John,
If you follow my advice on getting the features array from the AsyncToken in the selectionComplete function (and not the graphicsPrivider) than you should be ok.
protected function routeList_changeHandler(event:IndexChangeEvent):void { mySelectedRouteLayer.clear(); var graphic:Graphic = List(event.currentTarget).selectedItem as Graphic; var selectedRoute:int = graphic.attributes["ROUTE"]; query_Selection.where = "ROUTE = " + selectedRoute + ""; mySelectedRouteLayer.selectFeatures(query_Selection, FeatureLayer.SELECTION_NEW); mySelectedRouteLayer.selectionColor = NaN; highlightStops(graphic); /* var routeExtent:Extent = GraphicUtil.getGraphicsExtent(graphic.toArray()); */ /* myMap.extent = routeExtent; */ var ac:ArrayCollection = mySelectedRouteLayer.graphicProvider as ArrayCollection; myMap.zoomTo(GraphicUtil.getGraphicsExtent(ac.toArray())); }
protected function doQuery():void { queryTask.execute(query, new AsyncResponder(onResult, onFault)); function onResult(featureSet:FeatureSet, token:Object = null):void { routeList.dataProvider = new ArrayCollection(featureSet.features); } function onFault(info:Object, token:Object = null):void { Alert.show( info.toString() ); } } <s:List id="routeList" x="10" y="10" width="225" height="575" rollOverColor="#CCCCCC" horizontalScrollPolicy="on" creationComplete="doQuery()" change="routeList_changeHandler(event)">
protected function routeList_changeHandler(event:IndexChangeEvent):void { mySelectedRouteLayer.clear(); var graphic:Graphic = List(event.currentTarget).selectedItem as Graphic; var selectedRoute:int = graphic.attributes["ROUTE"]; query_Selection.where = "ROUTE = " + selectedRoute + ""; mySelectedRouteLayer.selectFeatures(query_Selection, FeatureLayer.SELECTION_NEW); mySelectedRouteLayer.selectionColor = NaN; highlightStops(graphic); myMap.zoomTo(graphic.geometry.extent); }