Does a new graphic need all 4 parameters or not?

539
1
04-30-2013 09:33 AM
MikeOnzay
Occasional Contributor III
The documentation for a new graphic states "Creates a new Graphic object. All parameters are required and must be specified in the order given." http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/graphic.html#GraphicConst1

but under the concepts section on graphics there is this statement "Graphics are not required to have all of the above items, and no one item is required. " http://help.arcgis.com/en/webapi/javascript/arcgis/jshelp/inside_graphics.html

Is this a discrepancy in the documentation or is there a real difference that I'm not seeing?
0 Kudos
1 Reply
BenFousek
Occasional Contributor III
None are required.  Of course without geometry and a symbol the graphic will not show in the map.

Having said that, if you are creating graphics from a query, identify, etc, you should set attributes and info template.  Without them graphics don't have much functionality.

Graphics for display only, for example a polygon for selecting other features, do not need attributes or info template.

The measure widget example http://developers.arcgis.com/en/javascript/samples/widget_measurement/ illustrates this. Measure in the map, find the graphic's DOM object using firebug map._layers.map_graphics.graphics[0] and check for attributes map._layers.map_graphics.graphics[0].attributes and info template map._layers.map_graphics.graphics[0].infoTemplate. Both are undefined.
0 Kudos