Packagecom.esri.ags.layers
Classpublic class GraphicsLayer
InheritanceGraphicsLayer Inheritance Layer Inheritance mx.core.UIComponent

A layer that contains one or more Graphic features. The map can contains 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


Example
MXML to display two points on a map using the GraphicsLayer:
 <esri:Map>
     <esri:ArcGISTiledMapServiceLayer
         url="http://server.arcgisonline.com/ArcGIS/rest/services/NPS_Physical_World_2D/MapServer" />
     <esri:GraphicsLayer>
         <esri:Graphic>
             <esri:geometry>
                 <esri:MapPoint x="13" y="55.59" spatialReference="{new SpatialReference(4326)}"/>
             </esri:geometry>
         </esri:Graphic>
 </esri:Map>

See also

com.esri.ags.Graphic


Public Properties
 PropertyDefined by
  graphicProvider : Object
Set of graphics to be viewed.
GraphicsLayer
  initialExtent : Extent
The initial extent of the map layer.
GraphicsLayer
 InheritedisInScaleRange : Boolean
Returns true if the current scale of the map is between the maximum and minimum scale of the layer [added in version 1.3].
Layer
 Inheritedloaded : Boolean
When the layer is loaded, the value becomes "true" and layer properties can be accessed.
Layer
 Inheritedmap : Map
A reference to the Map this layer is in.
Layer
 InheritedmaxScale : Number = 0
The maximum scale of the layer [added in version 1.3].
Layer
 InheritedminScale : Number = 0
The minimum scale of the layer [added in version 1.3].
Layer
  numGraphics : int
[read-only] Get the number of graphics in that layer.
GraphicsLayer
  renderer : Renderer
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
  spatialReference : SpatialReference
The spatial reference of the map layer.
GraphicsLayer
  symbol : Symbol
The default symbol for the layer.
GraphicsLayer
  symbolFunction : Function
[Deprecated - please use Renderers] The symbol function 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
  units : String
The units of the layer.
GraphicsLayer
Public Methods
 MethodDefined by
  
Creates a new GraphicsLayer.
GraphicsLayer
  
add(graphic:Graphic):String
Adds a graphic.
GraphicsLayer
  
clear():void
Clears all graphics.
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
toScreenY(mapY:Number):Number
Converts the y-coordinate of map point to a screen point.
Layer
 Inherited
updateLayer():void
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
 EventSummaryDefined by
   Fires when a graphic is added to the GraphicsLayer.GraphicsLayer
   Fires when all graphics in the GraphicsLayer are cleared.GraphicsLayer
   Fires when a graphic is removed from the GraphicsLayer.GraphicsLayer
 Inherited Fires after layer properties for the layer are successfully populated.Layer
 Inherited Fires if the layer is unable to load.Layer
Property detail
graphicProviderproperty
graphicProvider:Object  [read-write]

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

initialExtentproperty 
initialExtent:Extent  [read-write]

The initial extent of the map layer. Used for the map if it's 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]

Get 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:Renderer  [read-write]

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():Renderer
    public function set renderer(value:Renderer):void

See also

spatialReferenceproperty 
spatialReference:SpatialReference  [read-write]

The spatial reference of the map layer.

Implementation
    public function get spatialReference():SpatialReference
    public function set spatialReference(value:SpatialReference):void
symbolproperty 
symbol:Symbol  [read-write]

The default symbol for the layer. This symbol will be used when graphic does not define one and a symbolFunction 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
symbolFunctionproperty 
symbolFunction:Function  [read-write]

[Deprecated - please use Renderers] The symbol function 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. Note: the renderers introduced in version 1.2 replaces the functionality of the symbolFunction. The function should have the following signature: public function mySymbolFunction(graphic:Graphic):Symbol

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

Implementation
    public function get symbolFunction():Function
    public function set symbolFunction(value:Function):void

See also

unitsproperty 
units:String  [read-write]

The units of the layer.

The default value is DECIMAL_DEGRESS.

Implementation
    public function get units():String
    public function set units(value:String):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

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
graphicAddevent 
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.

graphicClearevent  
Event object type: com.esri.ags.events.GraphicEvent
GraphicEvent.type property = com.esri.ags.events.GraphicEvent.GRAPHIC_CLEAR

Fires when all graphics in the GraphicsLayer are cleared.

Defines the value of the type property of a graphicClear event object.

graphicRemoveevent  
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.