[mapserver-users] HTML Legend with Status Checking...

Martin, Daniel DMartin at erac.com
Wed Oct 2 13:10:40 EDT 2002


> OK, I have been reading this thread with great interest and was 
> wondering if you can summarize what you need to do to have multiple 
> layers at different scales and only have the visible ones show up in 
> your legend templates. 
Here's my best shot:
In MapServer we can have as many layers of the same name as we want.  The
benefit is that these same-named layers will turn on and off together.  An
HTML template will show each layer and class even if they have the same
name, *assuming* they are all in scale.

However, if these same named layers have scales that do not overlap, you
should never see both in the legend.  This gives you the effect of several
layers acting as one, with MapServer automatically switching between them as
you zoom in and out.  

As we found out in this thread, you MUST use MINSCALE and MAXSCALE in the
LAYER object, not in the CLASS object, for it to work correctly in the HTML
legend.

This also hinges on your opt_flag in your [leg_layer_html] tag.  If you use
opt_flag=1 or a summation value of opt_flag that includes 1, then layers
will show even when out of scale.  When I say a summation value, as the HTML
Legend HOWTO indicates, if you want an opt_flag of 1 and an opt_flag of 4,
you set your opt_flag to 5.

My favorite use of this is streets.  I use this technique to create a street
layer that, at high scale, uses a small single class highway layer.  If you
look at the entire US the streets load in seconds.  When you zoom to a
certain level MapServer switches to a very detailed street layer with many
different classes that would be extremely slow to load at a higher scale.
To the user this is seamless. 

One interesting addition I'll point out is that sometimes you may want to
combine two layers into one even at the same scale, but only show one in the
legend.  You can accomplish this by using [leg_layer_html
order_metadata=legend_order] and then setting the legend_order meta data to
-1 in one of the two layers:

METADATA 
   legend_order "-1"
END

>  I have a mapfile that was working great in a modified version of 
>  gmap75 and in it all like layers have the same name and different 
>  scales and it works great, except it always shows all the layers.
In an HTML legend, this *should* only happen if you have an opt_flag=1 (or a
summation value of opt_flag that includes 1).  Perhaps this was the case?

> I move the mapfile into the new maplab application and a bunch of my 
> layers vanished. 
Honestly, I've not used MapLab.  When you say "vanished", do you mean from
the map itself, or only from the legend?  If you mean from the legend,
perhaps the opt_flag is different in MapLab.

Hope that helps a little,
Dan Martin

-----Original Message-----
From: woodbri at swoodbridge.com [mailto:woodbri at swoodbridge.com]
Sent: Tuesday, October 01, 2002 7:10 PM
To: mapserver-users at lists.gis.umn.edu
Subject: Re: [mapserver-users] HTML Legend with Status Checking...


(I cc:'d this to maplab list)


OK, I have been reading this thread with great interest and was 
wondering if you can summarize what you need to do to have multiple 
layers at different scales and only have the visible ones show up in 
your legend templates. I think this is an area that could use more 
documentation or at least user insights.

The variables seem to be:

group names
layer names and scales
class names and scales
the option code in legend templates

and maybe a few others that I missed.

I have a mapfile that was working great in a modified version of 
gmap75 and in it all like layers have the same name and different 
scales and it works great, except it always shows all the layers.

I move the mapfile into the new maplab application and a bunch of my 
layers vanished. I turns out the maplab generates urls like:
   ...&layer[]=highway&layer[]=highway&layer[]=highway&...
because I use the same name on all the like layers. So I think I have 
it confused.

So your insight into the layers, names, scales etc might help me 
figure this out.


Thanks,
  -Steve W.



More information about the mapserver-users mailing list