[Chameleon] Legend template using group rather than layer (resending)

J. Delfos jacob.delfos at maunsell.com
Thu May 20 20:39:24 EDT 2004


(resending; we got stuffed exchange server)
--------------------------------------------
Thanks for you help, Liz and Paul.

So basically, as soon as you use groups in your legend, you lose layers
without a group. But if you don't have groups defined in your legend, you
cannot access their attributes either...

After a lot of messing around I found an equivalent solution, exploiting a
bug (feature?) in mapserver and chameleon:

Giving multiple layers the same name makes them turn on and off at the same
time, emulating a group. By putting metadata in the mapfile you can give it
an attribute that specified whether or not it should be shown in the legend:

[if name=WMS_SHOWINLEGEND oper=isnull]
Put checkboxes, titles, links, etc.
[/if]

So my simplified mapfile looks like this:

#########################################
LAYER
    NAME "Precinct 2 Structure Plan"
    TYPE POLYGON
    DATA precinct2structure2d
    STATUS OFF
    CLASSITEM "Color"

CLASS
EXPRESSION "1"
COLOR 0 0 255
END

CLASS
EXPRESSION "2"
COLOR 0 255 0
END

  METADATA
  WMS_TITLE "Precinct 2 Structure Plan"
  END
END


LAYER
    NAME "Precinct 2 Structure Plan"
    TYPE POLYGON
    DATA precinct2structure2d
    STATUS OFF
    CLASS
    OUTLINECOLOR 0 0 0
    END

  METADATA
    WMS_TITLE "Precinct 2 Structure Plan Linework"
    WMS_SHOWINLEGEND "no"
  END
 END
#############################################


Both layers have the same name, and show up as a group. Only the first
layer's name shows up in the legend, the second one disappears because I
test whether WMS_SHOWINLEGEND is null. I did this with other layers too, and
I can still query the vector layers, with their attributes showing up in
individual tables (by making them have different WMS_TITLE).

So to overcome the limitations, you can emulate a group by making layers
have the same name, and have your legend template test on which ones to
show.

Regards,

Jacob







-----Original Message-----
From: Paul Spencer [mailto:pagameba at magma.ca]
Sent: Thursday, 20 May 2004 8:51 AM
To: Godwin, Liz
Cc: Chameleon; spencer at dmsolutions.ca
Subject: Re: [Chameleon] Legend template using group rather than layer


Liz, you may be right ... the piece of the documentation that appears to
be pertinent is:

"HTML block to use for layer group headers if layers should be grouped
in the legend. If not set then layers are not grouped in the legend.

When the [leg_group_html] tag is used, then layers that don't belong to
any group (i.e. LAYER GROUP not set in the mapfile) and their classes
will not show up at all in the legend. The group list is decided by the
order_metadata parameter, which is explained later."

What I think is most confusing here is that layers that have no group
will not show up in the legend if the leg_group_html is used, regardless
of whether you use a leg_layer_html or not.

Certainly example 4 shows the two being used together.

However, when we tried it for one of our clients, I seem to remember
that we could not get it to work as we wanted, but that could have been
a limitation of our requirements or the legend template processor, can't
remember which.

Cheers,

Paul

Godwin, Liz wrote:

> This is the second time I have heard this, but I'm not convinced.
>
> Why does this work then?  Go to the Itasca demo:
> http://www2.dmsolutions.ca/msapps/itasca_legend/demo_init.html
>
> Legend 3 uses groups of layers.  Also.. The online documentation
> suggests that this works.
>
> Liz
>
> -----Original Message-----
> From: chameleon-bounces at lists.maptools.org
> [mailto:chameleon-bounces at lists.maptools.org] On Behalf Of Paul
> Spencer
> Sent: May 19, 2004 6:50 AM
> To: Delfos, Jacob
> Cc: chameleon at lists.maptools.org
> Subject: Re: [Chameleon] Legend template using group rather than layer
>
>
> Jacob,
>
> you have run into a limitation of the html legend template processor
> in
> mapserver, it is possible to show only groups OR layers.  This was one
> of the reasons that we built the XMLThemeLegend, it allows you to create
>
> Themes and Groups of layers for display purposes independently of the
> grouping of layers in the map file.
>
> Unfortunately, the XMLThemeLegend cannot display classes.
>
> We did one project where we combined both the XMLThemeLegend and
> LegendTemplate.  The XMLThemeLegend was used to generate layer
> visibility controls in a compact set of themes and groups and the
> LegendTemplate displayed groups and classes of visible layers (no
> checkboxes).  Pretty cool.
>
> Sorry I couldn't help you more,
>
> Paul
>
> Delfos, Jacob wrote:
>
>
>>Hi All,
>>
>>I've been tying to create a legend template which generates a legend
>>with tickboxes to turn layers on and off, but which shows groups as
>>well. If a layer is in a group, I don't want the invidividual layer to
>
>
>>be shown at all.
>>
>>At the moment I'm using a basic template which I think I got off the
>>mapserver website (pasted below).
>>
>>I tried to modify it to show groups, but it doesn't seem to work. Can
>>anyone give me a hint?
>>
>>Regards,
>>
>>Jacob
>>
>>
>>----------------------------------------------------------------------
>>-----------------------------------------------------------------
>>
>>[leg_layer_html order=ascending opt_flag=15]
>>[if name=CWC_TMP_LAYER oper=isnull]
>>
>>  <tr bgcolor="#FFFFFF">
>>    <td align="center"><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>
>>    [if name=wms_name oper=isnull]
>>    <td><a href="#"
>>
>
> onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><fon
> t
>
>>face="Arial, Helvetica, sans-serif"
>>size="1">[leg_layer_name]</font></a></td>
>>
>>  </tr>
>>    [/if]
>>    [if name=wms_name oper=isset]
>>    <td><a href="#"
>>
>
> onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><fon
> t
>
>>face="Arial, Helvetica, sans-serif" size="1">[metadata
>>name=WMS_TITLE]</font></a></td>
>>
>>  </tr>
>>    [/if]
>>[/if]
>>[/leg_layer_html]
>>
>>
>>----------------------------------------------------------------------
>>--
>>
>>_______________________________________________
>>Chameleon mailing list
>>Chameleon at lists.maptools.org
>>http://lists.maptools.org/mailman/listinfo/chameleon
>
>

-- 
  -----------------------------------------------------------------
|Paul Spencer                           pspencer at dmsolutions.ca   |
|-----------------------------------------------------------------|
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
  -----------------------------------------------------------------

_______________________________________________
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/20040521/56d66554/legend-0001.html


More information about the Chameleon mailing list