Select to view content in your preferred language

Identify multiple layers and show results in a viewstack

592
0
10-10-2011 11:25 AM
TamiaRudnicky
Occasional Contributor
Hi,

   I have modified the identify code to give me results for multiple data layers and show them in a viewstack within the info window. My problem is that I can't figure out how to clear the previous text values when a new identify is performed. For example: the first identify is on an overlapping point and line so I have results for the line in one viewstack content and results for the point in another viewstack content. The second identify is only on a line - I get new results for the line but the previous point result is retained. I have tried setting the infoTextArea.htmlText to a blank value or a set text within the mapClickHandler function but my infowindow doesn't open. I've tried setting it within the the myResultFunction and had luck when the first infoTextArea.htmlText was set but when more than one was set, the infowindow did not open.

  Does anyone have any suggestions?

  Here is part of my code (I have commented out my attempts at resetting my infoTextArea.htmlText):

private function mapClickHandler(event:MapMouseEvent):void
{
clickGraphicsLayer.clear();

var identifyParams:IdentifyParameters = new IdentifyParameters();
identifyParams.returnGeometry = true;
identifyParams.tolerance = 5;
identifyParams.width = mapOne.width;
identifyParams.height = mapOne.height;
identifyParams.geometry = event.mapPoint;
identifyParams.mapExtent = mapOne.extent;
identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_ALL;
identifyParams.spatialReference = mapOne.spatialReference;

var clickGraphic:Graphic = new Graphic(event.mapPoint, clickPtSym);
clickGraphicsLayer.add(clickGraphic);

//infoTextArea2.htmlText = "No data";
//infoTextArea3.htmlText = "No data";
//infoTextArea13.htmlText = "No data";
//infoTextArea17.htmlText = "No data";

identifyTask.execute(identifyParams, new AsyncResponder(myResultFunction, myFaultFunction, clickGraphic));
}

private function myResultFunction(results:Array, clickGraphic:Graphic = null):void
{
if (results && results.length > 0)
{
  var resultsArray0:Array = [];
  var resultsArray1:Array = [];
  var resultsArray2:Array = [];
  var resultsArray3:Array = [];
 
  //var emptyLabel2:String;
  //var emptyLabel3:String;
  //var emptyLabel13:String;
  //var emptyLabel17:String;
  //infoTextArea2.htmlText = emptyLabel2;
  //infoTextArea3.htmlText = emptyLabel3;
  //infoTextArea13.htmlText = emptyLabel13;
  //infoTextArea17.htmlText = emptyLabel17;
 
  for (var i:int = 0; i < results.length; i++)
  {
   var result:IdentifyResult = results;
   var resultGraphic:Graphic = result.feature;
   var mapPoint:MapPoint = MapPoint(clickGraphic.geometry);
   var point:Point = mapOne.toScreen(mapPoint); 
   var label:String;
   var re:int = result.layerId;

   switch (result.layerId)
   {
    case 0:
    {
    resultsArray0.push(result.feature.attributes);
    Alert.show("permit");
    infoTextArea2.htmlText = "<b>Permit Number:   </b>" + resultGraphic.attributes.PERMIT_NO;
    resultGraphic.symbol = smsIdentify;
    break;
    }
    case 1:
    {
    resultsArray1.push(result.feature.attributes);
    Alert.show("astru");
    infoTextArea3.htmlText = "<b>Access Structure:   </b>" + resultGraphic.attributes.PNTSTRUC +
    "\n<b>Field Survey Date:   </b>" + resultGraphic.attributes.GPS_Date;
    resultGraphic.symbol = smsIdentify;
    break;
    }
    case 2:
    {
    resultsArray2.push(result.feature.attributes);
    Alert.show("lubc");
    infoTextArea13.htmlText = "<b>Field Survey Date:   </b>" + resultGraphic.attributes.gps_date;
     infoTextArea13.height = 150;
     resultGraphic.symbol = slsIdentify;
     break;
    }
    case 3:
    {
    resultsArray3.push(result.feature.attributes);
    Alert.show("smm");
    infoTextArea17.htmlText = "<b>Undefended Shoreline Recommendation:   </b>" + resultGraphic.attributes.treatment;
    infoTextArea17.height = 150;
    resultGraphic.symbol = slsIdentify;
    break;
    }
   
   }
   lastIdentifyResultGraphic = resultGraphic;
  
   mapOne.infoWindow.label = "Identify Results";
   mapOne.infoWindow.show(mapOne.toMap(point));
  }
}
else
{
  Alert.show("Please click on the shoreline to identify shoreline attributes.");
};
}
///Code break /////

<esri:Map id="mapOne" width="100%" height="100%"
    mapClick="mapClickHandler(event)">
<esri:infoWindowContent>
  <s:VGroup>
   <s:BorderContainer backgroundColor="white" borderColor="#5478E4"
          cornerRadius="5" width="200"
          minHeight="0" minWidth="0" >
    <s:VGroup width="100%" paddingLeft="10" paddingRight="10" paddingBottom="10" paddingTop="10" >
     <s:BorderContainer width="100%" borderColor="#FFFFFF" >
     <s:TileGroup top="10" left="10" horizontalGap="3" verticalGap="3" requestedRowCount="3">
     <s:Button id="permButton" label="Permits" click="myViewStack.selectedChild=permInfo;" visible="{permit.selected}" includeInLayout="{permit.selected}"/>
     <s:Button id="pntButton" label="Access" click="myViewStack.selectedChild=pntInfo;" toolTip="Shoreline Access Structures" visible="{pntStru.selected}" includeInLayout="{pntStru.selected}"/>
     <s:Button id="luButton" label="Land Use" click="myViewStack.selectedChild=luInfo;" toolTip="Riparian Land Use" visible="{ripLU.selected}" includeInLayout="{ripLU.selected}"/>
     <s:Button id="smmButton" label="SMM" click="myViewStack.selectedChild=smmInfo;" toolTip="Shoreline Management Model" visible="{smm.selected}" includeInLayout="{smm.selected}"/>
     </s:TileGroup>
     </s:BorderContainer>
    </s:VGroup>
   </s:BorderContainer>
  
   <mx:ViewStack id="myViewStack" borderStyle="solid" width="100%"
        resizeToContent="true" color="0x323232" >
   
    <s:NavigatorContent id="permInfo" backgroundColor="0xDCDCDC" width="100%" height="100%" >
     <s:VGroup >
     <s:Label text="Permit Information" fontWeight="bold"/>
     <mx:TextArea id="infoTextArea2" editable="false"
       width="100%" paddingLeft="5" paddingTop="5" />
     </s:VGroup>
    </s:NavigatorContent>
   
    <s:NavigatorContent id="pntInfo" backgroundColor="0xDCDCDC" width="100%" height="100%">
     <s:VGroup>
     <s:Label text="Shoreline Access Structure"/>
     <mx:TextArea id="infoTextArea3" editable="false"
       width="100%" paddingLeft="5" paddingTop="5" />
     </s:VGroup>
    </s:NavigatorContent>
   
    <s:NavigatorContent id="luInfo" backgroundColor="0xDCDCDC" width="100%" height="100%">
     <s:VGroup>
     <s:Label text="Riparian Land Use" fontWeight="bold"/>
     <mx:TextArea id="infoTextArea13" editable="false"
       width="100%" paddingLeft="5" paddingTop="5" />
     </s:VGroup>
    </s:NavigatorContent>
   
    <s:NavigatorContent id="smmInfo" backgroundColor="0xDCDCDC" width="100%" height="100%" >
     <s:VGroup >
     <s:Label text="Shoreline Management Recommendations"/>
     <mx:TextArea id="infoTextArea17" editable="false"
       width="100%" paddingLeft="5" paddingTop="5" />
     </s:VGroup>
    </s:NavigatorContent>
   </mx:ViewStack>
  </s:VGroup>
</esri:infoWindowContent>


Any help will be greatly appreciated!

Thanks,
Tami
Tags (2)
0 Kudos
0 Replies