Packagecom.ammap
Classpublic class AmMapLegend
InheritanceAmMapLegend Inheritance mx.containers.Tile

AmMapLegend is a class which displays legend on the map. It's a simple extension of a Tile component and it does not have any direct interaction with the map, as there can be too many different interaction scenarios. So in case you want the legend to do some actions, you should add event listeners and create your own custom methods.

You can add this legend to any container. If you want to add it on top of a map, add both map and the legend to the Canvas and specify legend x and y position. Or, you can place a legend on top of a map as any other component - by adding MapMovie to the DataSet and setting component="yourLegendId".

View the examples.



Public Properties
 PropertyDefined by
  markerAlpha : Number
Opacity of the marker
AmMapLegend
  markerBorderColor : Number
Marker border color default undefined
AmMapLegend
  markerBorderThickness : Number
Thickness of the marker border
AmMapLegend
  markerLabelGap : Number
Size of the gap between legend marker and label
AmMapLegend
  markerSize : Number
Size of the marker in pixels
AmMapLegend
  markerType : String
Type of the legend marker
AmMapLegend
  valueAlign : String
Alignment of the value text
AmMapLegend
  valueWidth : Number
Width of the value text in pixels
AmMapLegend
Public Methods
 MethodDefined by
  
Constructor.
AmMapLegend
Events
 EventSummaryDefined by
   Dispatched when user clicks on a legend item AmMapLegend
   Dispatched when user rolls-out of the legend item AmMapLegend
   Dispatched when user rolls-over the legend item AmMapLegend
Property detail
markerAlphaproperty
markerAlpha:Number  [read-write]

Opacity of the marker

The default value is 1.

Implementation
    public function get markerAlpha():Number
    public function set markerAlpha(value:Number):void
markerBorderColorproperty 
markerBorderColor:Number  [read-write]

Marker border color default undefined

Implementation
    public function get markerBorderColor():Number
    public function set markerBorderColor(value:Number):void
markerBorderThicknessproperty 
markerBorderThickness:Number  [read-write]

Thickness of the marker border

The default value is 0.

Implementation
    public function get markerBorderThickness():Number
    public function set markerBorderThickness(value:Number):void
markerLabelGapproperty 
markerLabelGap:Number  [read-write]

Size of the gap between legend marker and label

The default value is 10.

Implementation
    public function get markerLabelGap():Number
    public function set markerLabelGap(value:Number):void
markerSizeproperty 
markerSize:Number  [read-write]

Size of the marker in pixels

The default value is 16.

Implementation
    public function get markerSize():Number
    public function set markerSize(value:Number):void
markerTypeproperty 
markerType:String  [read-write]

Type of the legend marker

The default value is square.

Implementation
    public function get markerType():String
    public function set markerType(value:String):void
valueAlignproperty 
valueAlign:String  [read-write]

Alignment of the value text

The default value is right.

Implementation
    public function get valueAlign():String
    public function set valueAlign(value:String):void
valueWidthproperty 
valueWidth:Number  [read-write]

Width of the value text in pixels

The default value is 80.

Implementation
    public function get valueWidth():Number
    public function set valueWidth(value:Number):void
Constructor detail
AmMapLegend()constructor
public function AmMapLegend()

Constructor.

Event detail
clickItemevent 
Event object type: com.ammap.events.LegendEvent

Dispatched when user clicks on a legend item

rollOutItemevent  
Event object type: com.ammap.events.LegendEvent

Dispatched when user rolls-out of the legend item

rollOverItemevent  
Event object type: com.ammap.events.LegendEvent

Dispatched when user rolls-over the legend item

Examples
groupedCountries
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
                layout="absolute" 
                xmlns:ammap="http://www.ammap.com/com_internal"
                width="100%"
                height="100%" xmlns:amcharts="http://www.amcharts.com/com_internal">
    
    <mx:Script>
        <![CDATA[
            import com.ammap.mapClasses.MapObject;
            import com.ammap.events.MapObjectEvent;
            import mx.collections.ArrayCollection;
            
            [Bindable]
            [Embed(source="../assets/maps/world.swf")]
            private var _world:Class
            
        ]]>
    </mx:Script>
    
    <!-- This example shows how map objects can be grouped. 
    Grouped objects change colors together when user rolls-over or clicks on one of them -->
    <ammap:AmMap developerMode="false"
                 id="ammap" 
                 width="100%" 
                 height="100%"
                 backgroundColor="#FFFFFF">
        
        <ammap:zoomControl>
            <ammap:ZoomControl buttonIconColor="#DADADA" buttonBorderColor="#DADADA"/>
        </ammap:zoomControl>
        
        <ammap:areasSettings>
            <ammap:AreasSettings unlistedAreasColor="#DDDDDD" rollOverAlpha="1" rollOverColor="#CC0000" alpha="0.9" balloonText="[[title]] joined EU at [[customData]]"/>
        </ammap:areasSettings>
        
        <ammap:dataSets>
            <ammap:DataSet
                mapClass="{_world}" 
                leftLongitude="-168.49" 
                topLatitude="83.63" 
                rightLongitude="190.3" 
                bottomLatitude="-55.58"
                zoomLevel="400" zoomLong="23.7826" zoomLat="53.9362">
                <ammap:areas>
                    <ammap:MapArea instanceName="borders" color="#FFFFFF" mouseEnabled="false"/>
                    <!-- grouping is made by setting linkWith property with array of objects to link with. -->
                    <ammap:MapArea title="Austria" id="AT" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="AT" customData="1995"></ammap:MapArea>
                    <ammap:MapArea title="Ireland" id="IE" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="IE" customData="1973"></ammap:MapArea>
                    <ammap:MapArea title="Denmark" id="DK" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="DK" customData="1973"></ammap:MapArea>
                    <ammap:MapArea title="Finland" id="FI" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="FI" customData="1995"></ammap:MapArea>
                    <ammap:MapArea title="Sweden" id="SE" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="SE" customData="1995"></ammap:MapArea>
                    <ammap:MapArea title="Great Britain" id="GB" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="GB" customData="1973"></ammap:MapArea>
                    <ammap:MapArea title="Italy" id="IT" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="IT" customData="1957"></ammap:MapArea>
                    <ammap:MapArea title="France" id="FR" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="FR" customData="1957"></ammap:MapArea>
                    <ammap:MapArea title="Spain" id="ES" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="ES" customData="1986"></ammap:MapArea>
                    <ammap:MapArea title="Greece" id="GR" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="GR" customData="1981"></ammap:MapArea>
                    <ammap:MapArea title="Germany" id="DE" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="DE" customData="1957"></ammap:MapArea>
                    <ammap:MapArea title="Belgium" id="BE" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="BE" customData="1957"></ammap:MapArea>
                    <ammap:MapArea title="Luxembourg" id="LU" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="LU" customData="1957"></ammap:MapArea>
                    <ammap:MapArea title="Netherlands" id="NL" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="NL" customData="1957"></ammap:MapArea>
                    <ammap:MapArea title="Portugal" id="PT" linkWith="{[AT,IE,DK,FI,SE,GB,IT,FR,ES,GR,DE,BE,LU,NL,PT]}" color="#3366CC" instanceName="PT" customData="1986"></ammap:MapArea>
                    
                    <ammap:MapArea title="Lithuania" id="LT" linkWith="{[LT,LV,CZ,SK,SI,EE,HU,CY,MT,PL]}" color="#FFCC33" instanceName="LT" customData="2004"></ammap:MapArea>
                    <ammap:MapArea title="Latvia" id="LV" linkWith="{[LT,LV,CZ,SK,SI,EE,HU,CY,MT,PL]}" color="#FFCC33" instanceName="LV" customData="2004"></ammap:MapArea>
                    <ammap:MapArea title="Czech Republic " id="CZ" linkWith="{[LT,LV,CZ,SK,SI,EE,HU,CY,MT,PL]}" color="#FFCC33" instanceName="CZ" customData="2004"></ammap:MapArea>
                    <ammap:MapArea title="Slovakia" id="SK" linkWith="{[LT,LV,CZ,SK,SI,EE,HU,CY,MT,PL]}" color="#FFCC33" instanceName="SK" customData="2004"></ammap:MapArea>
                    <ammap:MapArea title="Slovenia" id="SI" linkWith="{[LT,LV,CZ,SK,SI,EE,HU,CY,MT,PL]}" color="#FFCC33" instanceName="SI" customData="2004"></ammap:MapArea>
                    <ammap:MapArea title="Estonia" id="EE" linkWith="{[LT,LV,CZ,SK,SI,EE,HU,CY,MT,PL]}" color="#FFCC33" instanceName="EE" customData="2004"></ammap:MapArea>
                    <ammap:MapArea title="Hungary" id="HU" linkWith="{[LT,LV,CZ,SK,SI,EE,HU,CY,MT,PL]}" color="#FFCC33" instanceName="HU" customData="2004"></ammap:MapArea>
                    <ammap:MapArea title="Cyprus" id="CY" linkWith="{[LT,LV,CZ,SK,SI,EE,HU,CY,MT,PL]}" color="#FFCC33" instanceName="CY" customData="2004"></ammap:MapArea>
                    <ammap:MapArea title="Malta" id="MT" linkWith="{[LT,LV,CZ,SK,SI,EE,HU,CY,MT,PL]}" color="#FFCC33" instanceName="MT" customData="2004"></ammap:MapArea>
                    <ammap:MapArea title="Poland" id="PL" linkWith="{[LT,LV,CZ,SK,SI,EE,HU,CY,MT,PL]}" color="#FFCC33" instanceName="PL" customData="2004"></ammap:MapArea>
                    
                    <ammap:MapArea title="Romania" linkWith="{[BG]}" id="RO" color="#66CC99" instanceName="RO" customData="2007"></ammap:MapArea> 
                    <ammap:MapArea title="Bulgaria" linkWith="{[RO]}" id="BG" color="#66CC99" instanceName="BG" customData="2007"></ammap:MapArea>  
                    
                </ammap:areas>
            </ammap:DataSet>
        </ammap:dataSets>
    </ammap:AmMap>
    <!-- legend of the map -->
    <ammap:AmMapLegend 
        width="600" 
        backgroundAlpha="0.5" 
        backgroundColor="#FFFFFF" 
        bottom="15" 
        left="15" 
        borderColor="#666666"
        borderStyle="solid"
        paddingTop="10"
        paddingBottom="10"
        paddingRight="10"
        paddingLeft="10">
        
        <ammap:LegendItem text="Joined EU before 2004" markerColor="#3366CC"/>
        <ammap:LegendItem text="Joined EU at 2004" markerColor="#FFCC33"/>
        <ammap:LegendItem text="Joined EU at 2007" markerColor="#66CC99"/>        
    </ammap:AmMapLegend>
    
</mx:Application>