Select to view content in your preferred language

Features From Feature Layer

4329
7
02-01-2011 08:34 AM
sreeharikottoormadam
Occasional Contributor
How to get the features from the feature layer and add as a graphic layer?

I have a featurelayer . While loading the map, all the points in that feature layer should add as a graphic layer with attribute information.



Thanks!
Tags (2)
0 Kudos
7 Replies
DasaPaddock
Esri Regular Contributor
0 Kudos
sreeharikottoormadam
Occasional Contributor
protected function jnjMap_loadHandler(event:MapEvent):void
   {
 
      
    //Add feature layer to the map
    var fLayer:FeatureLayer=new FeatureLaye("http://sampleserve1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapS...");
      
  
    jnjMap.addLayer(fLayer);
   
      
   }



This is working for me. but i need to add this layer as a grahic layer with attribute value(any one or two fields of the feature layer).
0 Kudos
sreeharikottoormadam
Occasional Contributor
By this code I can add graphics from a feature layer and render with my own symbols. is it the correct method (limited query feature(max. 500) and performance)?

Actually I need to get the attribute value from the feature insted of taking the value from the graphic.





protected function XYZMap_loadHandler():void
   {
    // TODO Auto-generated method stub
    this.cursorManager.setBusyCursor();
    //clear    
    myGraphicsLayer.clear();
   
    //load graphic
    var uniqueID:String;
          var queryTask:QueryTask = new QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map...");
    queryTask.useAMF = false;
    var query:Query = new Query();
    query.where ="1=1"
    query.outSpatialReference = jnjMap.spatialReference;
    query.returnGeometry = true;
    query.outFields = [ "STATE_NAME" ];
    queryTask.execute(query, new AsyncResponder(onResult, onFault));
    
                 
    function onResult(featureSet:FeatureSet, token:Object = null):void
    {
     for each (var myGraphic:Graphic in featureSet.features)
     {
      uniqueID=myGraphic.attributes.STATE_NAME;  //Get State name to a variable
      myGraphic.toolTip=myGraphic.attributes.CITY_NAME;
      if (uniqueID=="Washington"){
       myGraphic.symbol = mySymbol;
      }
      else {
      myGraphic.symbol = defaultSymbol;
      }
           
      myGraphicsLayer.add(myGraphic);
     
     }
    }
    function onFault(info:Object, token:Object = null):void
    {
     Alert.show(info.toString());
    }
            
    this.cursorManager.removeBusyCursor();
   }




plz help me.......   is there is any alternate method to do this?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sreehari,

   You really need to read the documentation on FeatureLayer... A featurelayer inherits from graphicslayer. It basically is a enhanced graphics layer that DOES have attributes because it does a querytask internally. You should be able to do every thing you are after just using the featurelayer.

http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/layers/FeatureLayer.html
0 Kudos
sreeharikottoormadam
Occasional Contributor
can u plz share any code for doing the same....


I am new to flex...
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Sreehari,

   We all started as new to flex. That is why there are samples on the Flex API page.

http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=FeatureLayer_MouseOver_Snapshot
0 Kudos
sreeharikottoormadam
Occasional Contributor
Dear Robert Scheitlin,

                                   I have gone through the samples. Actually my requiremnt is bit different. I need to add afeature layer as graphic by looping each feature and  add an attribute(eg Uniq Id) to it. based on  that attribute value (uniqid), need to access values from sql server and render it.


thank you.....
0 Kudos