Search code examples
javascriptarcgis

How to get graphic attribute keys?


GLayer = new esri.layers.GraphicsLayer();
var graphic = new esri.Graphic(point, symbol);
name = "test";                  
graphic.setAttributes({"name" : name});
GLayer.add(graphic);

I created a graphic layer. Graphics are added to the graphics layer. The graphic consists of points and symbols. I created an attribute in the graphic. How do you get the key of all the attributes of the graphic? or Is it possible to know the presence or absence of a specific key in the attribute of graphic?


Solution

  • Read the documentation before posting please. It's graphic.attributes.

    Instead of reading the docs you could also have used console.log(graphic) to dump the object to the console where you could have found that it has an attributes parameter, or you could have used debugging tools to set a breakpoints on one of the lines and inspected the graphic object to view all its keys. Please try to do your own research and investigation first.