Select to view content in your preferred language

Get to attributes from featureSet

2068
2
10-14-2012 09:48 PM
daewoongkim
Emerging Contributor
I referred sample source in ArcGIS Resources Forums how to get attributes from GraphicsLayer.

I'm testing in now, reference source is ....

var drawArea:GraphicsLayer = _map.getLayer("drawGraphicLayer") as GraphicsLayer;
var featureSet3:FeatureSet = new FeatureSet(ArrayCollection(drawArea.graphicProvider).toArray());
//and check name & value in FeatureSet
for (var attributeName:Object in featureSet3.attributes)
{
   trace("attribute name: " + attributeName + " : " + featureSet3.attributes[attributeName]);
}

////////// output Example ////////////////
attribute name: 0 : [object Object]
attribute name: 1 : [object Object]

the values of attribute are printed "[object Object]"
I guess first obj is ArrayCollection, and second obj is Array.
I already did cast obj and plus .toString()  ->   featureSet3.attributes[attributeName].toString()
but this problem not resolved.
What is problem?
Tags (2)
0 Kudos
2 Replies
IvanBespalov
Frequent Contributor
private function getFeatureSet():FeatureSet
{
    var gp:ArrayCollection = myLayer.graphicProvider as ArrayCollection;
    if (!gp)
    {
 return null;
    }
    var featureSet:FeatureSet = new FeatureSet(gp.toArray());
    var counter:int;
    // for each feature in collection
    for each (var feature:Object in featureSet.attributes)
    {
 counter++;
 trace("> " + counter);
 // for each attribute in feature
 for (var attributeName:Object in feature)
 {
                var attributeValue:Object = feature[attributeName];
  trace(">>> " + attributeName + " : " + attributeValue);
 }
    }

    return featureSet;
}

/* output */
/*
> 1
>>> UNITS10_49 : 10898
>>> STATE_FIPS : 02
>>> AMERI_ES : 14569
>>> UNITS3_9 : 18983
>>> WIDOWED : 4428
>>> STATE_CITY : 0203000
>>> ASIAN_PI : 10910
>>> STATE_NAME : Alaska
>>> DIVORCED : 20631
>>> AGE_5_17 : 45189
>>> RENTER_OCC : 39030
>>> AGE_18_64 : 151392
>>> HSEHLD_1_M : 10673
>>> AGE_65_UP : 8258
>>> TYPE : city
...*/


Good luck
0 Kudos
daewoongkim
Emerging Contributor
Thank you for your comment Ivan. 😄

The answer of this problem is double "for statement."
0 Kudos