[Mapserver-users] truetype symbol size in legend

Eric Bridger eric at gomoos.org
Tue Apr 27 06:24:50 PDT 2004


On Tue, 2004-04-27 at 04:28, Moritz Lennert wrote:
> Eric Bridger said:
 
> > This is something of a hack also but you could create a separate layer
> > just for displaying the legend. Remove the NAME from your CLASS  above
> > to prevent it from displaying in the legend.
> >
> > Create a new LAYER:
> > NAME Cerclestt_legend
> > STATUS DEFAULT
> > TYPE POINT
> > CLASS
> >   NAME "Symbole cercle TT"
> >   COLOR 255 0 0
> >   # circle name defined in symbol.sym file
> >   SYMBOL "circle"
> >   SIZE N
> > END
> >
> > Set N to the size you want in pixels.  You could also create a TrueType
> > "N" circle in your symbol.sym file and use that as your SYMBOL.
> >
> 
> Thank you, now I get a nice legend. However, it is visible all the time,
> and would like to have it shown only when the corresponding layer is
> visible. So, I've been experimenting with the REQUIRES command. However, I
> just can't seem to make it work. When I set STATUS to DEFAULT, the legend
> is always visible, when I set it to ON or OFF it is never visible, even
> when the layer CerclesTT is visible...
> 
> Any hints ?
> 
> Here's my Layer definition:
> 
> LAYER # Legende pour cercles truetype
>     NAME Cerclestt_legend
>     STATUS ON
>     REQUIRES "[Cerclestt]"
>     TYPE POINT
>     CLASS
>       NAME "3 travailleurs"
>       COLOR 255 0 0
>       SYMBOL "point_tt"
>       SIZE 30
>     END
>  END # Legende pour cercles truetype
> 
You'll discover that with Mapserver there's always more than one way to
get the job done.

Legends (along with your map) are controlled by the layers CGI
parameter. The [legend] template variable gets replaced with something
like:
/cgi-bin/mapserv?mode=legend&layers=Cerclestt+...

What you need is to get layers=Cerclestt+Cerclestt_legend which could be
done with a small Javascript command triggered by the selection of the
map legend.

Alternatively, and perhaps most cleanly is to investigate the GROUP tag
in your map file. Have both the layer and legend layer use the same
group name. Then both would get turned on/off together. (I couldn't test
this, not being set up to use templates.

Finally, another quick hack, which I did test successfully:
Give both layers the same name.  When the map is drawn, the legend layer
(with no DATA) won't be displayed. When the legend is drawn the data
layers (with no CLASS NAME) won't be drawn in the legend.







More information about the MapServer-users mailing list