[Chameleon] Selectively displaying layers in a legend

Jacob Delfos jacob.delfos at maunsell.com
Thu Oct 21 21:46:46 EDT 2004


Jennifer,

At the risk of asking a stupid question, by selectively showing layers, you don't mean removing them from the map altogether, do you? That would be a matter of removing them from the .map file.

If you mean for the layer to show in the map, but not in the legend, you would have to change the template file that your legend_template widget uses. For example, you could put in an extra IF-statement, which says:

[if name=SHOWINLEGEND oper=isnull] 
[/if]

Your legend_template.html file would become:

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[leg_layer_html order=ascending opt_flag=15]
[if name=SHOWINLEGEND oper=isnull] 
  <tr bgcolor="#ffffff">
    <td><input type="radio" name="my_legend" onclick="CWCSelectLayer('[leg_layer_name]', true)"[if name=selected value=1] CHECKED[/if] ></td>
    <td align="center" width=20><input type="checkbox" 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]></td>
    <td><img src="[leg_icon width=20 height=18]" width="20" height="20"</td>
    [if name=wms_name oper=isnull]
    <td><a href="#" onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span class="label">[leg_layer_name]</span></a></td>
  </tr>
    [/if]
    [if name=wms_name oper=isset]
    <td><a href="#" onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span class="label">[metadata name=WMS_TITLE]</span></a></td>
  </tr>
    [/if]
[/if]
[/leg_layer_html]
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Then all you'd have to do to make it not appear in the legend, is put a tag called "SHOWINLEGEND" inside the METADATA tag of that layer:

LAYER
   blah blah.....
   METADATA
   SHOWINLEGEND "nope"
   END
END


Hope this helps...

Jacob


-----Original Message-----
From: chameleon-bounces at lists.maptools.org [mailto:chameleon-bounces at lists.maptools.org] On Behalf Of Jennifer Zeisloft
Sent: 22 October 2004 09:10
To: Chameleon at lists.maptools.org
Subject: [Chameleon] Selectively displaying layers in a legend


Hello All...

I am extremely new to MapServer, Chameleon, etc. (and web technology,
for that matter), and I am wondering how I might show certain layers
and not others in a legend.  I am working off of the sample_enhanced
files in the Chameleon sample applications.  This uses the legend
template widget, but if something else would work better for
selectively showing layers, I'd be more than willing to attempt using
another widget.

I am not all that familiar with the various code languages and I
haven't a clue which file would be the best to alter.  Any help would
be VERY much appreciated!  Thanks in advance.

Jennifer Zeisloft
(UW-Madison, Sea Grant)
_______________________________________________
Chameleon mailing list
Chameleon at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/chameleon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/chameleon/attachments/20041022/24ba6adc/attachment.htm


More information about the Chameleon mailing list