| Package | com.esri.ags.layers |
| Class | public class Layer |
| Inheritance | Layer mx.core.UIComponent |
| Subclasses | DynamicMapServiceLayer, GraphicsLayer, KMLLayer, MapImageLayer, TiledMapServiceLayer |
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
| Property | Defined By | ||
|---|---|---|---|
| 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 [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 | ||
| 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 [added in version 1.3]. | Layer | ||
| minScale : Number
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 | ||
| Method | Defined By | ||
|---|---|---|---|
Layer()
Creates a new Layer object. | Layer | ||
refresh():void
Causes the layer to redraw or reload its content. | Layer | ||
| Method | Defined By | ||
|---|---|---|---|
addMapListeners():void
Adds listeners for ExtentEvent.EXTENT_CHANGE, ZoomEvent.ZOOM_START,
ZoomEvent.ZOOM_UPDATE and ZoomEvent.ZOOM_END. | Layer | ||
extentChangeHandler(event:ExtentEvent):void
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 | ||
invalidateLayer():void
Subclasses should call this whenever they would like to have updateLayer() called on them. | Layer | ||
removeAllChildren():void
Removes all the layers children. | Layer | ||
removeMapListeners():void
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 | ||
zoomEndHandler(event:ZoomEvent):void
Finishes the zoom animation. | Layer | ||
zoomStartHandler(event:ZoomEvent):void
Prepares the zoom animation by taking a bitmap of the layer. | Layer | ||
zoomUpdateHandler(event:ZoomEvent):void
Redraws the bitmap of the layer. | Layer | ||
| 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 | |||
| initialExtent | property |
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.
public function get initialExtent():Extent| isInScaleRange | property |
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.
This property can be used as the source for data binding.
public function get isInScaleRange():Boolean| loaded | property |
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.
public function get loaded():Boolean| loadFault | property |
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.
public function get loadFault():FaultSee also
| map | property |
map:Map [read-only] A reference to the Map this layer is in.
public function get map():Map| maxScale | property |
maxScale:NumberThe maximum scale of the layer [added in version 1.3].
The default value is 0.
This property can be used as the source for data binding.
public function get maxScale():Number public function set maxScale(value:Number):void| minScale | property |
minScale:NumberThe minimum scale of the layer [added in version 1.3].
The default value is 0.
This property can be used as the source for data binding.
public function get minScale():Number public function set minScale(value:Number):void| spatialReference | property |
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.
public function get spatialReference():SpatialReference| units | property |
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.
public function get units():StringSee also
| Layer | () | Constructor |
public function Layer()Creates a new Layer object.
| addMapListeners | () | method |
protected function addMapListeners():voidAdds listeners for ExtentEvent.EXTENT_CHANGE, ZoomEvent.ZOOM_START, ZoomEvent.ZOOM_UPDATE and ZoomEvent.ZOOM_END.
See also
| extentChangeHandler | () | method |
protected function extentChangeHandler(event:ExtentEvent):voidWhen an EXTENT_CHANGE event occurs, this calls invalidateLayer();
Parameters
event:ExtentEvent — The ExtentEvent that occurred.
|
| hideHandler | () | method |
protected function hideHandler(event:FlexEvent):voidWhen the layer is hidden (visible is set to false), this calls removeMapListeners().
Parameters
event:FlexEvent — The FlexEvent that occurred.
|
| invalidateLayer | () | method |
protected function invalidateLayer():voidSubclasses 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():voidCauses the layer to redraw or reload its content.
| removeAllChildren | () | method |
protected function removeAllChildren():voidRemoves all the layers children.
| removeMapListeners | () | method |
protected function removeMapListeners():voidRemoves the four event listeners added by addMapListeners();
| setLoaded | () | method |
protected function setLoaded(value:Boolean):voidSubclasses 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):voidWhen 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):NumberConverts the x-coordinate of map point to a screen point.
Parameters
mapX:Number — The x-coordinate of the map point to convert.
|
Number — The x-coordinate in screen coordinates.
|
| toScreenY | () | method |
protected function toScreenY(mapY:Number):NumberConverts the y-coordinate of map point to a screen point.
Parameters
mapY:Number — The y-coordinate of the map point to convert.
|
Number — The y-coordinate in screen coordinates.
|
| updateLayer | () | method |
protected function updateLayer():voidSubclasses 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):voidFinishes the zoom animation.
Parameters
event:ZoomEvent — The ZoomEvent that occurred.
|
| zoomStartHandler | () | method |
protected function zoomStartHandler(event:ZoomEvent):voidPrepares the zoom animation by taking a bitmap of the layer.
Parameters
event:ZoomEvent — The ZoomEvent that occurred.
|
| zoomUpdateHandler | () | method |
protected function zoomUpdateHandler(event:ZoomEvent):voidRedraws the bitmap of the layer.
Parameters
event:ZoomEvent — The ZoomEvent that occurred.
|
| isInScaleRangeChange | Event |
com.esri.ags.events.LayerEventcom.esri.ags.events.LayerEvent.IS_IN_SCALE_RANGE_CHANGEFires if the value of isInScaleRange changes.
Defines the value of thetype property of the event object for a isInScaleRangeChange event.
| load | Event |
com.esri.ags.events.LayerEventcom.esri.ags.events.LayerEvent.LOADFires after layer properties for the layer are successfully populated.
Defines the value of thetype property of the event object for a load event.
| loadError | Event |
com.esri.ags.events.LayerEventcom.esri.ags.events.LayerEvent.LOAD_ERRORFires if the layer is unable to load.
Defines the value of thetype property of the event object for a loadError event.
| updateEnd | Event |
com.esri.ags.events.LayerEventcom.esri.ags.events.LayerEvent.UPDATE_ENDFires when the layer has finished updating its content.
Defines the value of thetype property of the event object for a updateEnd event.
| updateStart | Event |
com.esri.ags.events.LayerEventcom.esri.ags.events.LayerEvent.UPDATE_STARTFires when the layer begins to update its content.
Defines the value of thetype property of the event object for a updateStart event.