Select to view content in your preferred language

Trying to access graphic.attributes

714
1
07-29-2011 10:04 AM
Vinay_KumarVasa
Deactivated User
What am I doing wrong here. I am just playing with a sample, trying to extend it...

txtNeighborhood.text = String(myGraphicsLayer.numGraphics);
   
    for(var i:int=0; i<myGraphicsLayer.numGraphics; i++){
     var mygraphic:Graphic = myGraphicsLayer.graphicProvider;
     txtNeighborhood.text =   txtNeighborhood.text + "," + mygraphic.attributes["OBJECTID"];

This line does not return the value of the attribute for the graphic.

Attached is the sample that I am using.
Tags (2)
0 Kudos
1 Reply
BenFerguson
Occasional Contributor
I looked over the code.  I think the problem you are having is that the feature gets added to the same graphics layer as the drawn graphic, so you will have a mix of drawn graphics and feature graphics.  Your examining the drawn graphic, which has no attributes.

I would create a separate graphics layer, like
<esri:GraphicsLayer id="myParcelGraphicsLayer"/> in the map and then reference it at:

function onResult(featureSet:FeatureSet, token:Object = null):void
{
     if (featureSet.features.length > 0)
     {
for each (var myGraphic:Graphic in featureSet.features)
{
  myParcelGraphicsLayer.add(myGraphic);

and in your AssignNeighborhood section.

It should work then.
0 Kudos