This page describes an older version, please read about the latest version at:
https://developers.arcgis.com/en/flex/api-reference/
Packagecom.esri.ags.layers
Classpublic class Layer
InheritanceLayer Inheritance mx.core.UIComponent
SubclassesDynamicMapServiceLayer, GraphicsLayer, TiledMapServiceLayer

Base class for all layers that can be added to a map.

Use ArcGISTiledMapServiceLayer for cached data, ArcGISDynamicMapServiceLayer for non-cached data, ArcIMSMapServiceLayer for ArcIMS services, ArcGISImageServiceLayer for ArcGIS Image Services, VETiledLayer for Bing Maps (formerly Microsoft Virtual Earth) mapping and GraphicsLayer to display additional features on the map. You can also extend Layer (or, preferably, DynamicMapServiceLayer or TiledMapServiceLayer) to add support for additional map types.

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

See also

com.esri.ags.events.LayerEvent


Public Properties
 PropertyDefined by
  initialExtent : Extent
[read-only] The initial extent of the layer.
Layer
  isInScaleRange : Boolean
[read-only] 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
  loaded : Boolean
[read-only] When the layer is loaded, the value becomes "true" and layer properties can be accessed.
Layer
  map : Map
[read-only] A reference to the Map this layer is in.
Layer
  maxScale : Number = 0
The maximum scale of the layer [added in version 1.3].
Layer
  minScale : Number = 0
The minimum scale of the layer [added in version 1.3].
Layer
  spatialReference : SpatialReference
[read-only] The spatial reference of the layer.
Layer
  units : String
[read-only] The units of the layer.
Layer
Public Methods
 MethodDefined by
  
Creates a new Layer object.
Layer
  
refresh():void
Causes the layer to redraw or reload its content.
Layer
Protected Methods
 MethodDefined by
  
Adds listeners for ExtentEvent.EXTENT_CHANGE, ZoomEvent.ZOOM_START, ZoomEvent.ZOOM_UPDATE and ZoomEvent.ZOOM_END.
Layer
  
When an EXTENT_CHANGE event occurs, this calls invalidateLayer();
Layer
  
hideHandler(event:FlexEvent):void
When the layer is hidden (visible is set to false), this calls removeMapListeners().
Layer
  
Subclasses should call this whenever they would like to have updateLayer() called on them.
Layer
  
Removes all the layers children.
Layer
  
Removes the four event listeners added by addMapListeners();
Layer
  
setLoaded(value:Boolean):void
Subclasses must call this when they've loaded all their properties and are ready to load their content.
Layer
  
showHandler(event:FlexEvent):void
When the layer is shown (visible is set to true), this calls addMapListeners() and invalidateLayer().
Layer
  
toScreenX(mapX:Number):Number
Converts the x-coordinate of map point to a screen point.
Layer
  
toScreenY(mapY:Number):Number
Converts the y-coordinate of map point to a screen point.
Layer
  
updateLayer():void
Subclasses must override this method.
Layer
  
Finishes the zoom animation.
Layer
  
Prepares the zoom animation by taking a bitmap of the layer.
Layer
  
Redraws the bitmap of the layer.
Layer
Events
 EventSummaryDefined by
   Fires after layer properties for the layer are successfully populated.Layer
   Fires if the layer is unable to load.Layer
Property detail
initialExtentproperty
initialExtent:Extent  [read-only]

The initial extent of the layer. Used for the map if it's the first layer in the map and map doesn't have an extent specified. Subclasses should override this method as a best practice in case a subclassed layer is added to a map which doesn't have an extent.

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

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

Implementation
    public function get initialExtent():Extent
isInScaleRangeproperty 
isInScaleRange:Boolean  [read-only]

Returns true if the current scale of the map is between the maximum and minimum scale of the layer [added in version 1.3]. The comparison used maxScale <= map.scale <= minScale. The map scale is rounded up when compared to maxScale and rounded down when compared to minScale.

Implementation
    public function get isInScaleRange():Boolean
loadedproperty 
loaded:Boolean  [read-only]

When the layer is loaded, the value becomes "true" and layer properties can be accessed. The load event is also fired. Subclasses must call setLoaded() to change this property.

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

Implementation
    public function get loaded():Boolean
mapproperty 
map:Map  [read-only]

A reference to the Map this layer is in.

Implementation
    public function get map():Map
maxScaleproperty 
public var maxScale:Number = 0

The maximum scale of the layer [added in version 1.3].

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

minScaleproperty 
public var minScale:Number = 0

The minimum scale of the layer [added in version 1.3].

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

spatialReferenceproperty 
spatialReference:SpatialReference  [read-only]

The spatial reference of the layer. Subclasses should override this method as a best practice in case a subclassed layer is added to a map which has a different spatial reference.

The default value is new SpatialReference(4326).

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

Implementation
    public function get spatialReference():SpatialReference
unitsproperty 
units:String  [read-only]

The units of the layer. Subclasses should override this method as a best practice in case a subclassed layer is added to a map which has different "units".

The default value is Units.DECIMAL_DEGREES.

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

Implementation
    public function get units():String

See also

Constructor detail
Layer()constructor
public function Layer()

Creates a new Layer object.

Method detail
addMapListeners()method
protected function addMapListeners():void

Adds listeners for ExtentEvent.EXTENT_CHANGE, ZoomEvent.ZOOM_START, ZoomEvent.ZOOM_UPDATE and ZoomEvent.ZOOM_END.

See also

extentChangeHandler()method 
protected function extentChangeHandler(event:ExtentEvent):void

When an EXTENT_CHANGE event occurs, this calls invalidateLayer();

Parameters
event:ExtentEvent — The ExtentEvent that occurred.
hideHandler()method 
protected function hideHandler(event:FlexEvent):void

When the layer is hidden (visible is set to false), this calls removeMapListeners().

Parameters
event:FlexEvent — The FlexEvent that occurred.
invalidateLayer()method 
protected function invalidateLayer():void

Subclasses should call this whenever they would like to have updateLayer() called on them. It's analogous to Flex's invalidateDisplayList()/updateDisplayList() methods since many calls to invalidateLayer() in one frame will only result in a single call to updateLayer() in the next frame.

See also

refresh()method 
public function refresh():void

Causes the layer to redraw or reload its content.

removeAllChildren()method 
protected function removeAllChildren():void

Removes all the layers children.

removeMapListeners()method 
protected function removeMapListeners():void

Removes the four event listeners added by addMapListeners();

setLoaded()method 
protected function setLoaded(value:Boolean):void

Subclasses must call this when they've loaded all their properties and are ready to load their content.

Parameters
value:Boolean — Returns true if the layer is ready; false otherwise.
showHandler()method 
protected function showHandler(event:FlexEvent):void

When the layer is shown (visible is set to true), this calls addMapListeners() and invalidateLayer().

Parameters
event:FlexEvent — The FlexEvent that occurred.
toScreenX()method 
protected function toScreenX(mapX:Number):Number

Converts the x-coordinate of map point to a screen point.

Parameters
mapX:Number — The x-coordinate of the map point to convert.

Returns
Number — The x-coordinate in screen coordinates.
toScreenY()method 
protected function toScreenY(mapY:Number):Number

Converts the y-coordinate of map point to a screen point.

Parameters
mapY:Number — The y-coordinate of the map point to convert.

Returns
Number — The y-coordinate in screen coordinates.
updateLayer()method 
protected function updateLayer():void

Subclasses must override this method. It is called whenever the layer needs to be refreshed.

See also

zoomEndHandler()method 
protected function zoomEndHandler(event:ZoomEvent):void

Finishes the zoom animation.

Parameters
event:ZoomEvent — The ZoomEvent that occurred.
zoomStartHandler()method 
protected function zoomStartHandler(event:ZoomEvent):void

Prepares the zoom animation by taking a bitmap of the layer.

Parameters
event:ZoomEvent — The ZoomEvent that occurred.
zoomUpdateHandler()method 
protected function zoomUpdateHandler(event:ZoomEvent):void

Redraws the bitmap of the layer.

Parameters
event:ZoomEvent — The ZoomEvent that occurred.
Event detail
loadevent 
Event object type: com.esri.ags.events.LayerEvent
LayerEvent.type property = com.esri.ags.events.LayerEvent.LOAD

Fires after layer properties for the layer are successfully populated.

Defines the value of the type property of the event object for a load event.

loadErrorevent  
Event object type: com.esri.ags.events.LayerEvent
LayerEvent.type property = com.esri.ags.events.LayerEvent.LOAD_ERROR

Fires if the layer is unable to load.

Defines the value of the type property of the event object for a loadError event.