Select to view content in your preferred language

Changing the Dynamic Map Legend Widget output

515
1
06-26-2010 05:00 PM
IanParfitt
Deactivated User
Hi

I'm looking for a way to change the format of the Map Legend Widget (From Robert's code at
http://forums.esri.com/thread.asp?c=...=299116&mc=137).   I'd like to have the point swatches / symbols on the same line as the description text to save space: currently the swatches are on one line, the description the next line and so on, taking up twice as much space as I'd like, and making it necessary for the user to scroll down to see all the point symbols.  Would like to see them all at once for simplicity.    Is this possible to do?

Many thanks

Ian
Tags (2)
0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus
Ian,

   I didn't extensively test this but seems to do what you are asking for.
Just replace your layerLegendData.mxml with this code:

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox 
 xmlns:mx  ="http://www.adobe.com/2006/mxml" 
 xmlns:widgets ="com.esri.solutions.flexviewer.widgets.*"
 width   ="95%" 
 minHeight  ="22" 
 backgroundAlpha ="1" 
 paddingLeft  ="9" 
 paddingRight ="3" 
 backgroundColor ="#FFFFFF"
 includeInLayout="{isVisible}">
 <mx:Script>
  <![CDATA[
   import mx.collections.ArrayCollection;
  
   [Bindable]
   private var layerName:String;
   
   private var _infoData:Object;
   
   private var ldata:Object;
   
   [Bindable]
   private var isVisible:Boolean = false;
   
   [Bindable]
   private var isNotSingle:Boolean = true;
   
   [Bindable]
   private var isSingle:Boolean = false;
   
   public function get infoData():Object
   {
    return _infoData;
   }
   
   public function set infoData(value:Object):void
   {
    _infoData = value;
    
    ldata = infoData.ldata;
    layerName = infoData.title;
    isVisible = infoData.isvis;
    if(ldata.length == 1){
     isNotSingle = false;
     isSingle = true;
     var infDataS:Object = 
     {
      icon: ldata[0]["url"], 
      title: layerName
     };
     sLegendData.infoData = infDataS;
    }else{
     isNotSingle = true;
     isSingle = false;
     var recAC:ArrayCollection = new ArrayCollection();
     for (var i:Number = 0; i < ldata.length; i++){
      var infData:Object = 
      {
       icon: ldata["url"], 
       title: ldata["label"]
      };                 
      recAC.addItem(infData);
     }
     legendRepeater.dataProvider = recAC;
    }
    
   }
   
  ]]>
 </mx:Script>
 <widgets:LegendData id="sLegendData" includeInLayout="{isSingle}" visible="{isSingle}"/>
 <mx:Label text="{layerName}" fontWeight="bold" width="100%" includeInLayout="{isNotSingle}" visible="{isNotSingle}"/>
 <mx:Repeater id="legendRepeater" includeInLayout="{isNotSingle}" visible="{isNotSingle}">
  <widgets:LegendData infoData="{legendRepeater.currentItem}"/>
 </mx:Repeater>
</mx:VBox>


After paying around with this I like it, well something else to do to my website when I get back to work.
0 Kudos