| Package | com.esri.ags.layers |
| Class | public class Layer |
| Inheritance | Layer mx.core.UIComponent |
| Subclasses | DynamicMapServiceLayer, GraphicsLayer, 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]
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 | ||
| 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 after layer properties for the layer are successfully populated. | Layer | |||
| Fires if the layer is unable to load. | Layer | |||
| initialExtent | property |
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
| 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.
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.
Implementation public function get loaded():Boolean
| map | property |
map:Map [read-only]A reference to the Map this layer is in.
Implementation public function get map():Map
| maxScale | property |
public var maxScale:Number = 0The maximum scale of the layer [added in version 1.3].
This property can be used as the source for data binding.
| minScale | property |
public var minScale:Number = 0The minimum scale of the layer [added in version 1.3].
This property can be used as the source for data binding.
| 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.
Implementation 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.
Implementation public function get units():String
See 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();
Parametersevent: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().
Parametersevent: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'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():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.
Parametersvalue:Boolean — Returns 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().
Parametersevent:FlexEvent — The FlexEvent that occurred.
|
| toScreenX | () | method |
protected function toScreenX(mapX:Number):NumberConverts the x-coordinate of map point to a screen point.
ParametersmapX: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.
ParametersmapY: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.
See also
| zoomEndHandler | () | method |
protected function zoomEndHandler(event:ZoomEvent):voidFinishes the zoom animation.
Parametersevent:ZoomEvent — The ZoomEvent that occurred.
|
| zoomStartHandler | () | method |
protected function zoomStartHandler(event:ZoomEvent):voidPrepares the zoom animation by taking a bitmap of the layer.
Parametersevent:ZoomEvent — The ZoomEvent that occurred.
|
| zoomUpdateHandler | () | method |
protected function zoomUpdateHandler(event:ZoomEvent):voidRedraws the bitmap of the layer.
Parametersevent:ZoomEvent — The ZoomEvent that occurred.
|
| load | event |
com.esri.ags.events.LayerEvent
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 |
com.esri.ags.events.LayerEvent
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.