Class: GraphicsLayerE-mail This Topic Printable Version Give Us Feedback

Description

A layer that contains one or more Graphic features. Each map contains a GraphicsLayer by default, accessible using the Map.Graphics property. Beginning with v1.4, you can create your own graphics layers and add them to the map. Graphics layers can be reordered within the group of graphics layers. However, the graphics layer in Map.Graphics is always on top. Also, all graphics layers are always on top of TiledMapServiceLayers and DynamicMapServiceLayers.

Class hierarchy

esri.layers.Layer
  |_ esri.layers.GraphicsLayer

Constructor

Constructor Description
esri.layers.GraphicsLayer() Creates a new GraphicsLayer object.
esri.layers.GraphicsLayer(options?) Creates a new GraphicsLayer object with parameters.

Properties

Property Type Description
graphics Graphic[] The array of graphics that make up the layer.
renderer Renderer Renderer assigned to the GraphicsLayer.

Methods

Method Return Value Description
add(graphic) Graphic Adds a graphic.
clear() none Clears all graphics.
disableMouseEvents() none Disables all mouse events on the graphics layer.
enableMouseEvents() none Enables all mouse events on the graphics layer.
remove(graphic) Graphic Removes a graphic.
setRenderer(renderer) none Sets the renderer for the graphics layer.

Events

Event Description
onClick(event) Fires when a graphic has been clicked.
onGraphicAdd(graphic) Fires when a graphic is added to the GraphicsLayer.
onGraphicRemove(graphic) Fires when a graphic is removed from the GraphicsLayer.
onGraphicsClear() Fires when all graphics in the GraphicsLayer are cleared.
onMouseDown(event) Fires when a mouse button is pressed down and the mouse cursor is on a graphic.
onMouseDrag(event) Fires while the mouse is being dragged until the mouse button is released.
onMouseMove(event) Fires as the mouse moves through a graphic on the GraphicsLayer.
onMouseOut(event) Fires as the mouse exits a graphic on the GraphicsLayer.
onMouseOver(event) Fires when the mouse first enters into a graphic on the GraphicsLayer.
onMouseUp(event) Fires when a mouse button is released and the mouse cursor is on a graphic.
Constructor Detail

esri.layers.GraphicsLayer()

Creates a new GraphicsLayer object. (As of v1.4)

esri.layers.GraphicsLayer(options?)

Creates a new GraphicsLayer object with parameters. (As of v1.4)
Parameters:
<Object> options Optional See options list for parameters.
Options:
<Boolean> displayOnPan When true, graphics are displayed during panning. When false, the graphics are turned off during pan movement. Setting to false may improve performance in Internet Explorer. The default is true.
<String> id Id to assign to the layer. If not assigned, esri.Map assigns value.
<Boolean> visible Initial visibility of the layer. Default is true.
Properties Detail

<Graphic[]> graphics

The array of graphics that make up the layer.

<Renderer> renderer

Renderer assigned to the GraphicsLayer. (As of v1.4)
Methods Detail

add(graphic)

Adds a graphic.
Return value: Graphic
Input Parameters:
<Graphic> graphic Required The graphic to add.
See also:
onGraphicAdd  

clear()

Clears all graphics.
Return value: none
See also:
onGraphicsClear  

disableMouseEvents()

Disables all mouse events on the graphics layer.
Return value: none

enableMouseEvents()

Enables all mouse events on the graphics layer.
Return value: none

remove(graphic)

Removes a graphic.
Return value: Graphic
Input Parameters:
<Graphic> graphic Required The graphic to remove.
See also:
onGraphicRemove  

setRenderer(renderer)

Sets the renderer for the graphics layer.
Return value: none
Input Parameters:
<Renderer> renderer Required The renderer used for the graphic.

Events Detail

onClick(event)

Fires when a graphic has been clicked.
Arguments:
<Object> event The returned object contains screenPoint, mapPoint, and Graphic.

onGraphicAdd(graphic)

Fires when a graphic is added to the GraphicsLayer.
Arguments:
<Graphic> graphic The added graphic.
See also:
add  

onGraphicRemove(graphic)

Fires when a graphic is removed from the GraphicsLayer.
Arguments:
<Graphic> graphic The removed graphic.
See also:
remove  

onGraphicsClear()

Fires when all graphics in the GraphicsLayer are cleared.
See also:
clear  

onMouseDown(event)

Fires when a mouse button is pressed down and the mouse cursor is on a graphic.
Arguments:
<Object> event The returned object contains screenPoint, mapPoint, and Graphic.

onMouseDrag(event)

Fires while the mouse is being dragged until the mouse button is released.
Arguments:
<Object> event The result can be any JavaScript MouseEvent, or the x and y coordinates of screenPoint or mapPoint.

onMouseMove(event)

Fires as the mouse moves through a graphic on the GraphicsLayer.
Arguments:
<Object> event The returned object contains screenPoint, mapPoint, and Graphic.

onMouseOut(event)

Fires as the mouse exits a graphic on the GraphicsLayer.
Arguments:
<Object> event The returned object contains screenPoint, mapPoint, and Graphic.

onMouseOver(event)

Fires when the mouse first enters into a graphic on the GraphicsLayer.
Arguments:
<Object> event The returned object contains screenPoint, mapPoint, and Graphic.

onMouseUp(event)

Fires when a mouse button is released and the mouse cursor is on a graphic.
Arguments:
<Object> event The returned object contains screenPoint, mapPoint, and Graphic.