Packagecom.esri.ags.layers
Classpublic class GraphicsLayer
InheritanceGraphicsLayer Inheritance Layer Inheritance mx.core.UIComponent
Implements ILegendSupport
Subclasses FeatureLayer

A layer that contains one or more Graphic features. The map can contain one or more graphics layers.

Note that GraphicsLayer, like all layers, extend UIComponent and thus include basic mouse events, for example: click, mouseOut, mouseOver, and mouseDown, as well as other events like show and hide, and general properties, such as alpha, mouseChildren, toolTip and visible.

Default MXML PropertygraphicProvider

View the examples

See also

com.esri.ags.Graphic
com.esri.ags.events.LayerEvent


Public Properties
 PropertyDefined By
 InheritedattributionVisible : Boolean
Indicates if this layer's attribution should be displayed.
Layer
  autoMoveGraphicsToTop : Boolean
If true, the Graphics will be moved to the top of the stack on mouseOver.
GraphicsLayer
  clusterer : IClusterer
The graphics clusterer.
GraphicsLayer
 Inheritedcopyright : String
The layer's copyright text.
Layer
  graphicProvider : Object
Set of graphics to be viewed.
GraphicsLayer
  infoWindowRenderer : IFactory
The info renderer.
GraphicsLayer
  initialExtent : Extent
[override] Initial extent of the layer.
GraphicsLayer
 InheritedisInScaleRange : Boolean
[read-only] Returns true if the current scale of the map is between the maximum and minimum scale of the layer.
Layer
 Inheritedloaded : Boolean
[read-only] When the layer is loaded, the value becomes "true" and layer properties can be accessed.
Layer
 InheritedloadFault : Fault
[read-only] A reference to the fault that is dispatched when the layer throws a loadError event.
Layer
 Inheritedmap : Map
[read-only] A reference to the Map this layer is in.
Layer
 InheritedmaxScale : Number
The maximum scale of the layer.
Layer
 InheritedminScale : Number
The minimum scale of the layer.
Layer
  numGraphics : int
[read-only] Gets the number of graphics in that layer.
GraphicsLayer
 InheritedrefreshInterval : Number
Refresh interval of the layer in minutes.
Layer
  renderer : IRenderer
The renderer allows for the symbol of the graphic to be dynamically picked - for example based on attributes or position of the graphic, or based on the scale of the map, or anything else.
GraphicsLayer
 InheritedshowInLegend : Boolean
Indicates if this layer should be displayed in the Legend component or PrintTask output.
Layer
  spatialReference : SpatialReference
[override] The spatial reference of the map layer.
GraphicsLayer
  symbol : Symbol
The default symbol for the layer.
GraphicsLayer
Protected Properties
 PropertyDefined By
 InheritedrotatedMapExtent : Extent
[read-only] Extent of the layer in the rotated map.
Layer
Public Methods
 MethodDefined By
  
Creates a new GraphicsLayer.
GraphicsLayer
  
add(graphic:Graphic):String
Adds a graphic.
GraphicsLayer
  
clear():void
Clears all graphics.
GraphicsLayer
  
getLegendInfos(responder:IResponder = null):AsyncToken
Gets legend infos.
GraphicsLayer
  
moveToTop(graphic:Graphic):void
Moves a specific graphic to the top of the stack.
GraphicsLayer
 Inherited
refresh():void
Causes the layer to redraw or reload its content.
Layer
  
remove(graphic:Graphic):void
Removes the specific graphic.
GraphicsLayer
Protected Methods
 MethodDefined By
 Inherited
Adds listeners for ExtentEvent.EXTENT_CHANGE, ZoomEvent.ZOOM_START, ZoomEvent.ZOOM_UPDATE and ZoomEvent.ZOOM_END.
Layer
 Inherited
When an EXTENT_CHANGE event occurs, this calls invalidateLayer();
Layer
 Inherited
hideHandler(event:FlexEvent):void
When the layer is hidden (visible is set to false), this calls removeMapListeners().
Layer
 Inherited
Subclasses should call this whenever they would like to have updateLayer() called on them.
Layer
 Inherited
Removes all the layers children.
Layer
 Inherited
Removes the four event listeners added by addMapListeners();
Layer
 Inherited
setLoaded(value:Boolean):void
Subclasses must call this when they've loaded all their properties and are ready to load their content.
Layer
 Inherited
showHandler(event:FlexEvent):void
When the layer is shown (visible is set to true), this calls addMapListeners() and invalidateLayer().
Layer
 Inherited
toScreenX(mapX:Number):Number
Converts the x-coordinate of map point to a screen point.
Layer
 Inherited
toScreenXY(mapX:Number, mapY:Number):Point
Converts map coordinates to screen coordinates.
Layer
 Inherited
toScreenY(mapY:Number):Number
Converts the y-coordinate of map point to a screen point.
Layer
 Inherited
Subclasses must override this method.
Layer
 Inherited
Finishes the zoom animation.
Layer
 Inherited
Prepares the zoom animation by taking a bitmap of the layer.
Layer
 Inherited
Redraws the bitmap of the layer.
Layer
Events
 Event Summary Defined By
  Fires when a graphic is added to the GraphicsLayer.GraphicsLayer
  Fires when a graphic is removed from the GraphicsLayer.GraphicsLayer
  Fires when all graphics in the GraphicsLayer are cleared.GraphicsLayer
 InheritedFires if the value of isInScaleRange changes.Layer
 InheritedFires after layer properties for the layer are successfully populated.Layer
 InheritedFires if the layer is unable to load.Layer
 InheritedFires when the layer has finished updating its content.Layer
 InheritedFires when the layer begins to update its content.Layer
Property Detail
autoMoveGraphicsToTopproperty
autoMoveGraphicsToTop:Boolean

If true, the Graphics will be moved to the top of the stack on mouseOver.

The default value is false.


Implementation
    public function get autoMoveGraphicsToTop():Boolean
    public function set autoMoveGraphicsToTop(value:Boolean):void

See also

clustererproperty 
clusterer:IClusterer

The graphics clusterer.

This property can be used as the source for data binding.


Implementation
    public function get clusterer():IClusterer
    public function set clusterer(value:IClusterer):void
graphicProviderproperty 
graphicProvider:Object

Set of graphics to be viewed. This property lets you use either an Array, an ArrayCollection, or a single Graphic as graphic providers. If you set the graphicProvider property to an Array, it will be converted to an ArrayCollection. If you set the property to an ArrayCollection, it will be used directly. If you set the property to a single Graphic, it will be wrapped in a new ArrayCollection.

As a consequence of the conversions, when you get the graphicProvider property, it will always be an ArrayCollection.

The default value is an empty ArrayCollection.

This property can be used as the source for data binding.


Implementation
    public function get graphicProvider():Object
    public function set graphicProvider(value:Object):void

See also

infoWindowRendererproperty 
infoWindowRenderer:IFactory

The info renderer.


Implementation
    public function get infoWindowRenderer():IFactory
    public function set infoWindowRenderer(value:IFactory):void

See also

initialExtentproperty 
initialExtent:Extent[override]

Initial extent of the layer. Used by the map if it is the first layer in the map and map doesn't have an extent specified.

The default value is new Extent(-180, -90, 180, 90, new SpatialReference(4326)).


Implementation
    public function get initialExtent():Extent
    public function set initialExtent(value:Extent):void
numGraphicsproperty 
numGraphics:int  [read-only]

Gets the number of graphics in that layer.

This property can be used as the source for data binding.


Implementation
    public function get numGraphics():int
rendererproperty 
renderer:IRenderer

The renderer allows for the symbol of the graphic to be dynamically picked - for example based on attributes or position of the graphic, or based on the scale of the map, or anything else. This will be used when graphic does not have its own symbol.

This property can be used as the source for data binding.


Implementation
    public function get renderer():IRenderer
    public function set renderer(value:IRenderer):void

See also

spatialReferenceproperty 
spatialReference:SpatialReference[override]

The spatial reference of the map layer.

The default value is new SpatialReference(4326).


Implementation
    public function get spatialReference():SpatialReference
    public function set spatialReference(value:SpatialReference):void
symbolproperty 
symbol:Symbol

The default symbol for the layer. This symbol will be used when graphic does not define one and a renderer is not defined. Any individual graphic with a symbol assigned, will use that symbol instead of anything specified on its layer.

This property can be used as the source for data binding.


Implementation
    public function get symbol():Symbol
    public function set symbol(value:Symbol):void
Constructor Detail
GraphicsLayer()Constructor
public function GraphicsLayer()

Creates a new GraphicsLayer.

Method Detail
add()method
public function add(graphic:Graphic):String

Adds a graphic. If an ID was not defined, a unique name will be created and assigned to the graphic. The unique name is created using NameUtil.createUniqueName, which will combine the unqualified class name with an incrementing counter to create something like "Graphic67".

Parameters

graphic:Graphic — The graphic to add.

Returns
String — The graphic id.

See also

clear()method 
public function clear():void

Clears all graphics.

See also

getLegendInfos()method 
public function getLegendInfos(responder:IResponder = null):AsyncToken

Gets legend infos.

Parameters

responder:IResponder (default = null) — The responder to call on result or fault. The result function will be given an array of LayerLegendInfo instances.

Returns
AsyncToken

See also

moveToTop()method 
public function moveToTop(graphic:Graphic):void

Moves a specific graphic to the top of the stack.

Parameters

graphic:Graphic — The graphic to move.

remove()method 
public function remove(graphic:Graphic):void

Removes the specific graphic.

Parameters

graphic:Graphic — The graphic to remove.

See also

Event Detail
graphicAdd Event
Event Object Type: com.esri.ags.events.GraphicEvent
GraphicEvent.type property = com.esri.ags.events.GraphicEvent.GRAPHIC_ADD

Fires when a graphic is added to the GraphicsLayer.

Defines the value of the type property of a graphicAdd event object.
graphicRemove Event  
Event Object Type: com.esri.ags.events.GraphicEvent
GraphicEvent.type property = com.esri.ags.events.GraphicEvent.GRAPHIC_REMOVE

Fires when a graphic is removed from the GraphicsLayer.

Defines the value of the type property of a graphicRemove event object.
graphicsClear Event  
Event Object Type: com.esri.ags.events.GraphicsLayerEvent
GraphicsLayerEvent.type property = com.esri.ags.events.GraphicsLayerEvent.GRAPHICS_CLEAR

Fires when all graphics in the GraphicsLayer are cleared.

Defines the value of the type property of a graphicsClear event object.
Examples
MXML to display a point on a map using the GraphicsLayer:
 <esri:Map>
     <esri:ArcGISTiledMapServiceLayer
         url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer" />
     <esri:GraphicsLayer>
         <esri:Graphic>
             <esri:geometry>
                 <esri:MapPoint x="1447000" y="7477000" spatialReference="{new SpatialReference(102100)}"/>
             </esri:geometry>
         </esri:Graphic>
 </esri:Map>