Select to view content in your preferred language

Zoom to Feature from List: Issues with dataProvider attributes

519
2
04-21-2014 01:55 PM
JohnRitsko
Deactivated User
Greetings,

  Here is what I'm working on.  We have a list of Bus Routes.  When a user clicks on a Bus Route from the list it calls a MouseEvent that zooms to that particular route.  I can get it to zoom to the route but the problem is with how the List is populated.  Since the List is populating from the queryTask.executeLastResult.features it's populating the List with these long named features from what I can tell.  What I want it to do is populate the List with the NAME attribute that stores the Route Name.

I have provided the code below of how I created the list, and then the functions that I seem to be stuck on.

I have also created a <esri:GraphicsLayer id="myGraphicsLayer"/> inside my <esri:Map> tag if that helps. 
I also have the Selected Route changing to a different color but can't seem to reset it back if a new route is selected.

Currently this is what gets populated in the LIST for the NAMES:
RTCInteractiveSystemMap.ApplicationSkin3._ApplicationSkin_Group1.contectGroup.BorderContainer6.BorderContainerSkin9.Group10.myMap.LayerContainer12.myGraphicsLayer.Graphic###

The ### represent the different graphics in the List and change for each record in the list.

I need it to show the NAME attribute of the data.


private var contentNavigator:ContentNavigator = new ContentNavigator();     protected function doQuery():void {  queryTask.execute(query);     }    protected function routeList_clickHandler(event:MouseEvent):void {  var currentGraphic:Graphic = List(event.currentTarget).selectedItem as Graphic;  contentNavigator.dataProvider = new ArrayList([ currentGraphic ]);         currentGraphic.symbol = sls1;   myMap.zoomTo(currentGraphic.geometry); }     protected function queryTask_executeCompleteHandler(event:QueryEvent):void {  myGraphicsLayer.graphicProvider = event.featureSet.features;  routeList.dataProvider = new ArrayCollection(queryTask.executeLastResult.features);        /* This is where the List is getting populated but if I change it to ".attributes" instead of features it of course doesn't work */        /* routeList.LabelField = "NAME"; */ }


<s:List id="routeList"    x="10" y="10"   width="225" height="554"   rollOverColor="#CCCCCC"   horizontalScrollPolicy="on"   visible="{queryTask.executeLastResult !=null}"   creationComplete="doQuery()"   click="routeList_clickHandler(event)"/>
Tags (2)
0 Kudos
2 Replies
AaronNash1
Frequent Contributor
I had a similar problem and this was how I solved it

try changing routeList.dataProvider = new ArrayCollection(queryTask.executeLastResult.features);

to routeList.dataProvider = new ArrayList(event.featureSet.features); and then apply an itemrenderer to your list

<s:itemRenderer>
      <fx:Component>
           <s:ItemRenderer>
                 <s:Label height="20" left="5" text="{data.attributes.NAME}" verticalAlign="middle"/>
           </s:ItemRenderer>
      </fx:Component>
</s:itemRenderer>
0 Kudos
JohnRitsko
Deactivated User
That worked out great, thank you so very much.  Now my only issue is that I have the List with the horizontalScrollPolicy="on" but it still doesn't utilize that and cuts my text as I have shown below.  Any ideas on that.


[ATTACH=CONFIG]33246[/ATTACH]


I had a similar problem and this was how I solved it

try changing routeList.dataProvider = new ArrayCollection(queryTask.executeLastResult.features);

to routeList.dataProvider = new ArrayList(event.featureSet.features); and then apply an itemrenderer to your list

<s:itemRenderer>
      <fx:Component>
           <s:ItemRenderer>
                 <s:Label height="20" left="5" text="{data.attributes.NAME}" verticalAlign="middle"/>
           </s:ItemRenderer>
      </fx:Component>
</s:itemRenderer>
0 Kudos