Packagecom.esri.ags.layers
Classpublic class Layer
InheritanceLayer Inheritance mx.core.UIComponent
Subclasses DynamicMapServiceLayer, GeoRSSLayer, GraphicsLayer, KMLLayer, MapImageLayer, 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
  attributionVisible : Boolean
Indicates if this layer's attribution should be displayed.
Layer
  copyright : String
The layer's copyright text.
Layer
  initialExtent : Extent
[read-only] 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.
Layer
  loaded : Boolean
[read-only] When the layer is loaded, the value becomes "true" and layer properties can be accessed.
Layer
  loadFault : Fault
[read-only] A reference to the fault that is dispatched when the layer throws a loadError event.
Layer
  map : Map
[read-only] A reference to the Map this layer is in.
Layer
  maxScale : Number
The maximum scale of the layer.
Layer
  minScale : Number
The minimum scale of the layer.
Layer
  refreshInterval : Number
Refresh interval of the layer in minutes.
Layer
  showInLegend : Boolean
Indicates if this layer should be displayed in the Legend component or PrintTask output.
Layer
  spatialReference : SpatialReference
[read-only] The spatial reference of the layer.
Layer
Protected Properties
 PropertyDefined By
  rotatedMapExtent : Extent
[read-only] Extent of the layer in the rotated map.
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
  
toScreenXY(mapX:Number, mapY:Number):Point
Converts map coordinates to screen coordinates.
Layer
  
toScreenY(mapY:Number):Number
Converts the y-coordinate of map point to a screen point.
Layer
  
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
 Event Summary Defined By
  Fires if the value of isInScaleRange changes.Layer
  Fires after layer properties for the layer are successfully populated.Layer
  Fires if the layer is unable to load.Layer
  Fires when the layer has finished updating its content.Layer
  Fires when the layer begins to update its content.Layer
Property Detail
attributionVisibleproperty
attributionVisible:Boolean

Since : ArcGIS API 3.1 for Flex

Indicates if this layer's attribution should be displayed.

The default value is true.

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


Implementation
    public function get attributionVisible():Boolean
    public function set attributionVisible(value:Boolean):void
copyrightproperty 
copyright:String

Since : ArcGIS API 3.1 for Flex

The layer's copyright text.

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


Implementation
    public function get copyright():String
    public function set copyright(value:String):void
initialExtentproperty 
initialExtent:Extent  [read-only]

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

Since : ArcGIS API for Flex 1.3

Returns true if the current scale of the map is between the maximum and minimum scale of the layer. The comparison used is maxScale <= map.scale <= minScale.

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


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
loadFaultproperty 
loadFault:Fault  [read-only]

Since : ArcGIS API for Flex 2.3

A reference to the fault that is dispatched when the layer throws a loadError event. If loaded is false and this is not null, then the layer has failed to load.

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


Implementation
    public function get loadFault():Fault

See also

mapproperty 
map:Map  [read-only]

A reference to the Map this layer is in.


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

Since : ArcGIS API for Flex 1.3

The maximum scale of the layer.

The default value is 0.

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


Implementation
    public function get maxScale():Number
    public function set maxScale(value:Number):void
minScaleproperty 
minScale:Number

Since : ArcGIS API for Flex 1.3

The minimum scale of the layer.

The default value is 0.

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


Implementation
    public function get minScale():Number
    public function set minScale(value:Number):void
refreshIntervalproperty 
refreshInterval:Number

Since : ArcGIS API 3.6 for Flex

Refresh interval of the layer in minutes. Non-zero value indicates automatic layer refresh at the specified interval. Value of 0 indicates auto refresh is not enabled.

The default value is 0.

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


Implementation
    public function get refreshInterval():Number
    public function set refreshInterval(value:Number):void
rotatedMapExtentproperty 
rotatedMapExtent:Extent  [read-only]

Since : ArcGIS API 3.1 for Flex

Extent of the layer in the rotated map. The rotatedMapExtent is different from the map's extent as the layer's size is different from the map's size when mapRotation is not 0.

On the image below, two maps:

Map's visible area


Implementation
    protected function get rotatedMapExtent():Extent
showInLegendproperty 
showInLegend:Boolean

Since : ArcGIS API 3.2 for Flex

Indicates if this layer should be displayed in the Legend component or PrintTask output. This will be ignored by the PrintTask if LayoutOptions.legendOptions is not null.

The default value is true.

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


Implementation
    public function get showInLegend():Boolean
    public function set showInLegend(value:Boolean):void
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
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 is 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 — Pass 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.
toScreenXY()method 
protected function toScreenXY(mapX:Number, mapY:Number):Point

Since : ArcGIS API 3.1 for Flex

Converts map coordinates to screen coordinates.

Parameters

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

Returns
Point — The coordinates 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. A LayerEvent.UPDATE_START event is dispatched whenever this method is called. Subclasses should dispatch a LayerEvent.UPDATE_END event when they are finished.

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
isInScaleRangeChange Event
Event Object Type: com.esri.ags.events.LayerEvent
LayerEvent.type property = com.esri.ags.events.LayerEvent.IS_IN_SCALE_RANGE_CHANGE

Fires if the value of isInScaleRange changes.

Defines the value of the type property of the event object for an isInScaleRangeChange event.
load Event  
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.
loadError Event  
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.
updateEnd Event  
Event Object Type: com.esri.ags.events.LayerEvent
LayerEvent.type property = com.esri.ags.events.LayerEvent.UPDATE_END

Fires when the layer has finished updating its content.

Defines the value of the type property of the event object for a updateEnd event.
updateStart Event  
Event Object Type: com.esri.ags.events.LayerEvent
LayerEvent.type property = com.esri.ags.events.LayerEvent.UPDATE_START

Fires when the layer begins to update its content.

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