Select to view content in your preferred language

Bind Identify Results to a datagroup

558
2
06-23-2011 05:00 AM
AaronNash
Deactivated User
I am looking at the identify code sample and I have it running in an application. I would like the results to show in a datagroup like how Robert's Identify Widget works. This is the code that I am using out of the sample code section. The pop up works fine on a mouse click and the data is populated. 
  private function mapClickHandler(event:MapMouseEvent):void
  {
   clickGraphicsLayer.clear();   
   var identifyParams:IdentifyParameters = new IdentifyParameters();
   identifyParams.returnGeometry = true;
   identifyParams.tolerance = 3;
   identifyParams.width = map.width;
   identifyParams.height = map.height;
   identifyParams.geometry = event.mapPoint;
   identifyParams.mapExtent = map.extent;
   identifyParams.spatialReference = map.spatialReference;     
   var clickGraphic:Graphic = new Graphic(event.mapPoint, clickPtSym);
   clickGraphicsLayer.add(clickGraphic);    
   identifyTask.execute(identifyParams, new AsyncResponder(myResultFunction, myFaultFunction, clickGraphic));
  }

  private function myResultFunction(results:Array, clickGraphic:Graphic = null):void
  {
   if (results && results.length > 0)
   {
    var result:IdentifyResult = results[0];
    var resultGraphic:Graphic = result.feature;
    switch (resultGraphic.geometry.type)
    {
     case Geometry.MAPPOINT:
     {
      resultGraphic.symbol = smsIdentify;
      break;
     }
     case Geometry.POLYLINE:
     {
      resultGraphic.symbol = slsIdentify;
      break;
     }
     case Geometry.POLYGON:
     {
      resultGraphic.symbol = sfsIdentify;
      break;
     }
    }
    lastIdentifyResultGraphic = resultGraphic;     
    // update clickGraphic (from mouse click to returned feature)
    clickGraphic.symbol = new InfoSymbol(); // use default renderer
    clickGraphic.attributes = resultGraphic.attributes;
   }
  }

Here is the code I am using for the datagroup
   [Bindable]
  private var resultGraphic:IList;

<s:Scroller visible="false" id="resultlist" width="100%" height="100%">
  <s:DataGroup dataProvider="{resultGraphic}" visible="true">
   <s:layout>
    <s:VerticalLayout gap="2" horizontalAlign="justify" useVirtualLayout="true"/>
   </s:layout> 
  </s:DataGroup>
 </s:Scroller> 


Unfortunately the data is not being populated in the datagroup. Am I binding the wrong value? Any help would be appreciated
Tags (2)
0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor
In my application, I've taken the results of the Identify and pushed it into an array, then set the DataGrid's dataProvider to that array. This is part of a larger code for an application that takes the IdentifyResults from all the visible layers and puts the results from each layer into a separate tab in an InfoWindow.

                identifyTask.execute(identifyParams, new AsyncResponder(resultFunction, faultFunction, clickGraphic));

                function resultFunction(results:Array, clickGraphic:Graphic):void
                {
                    if (results && results.length > 0)
                    {
                        var resultsArray:Array = [];
                        var newDG:DataGrid = new DataGrid;

                        resultsArray.push(result.feature.attributes);
                        newDG = new DataGrid;
                        newDG.dataProvider = resultsArray;
                    }
                }


In reading your post, I was seeing DataGrid instead of DataGroup. However, the dataProvider expects an IList, which could be an ArrayCollection, ArrayList, and       XMLListCollection, so you should add your graphic to an array.
0 Kudos
AaronNash
Deactivated User
thanks for the information, I am still playing with the code. Have not been able to figure this out yet. Not sure if the datagroup is the best way to go. The results are being viewed in a mobile android app, that is why i am not using a datagrid
0 Kudos