[Mapserver-users] html legends

Lowther, David W dlowther at ou.edu
Thu Apr 17 09:26:33 EDT 2003


Kevin,

You can make any of that happen with HTML legends if you are willing to be
creative with the use of the [IF] blocks and create your own metadata tags
that you can check in the HTML legend.

So, in your case, you might have a metadata tag in your mapfile called
Legend_Type. Possible values could be "LAYER" or "CLASS". Each layer in your
mapfile would have this metadata value set to one or the other. Then, in
your HTML legend template, you could check this value and build the legend
accordingly.

Something (and I mean roughly) like this might work...

[leg_layer_html opt_flag=15]
	[if name=legend_type oper=eq value=LAYER]
		<!-- show symbol and layername -->
		<img src=[leg_icon width=30 height=10]>[leg_layer_name]
	[/if]
	[if name=legend_type oper=eq value=CLASS]
		<!-- show layername only -->
		<img src=[leg_icon width=30 height=10]>[leg_layer_name]
	[/if]	
[/leg_layer_html]
[leg_class_html opt_flag=15]
	<!-- no if needed for type LAYER -->
	[if name=legend_type oper=eq value=CLASS]
		<!-- do each class icon and name -->
		<img src=[leg_icon width=30 height=10]>[leg_class_name]
	[/if]	
[/leg_class_html]


Here's the definative source for things like opt_flag and other HTML legend
how-to's:

http://mapserver.gis.umn.edu/doc36/html-legend-howto.html


Hope that helps,

Dave Lowther

> -----Original Message-----
> From: Kevin Flanders [mailto:kevinflanders at rcn.com] 
> Sent: Tuesday, April 15, 2003 6:44 PM
> To: mapservermailing
> Subject: [Mapserver-users] html legends
> 
> 
> I am having some difficulty creating the html legend I 
> want...if it is even possible.  I would like to have layer 
> names for all map layers and class names for only those 
> layers that have multiple classes.
> 
> So a layer that had multiple classes would have its name with 
> no symbol, and then several classes below it with symbols.  A 
> layer with only one class would have a symbol and its name only.
> 
> Is this possible?  Would it help to have single-class layer 
> names equal their respective class names?
> 
> 
> 
> Kevin
> 
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu 
> http://lists.gis.umn.edu/mailman/listinfo/maps> erver-users
> 



More information about the mapserver-users mailing list