Changing styles at different zoomlevels

Trond Michelsen trondmm-mapserver at CRUSADERS.NO
Mon May 29 13:52:49 EDT 2006


Hi.

What's the preferred way of setting different styles to a layer at
different zoom levels?

I use a 6 pixels wide line to draw highways, but when you zoom far
out, the roads just get too big. I know I can set maxlevel to turn the
layer off, and I do turn off smaller roads at smaller scales, but I'd
like to be able to show the highways with at different symbol (thinner
line) as the user zooms out.

Now, it's not very difficoult to do this with minscale/maxscale and
extra classes for the highways, but the problem is that the legend
will include all versions of the highway-symbols, regardless of the
zoomlevel.

Is there a way to tell mapserver not to draw legendsymbols for the
classes that aren't drawn at a particular zoom level?

My layer is defined somewhat like this:

LAYER
  name "roads"
  data roads
  status on
  type vector
  minscale   200000
  maxscale 10000000
  classitem  "type"

  CLASS
    name "Highway"
    expression "H"
    maxscale 4000000
    STYLE
      symbol "point"
      size 6
      color 0 0 0
    END
    STYLE
      symbol "point"
      size 4
      color 255 255 0
    END
  END

  CLASS
    name "Highway"
    expression "H"
    minscale  4000000
    STYLE
      symbol "point"
      size 2
      color 0 0 0
    END
  END

END

-- 
Trond Michelsen



More information about the mapserver-users mailing list