[mapserver-users] Re: HTML Legends - What Good Are They?

Ben Madin lists at remoteinformation.com.au
Wed Feb 24 17:45:16 PST 2010


G'day Bill,

Hopefully someone else has answered this by now...

On 24/02/2010, at 22:41 , mapserver-users-request at lists.osgeo.org wrote:

> I've been searching the 'net and asking questions here for the last two days on HTML Legends, and outside of the standard MS documentation (which has some very confusing bits in it for one who's unfamiliar with the way it works) I've not found anything relevant on this topic except my own questions echoed back at me from nabble and some interestingly-titled documents that are inaccessible because they were on the old MS website. And so far the forum's been silent on the issue as well.

I think it would make a great poll, but I suspect an increased adoption of the web client packages (openlayers, geomoose etc) means less people are using these tools.

> But I have discovered one old message hinting at clever ways to use nested [if] statements with custom metadata variables to make a very useful layer control with collapse and expand features and more. I want to learn more about that but I'd like to skip the time-consuming process of learning by trial and error.
> 
> So can anyone point me to some documentation that goes into more detail about what HTML Legends can really do or direct me to one or two URLs that demonstrate some advanced techniques with nested [if] ...[/if] blocks and custom metadata variables?

Documentation no... I used trial and error. This isn't very sophisticated, I'm not sure what level you are at with this. I found it very confusing to start with, and in general most users don't seem to like sites with too many checkboxes etc - so I only use them for more technical sites - defacto Web GIS. I'm also not a GIS / Web person, but an epidemiologist...

So if it helps here is an image of an example (I'm afraid the site content is internal only) and the code that generates it.

I have also used a site with a lot of javascript that made things visible etc with little plus + minus boxes but found that then people complained they couldn't find the layer they wanted. It's hard to win!

This example worked on MS 4.10, and is still working on 5.6.1 (with the security upgrades added)



the mapfile bit:

  LEGEND
    STATUS EMBED
    position UL
    KEYSIZE 20 15
    LABEL
      TYPE TRUETYPE
      FONT arial
      COLOR 0 0 0
      SIZE 9
    END
    TEMPLATE "template_legend.html"
  END

Note that these maps were often taken for powerpoints for situation updates, hence the legend embedded on the map as well as the legend on the side.

the lines in the template.html file that actually included it :

<h2>Legend:</h2>
<table width='100%'>
    [legend]
</table>

and the legend_template.html template :

[leg_group_html order_metadata=leg_group_name]
<tr>
    <td colspan=3 class='mbg'><b>[leg_group_name]</b></td>
</tr>
[/leg_group_html]

[leg_layer_html order_metadata=layer_order opt_flag=15]
<tr>
    <td>
        <input type=checkbox name="layer" 
       value="[leg_layer_name]" [if name=layer_status oper=eq value=1]CHECKED[/if]>
     </td>
    <td colspan=2>
        <!--a href="[metadata name=href]"-->[metadata name=layer_title]<!--/a-->
    </td>
</tr >
[/leg_layer_html]

[leg_class_html]
<tr>
    <td width=15> </td>
    <td>
        <img src="[leg_icon width=150 height=75]" width=30 height=10>
    </td>
    <td>
        [leg_class_name]
    </td>
</tr>
[/leg_class_html]    


I hope this helps a little bit...

cheers

Ben





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100225/9517e119/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen shot 2010-02-25 at 9.27.39 AM.png
Type: image/png
Size: 64969 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100225/9517e119/attachment.png>


More information about the MapServer-users mailing list