[mapserver-users] legend "feature"?

Puneet Kishor pkishor at GeoAnalytics.com
Sun Sep 1 17:25:29 EDT 2002


On Friday, August 30, 2002, at 04:53  PM, TCHaddad wrote:

> Hello,
>
> I just inserted a whole bunch of scale dependant classes into the 
> layers in my mapfile, so that the symbology in my maps will change as 
> the user zooms in and out. works very well visually.
>
> However, I noticed that now if I generate a legend at a particular zoom 
> level, I get all the symbols associated with every layer displayed in 
> the map. For example, I get 3 legend entries with 3 different symbols 
> when I turn on the layer defined below:
>
> LAYER
>   NAME  ushighway
>   GROUP Roads
>   STATUS OFF
>   TYPE LINE
>   DATA "D:/gis/ushwy"
>   #MINSCALE
>   MAXSCALE 3000000
>   CLASS
>     MAXSCALE 100000
>     NAME "US Highway"
>     TEMPLATE "ttf.htm"
>     SYMBOL 'circle1'
>     COLOR 54 54 54
>     SIZE 3
>     OVERLAYSYMBOL 'circle1'
>     OVERLAYCOLOR 25 25 112
>     OVERLAYSIZE 1
>   END
>  CLASS
>     MAXSCALE 700000
>     MINSCALE 100001
>     NAME "US Highway"
>     SYMBOL 'circle1'
>     COLOR 25 25 112
>     SIZE 2
>   END
>  CLASS
>     MINSCALE 700001
>     NAME "US Highway"
>     TEMPLATE "ttf.htm"
>     SYMBOL 'circle1'
>     COLOR 130 130 130
>     SIZE 1
>   END
> END
>
> I understand if I take out the NAME item from 2 of the Classes, that I 
> will only get one legend entry per layer, but then nothing garuntees 
> that my legend will have the correct symbol according to my zoom level.
>
> Is there something I am missing in my definition of the Layer, or is 
> this a "feature" of how legends work?
>

well, first of all... afaik, this is a "feature" of how at least _this_ 
legend works. You have a name, it will display (subject to scale 
conditions, of course). You don't have a name, it won't display.

If you take NAME from 2 of your classes, those classes will be drawn in 
the map, but they will never show up in the legend. Only the class with 
the NAME still in the map file will show up in the legend when it lights 
up in the map because of its scale becoming active.

That said, don't you want the legend to display the layer that is in the 
map "now"? If not, then you have to find different ways to legend... one 
option would be to use HTML Legends for which you will need at least 
mapserver version > 3.5 (check the docs... I know html leg don't work 
with 3.5  because I have that; might be 3.6.1). With html leg (again 
afaik), you can control each layer separately, hence you can logic it 
out (or in) with mapscript. Alternatively, you can paint a static legend 
that you can make in a graphics program and save.


someone, correct me if I am wrong.

pk/




More information about the mapserver-users mailing list