Chameleon    Home  |  Docs  |  Support  |  Bugs  |  CVS  |  Downloads 

MapTools.org

Legend Template

First, I took the code of Edith Taki that I found on a list. It is doing something similar so it was a good starting point. My legend template file looks like this:

[leg_group_html]
</div>
<div>
<div class="groupLabel">
<span>
<input type="checkbox" id="[leg_group_name]" name="[leg_group_name]"
onchange="toggleGroup(this);"
</span>
<span><img id="[leg_group_name]_folderImage" 
src="images/rightarrow.gif"></span>
<span>
<a style="color:#333333; text-decoration: none;" 
href="javascript:void(0);" 
onclick="toggleLayers('[leg_group_name]');">[leg_group_name] </a>
</span>
</div>
</div>

initGroup('[leg_group_name]');

[/leg_group_html]
[leg_layer_html order=ascending opt_flag=15]
 <div style="margin-left:10px;">
   [if name=SHOWINLEGEND  oper=isnull]
     <span>
       <input type="checkbox" id="layer-[metadata name=group]-[metadata name=layer_index]"
              name='legendlayername[]' value="[leg_layer_name]"
              [if name=layer_status oper=eq value=1]CHECKED[/if]
              [if name=layer_status oper=eq value=2]CHECKED[/if]
              onclick="toggleLayer(this);" >        
     </span>
     <span>
       <img src=[leg_icon]>
     </span>
    
     
       [if name=wms_title oper=isnull]
         <span class="layerLabel"> [leg_layer_name] </span>
       [/if]

       [if name=wms_title oper=isset]
          <span class="layerLabel"> [metadata name=WMS_TITLE]  </span>
       [/if]
   [/if]

     [if name=SHOWINLEGEND oper=isset]
        <input type="hidden" name='legendlayername[]' id="nope" value="[leg_layer_name]">
     [/if]
 </div>
[/leg_layer_html]
  1. Group checkbox has associated onChange toggleGroup function. Group label has associated onClick toggleLayers function (explanations later)
  2. There is initGroup function called from this template. It is used for initialization of group status (expanded/collapsed status and group checkbox status).
  3. The rest is pretty much standard, with handling of SHOWINLEGEND metadata so the layer can be shown on a map but not in a legend

Created by: dgambin last modification: Friday 17 of February, 2006 [08:50:13 UTC] by dgambin

Printer Friendly

 
 

Contact Information

Chameleon Users List