Assigning attributes to graphics
The attributes of a graphic are the name/value pairs that describe that object. In many cases graphics are generated as the result of a task such as QueryTask
. In such cases the geometry and attributes are derived from the query results and you just need to symbolize each graphic accordingly. The data columns associated with the layer you are querying become the attributes for the graphic. You can limit the range of attribute data returned by the query by setting properties on the task, such as outFields
. If you are creating your graphics programmatically then you'll need to assign the attributes in your code using the Graphic.setAttributes()
method seen in the code example that follows:
Graphic.setAttributes( {"XCoord":evt.mapPoint.x, "YCoord".evt.mapPoint.y,"Plant":"Mesa Mint"});