[Mapserver-users] Styleitem 'Auto' and Legends

Daniel Morissette morissette at dmsolutions.ca
Fri Jan 3 12:41:25 EST 2003


Oliver Wesp wrote:
> 
> I'm somwhat new to using MapInfo TABs with MapServer. So far I got
> everything up and running. My TABs contain different styles so I'm using
> StyleItem 'AUTO' to render these layers. Works fine except for the
> legend. I like every class to appear on the legend. Is this possible? An
> empty class section doesn't appear in the legend (lack of name-item).
> If I add NAME to my class section one class appears in the legend and
> is randomly rendered with different styles due to the displayed features
> when I zoom into the map.

This is a known issue when you use STYLEITEM AUTO and there is not much
we can do about it.  The legend icon that you get corresponds to the
style of the last object that was drawn from the layer, that's why it
changes when you zoom in.

The nature of datasets such as TAB files is so that every object in the
file can have a different color and style in theory, so there is no way
MapServer can automatically derive a legend for those layers.

You have a few options, you could build a canned legend and hardcode it
in your HTML template.  You could also use the HTML legend and set the
legend icon URL in some layer metadata (the legend icon URL would point
to legend icons that you built yourself for each layer).

I guess we could also modify MapServer so that if you define CLASS
parameters (colors, etc.) in your layer then those parameters are saved
and used for the legend icons instead of the current behavior where
whatever you set in the CLASS object with STYLEITEM AUTO is simply
ignored and the style of the last object takes precedence.

I think I'll file the last option as an enhancement in bugzilla.

Daniel
-- 
------------------------------------------------------------
 Daniel Morissette               morissette at dmsolutions.ca
 DM Solutions Group              http://www.dmsolutions.ca/
------------------------------------------------------------



More information about the mapserver-users mailing list