| Package | com.esri.ags.components |
| Class | public class Legend |
| Inheritance | Legend spark.components.supportClasses.SkinnableComponent |
The legend supports the following layer types: ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer, FeatureLayer, GraphicsLayer and KMLLayer (KML added in version 2.4). If the layer is an ArcGISDynamicMapServiceLayer or ArcGISTiledMapServiceLayer created using ArcGIS Server 10.0 SP1 or higher the legend is generated using the REST Map Service legend resource of that service, for example, http://server.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Unemployment_Rate/MapServer/legend. If the layers are version 10 or lower the legend is created using the ArcGIS.com legend service. In order to use the ArcGIS.com legend service your map service needs to be publicly accessible and your application must be able to access ArcGIS.com.
The legend for feature layers is created using the layer's drawing info, for example: http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0.
See also
| Property | Defined By | ||
|---|---|---|---|
| layers : Array
Specify a subset of layer instances in the map to display in the component. | Legend | ||
| map : Map
The Map that the legend is associated with. | Legend | ||
| respectCurrentMapScale : Boolean
When true the legend will update with every scale change and display only the layers and sub layers that are visible in the current map scale. | Legend | ||
| Method | Defined By | ||
|---|---|---|---|
Creates a new Legend component. | Legend | ||
To skin the component, implement a skin that defines the following states. Although you must implement all skin states, a skin state can be empty. An empty skin state specifies no changes to the default skin state.
| layers | property |
layers:ArraySpecify a subset of layer instances in the map to display in the component. If not set, all layers in the map will be displayed.
This property can be used as the source for data binding.
public function get layers():Array public function set layers(value:Array):voidSee also
| map | property |
map:MapThe Map that the legend is associated with.
This property can be used as the source for data binding.
public function get map():Map public function set map(value:Map):void| respectCurrentMapScale | property |
respectCurrentMapScale:BooleanWhen true the legend will update with every scale change and display only the layers and sub layers that are visible in the current map scale. When false, the legend does not update on every scale change and all layers and sub layers will be displayed.
The default value is true.
This property can be used as the source for data binding.
public function get respectCurrentMapScale():Boolean public function set respectCurrentMapScale(value:Boolean):void| Legend | () | Constructor |
public function Legend(layers:Array = null, map:Map = null, respectCurrentMapScale:Boolean = true)Creates a new Legend component.
Parameterslayers:Array (default = null) — Specify a subset of layers in the map to display in the component.
| |
map:Map (default = null) — The Map associated.
| |
respectCurrentMapScale:Boolean (default = true) — When true the legend will update with every scale change and display only the layers and sub layers that are visible in the current map scale. When false, the legend does not update on every scale change and all layers and sub layers will be displayed.
|