Adding graphics to the GraphicsLayer
Before any of your graphics are displayed on the map you must add them to the GraphicsLayer
. Each map has a GraphicsLayer
which contains an array of graphics that is initially empty until you add the graphics:

The GraphicsLayer
can contain any type of graphic objects, so you can mix points, lines, and polygons in the same layer. Graphics are added to the layer through the add()
method and can also be removed individually through the remove()
method. In the event that you need to remove all graphics simultaneously the clear()
method can be used. GraphicsLayer
also has a number of events that can be listened to, including click
, mouse-down
, and others, to add more interactivity to your application.
Multiple GraphicsLayers
The API supports adding multiple graphics layers to the map, making it much easier to organize different types of graphics. Layers can easily be removed or added as needed. For example, you can put polygon graphics representing counties in...