Select to view content in your preferred language

remove only InfoSymbol and red x mark

689
1
03-16-2011 04:32 PM
MikeJun
Emerging Contributor
I downloaded identify features and zoom to query result sample code and put it together.
Sample code simply gets rid of all graphics however I'd like to remove only infosymbol and red mark that pops out after clicking identify tool.


   private function mapClickHandler(event:MapMouseEvent):void
   {
    //clickGraphicsLayer.clear();
    //var clickGraphic:Graphic = new Graphic(clickGraphic.symbol);
    clickGraphicsLayer.remove(clickGraphic); I put this but won't work.

please help



<?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="Identify Features on the Map" xmlns:utils="com.esri.ags.utils.*">

<fx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.events.MapMouseEvent;
   import com.esri.ags.geometry.Geometry;
   import com.esri.ags.symbols.InfoSymbol;
   import com.esri.ags.tasks.supportClasses.IdentifyParameters;
   import com.esri.ags.tasks.supportClasses.IdentifyResult;
  
   import mx.controls.Alert;
   import mx.rpc.AsyncResponder;
  
   [Bindable]private var lastIdentifyResultGraphic:Graphic;
  
   private function mapClickHandler(event:MapMouseEvent):void
   {
    //clickGraphicsLayer.clear();
    //var clickGraphic:Graphic = new Graphic(clickGraphic.symbol);
    clickGraphicsLayer.remove(clickGraphic);
   
   
    var identifyParams:IdentifyParameters = new IdentifyParameters();
    identifyParams.returnGeometry = true;
    identifyParams.tolerance = 3;
    identifyParams.width = myMap.width;
    identifyParams.height = myMap.height;
    identifyParams.geometry = event.mapPoint;
    identifyParams.mapExtent = myMap.extent;
    identifyParams.spatialReference = myMap.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 com.esri.ags.symbol.InfoSymbol;
     //clickGraphic.symbol = new com.esri.ags.symbols.InfoSymbol();
    
     clickGraphic.symbol = new InfoSymbol(); // use default renderer
     clickGraphic.attributes = resultGraphic.attributes;
    }
   }
  
   private function myFaultFunction(error:Object, clickGraphic:Graphic = null):void
   {
    Alert.show(String(error), "Identify Error");
   }
  ]]>
</fx:Script>

<fx:Declarations>
  <!-- Symbol for where the user clicked -->
  <esri:SimpleMarkerSymbol id="clickPtSym"
         color="0xFF0000"
         size="12"
         style="x"/>
 
  <!-- Symbol for Identify Result as Polyline -->
  <esri:SimpleLineSymbol id="slsIdentify"
          width="2"
          alpha="1"
          color="0x00FF00"
          style="solid"/>
 
  <!-- Symbol for Identify Result as Point -->
  <esri:SimpleMarkerSymbol id="smsIdentify"
         color="0x00FF00"
         size="15"
         style="diamond"/>
 
  <!-- Symbol for Identify Result as Polygon -->
  <esri:SimpleFillSymbol id="sfsIdentify"/>
 
  <!-- Identify Task -->
  <esri:IdentifyTask id="identifyTask"
         concurrency="last"
         url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map..."/>
</fx:Declarations>

<esri:Map id="myMap"
     mapClick="mapClickHandler(event)"
     openHandCursorVisible="false">
  <esri:extent>
  
   <esri:WebMercatorExtent minlon="-120" minlat="30" maxlon="-100" maxlat="50"/>
  
  
  </esri:extent>
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
  <esri:GraphicsLayer graphicProvider="{lastIdentifyResultGraphic}"/>
  <esri:GraphicsLayer id="clickGraphicsLayer"/>
</esri:Map>

</s:Application>
Tags (2)
0 Kudos
1 Reply
AlexJones
Emerging Contributor
I am not sure if I understand the question, but in that example your graphics layer is bound to the lastIdentifyResultGraphic

<esri:GraphicsLayer graphicProvider="{lastIdentifyResultGraphic}"/>


If you want to keep the graphic and add to it just rename the Graphics layer and add the lastResultGraphic to it.

<esri:GraphicsLayer id="resultGraphicsLayer"/>


Inside the myResultFunction:

lastIdentifyResultGraphic = resultGraphic;
resultGraphicsLayer.add(lastIdentifyResultGraphic);


Please let me know if you have any questions.
0 Kudos