[Mapserver-users] legend question

Charlton Purvis cpurvis at asg.sc.edu
Wed Sep 10 15:07:07 EDT 2003


This is a multi-part message in MIME format.

------_=_NextPart_001_01C377CE.BA9FE116
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi, Damian:

That's not as easy to do, but I do it frequently.  But let me make sure
I understand what you want to do:

[x] Group1Name
    Class1
    Class2
    Class3
[x] Group2Name

Is that right?

If so, I do it by sneaking in a few METADATA variables inside my LAYER
and also making the legend use fixed images (i.e. don't allow MapServer
to use the ones it creates on-the-fly).  To go into all the gory detail
would be, well, gory.  So I'll just throw some code at you and give you
a few points.

.map
# I want to show=20
# [x] speed bari absolute diff power2
#      color_block class 1
#      color_block class 2
#      etc.
  LAYER
    NAME "speed_bari_absolute_diff"
    GROUP "speed_bari_absolute_diff"
    STATUS OFF
    DATA "the_geom from domain_intersect"
    TYPE POINT
    CONNECTIONTYPE POSTGIS
    CONNECTION "user=3Dpostgres dbname=3DmyGISdb host=3Dlocalhost"
    SYMBOLSCALE 10000000
    TOLERANCE 4000
    TOLERANCEUNITS meters
    TEMPLATE "ttt"
    METADATA
      no_icon "ttt"
      list_icons "ttt"
      query_cols "xi yi unc_speed_bari um_speed_bari usf_speed_bari
speed_bari_dif_abs speed_bari_dif_per"
    END

Now look at the attached .html file.  It's ugly!  And the resulting html
(after it is parsed) is even worse!  I'm going to have to think of
something slicker before I use it real-time.  As a matter of fact, I
don't think I'll use this solution, at all.

But until then . . .

* Usual checkbox if/then stuff, but I look for a metadata variable,
no_icon, to see if it is set.  If it is, then I don't want this group to
have an icon at the group checkbox level.  Just the checkbox, please.
(use_icon means I do want a group-level icon.  Follow the use_icon isset
stuff to see that the image URL is placed at this point.  All the
javascript junk is to remove the underscores.
* Write the group name.  Same javascript underscore junk.
* Now in the class level, I have hard coded checks for layer names.  So
if we're looking at the speed_bari_percent_diff layer, show the class
icons which are hard coded the same way as the group icons in the first
bullet.

I realize that I'm just throwing stuff at you, and that's not completely
helpful.  If you want more details, say the word.

Charlton

> -----Original Message-----
> From: Map Surfers [mailto:map_surfer at yahoo.com]
> Sent: Tuesday, September 09, 2003 3:32 PM
> To: mapserver-users at lists.gis.umn.edu
> Subject: [Mapserver-users] legend question
>=20
> How would I make it so that the classes only displayed
> if a user selected the layer/group to display?
>=20
> [leg_group_html]
> <tr>
>   <td colspan=3D"2" bgcolor=3D"#CCCCCC"><font
> face=3D"Verdana, Arial, Helvetica" size=3D"-1">
>     <input type=3D"checkbox" name=3D"layer_status[]"
> value=3D"[layer_group_name]" [if name=3Dlayer_status
> oper=3Deq value=3D1]CHECKED[/if][if name=3Dlayer_status
> oper=3Deq value=3D2]CHECKED[/if]>
>     &nbsp;<b>[leg_group_name]</b>
>   </font></td>
> </tr>
> [/leg_group_html]
>=20
> [leg_class_html]
> <tr>
>   <td align=3D"center" valign=3D"top"><font face=3D"Verdana,
> Arial, Helvetica" size=3D"-1">
>     <img src=3D"[leg_icon width=3D18 height=3D10]"
> width=3D"20" height=3D"10">
>   </font></td>
>   <td><font face=3D"Verdana, Arial, Helvetica"
> size=3D"-1">
>     [leg_class_name]
>   </font></td>
> </tr>
> [/leg_class_html]
>=20
> TIA,
>=20
> Damian

------_=_NextPart_001_01C377CE.BA9FE116
Content-Type: text/plain;
	name="legend_template.html.txt"
Content-Transfer-Encoding: base64
Content-Description: legend_template.html.txt
Content-Disposition: attachment;
	filename="legend_template.html.txt"

W2xlZ19ncm91cF9odG1sIE9wdF9GbGFnPTE1XQo8dHIgYmdjb2xvcj0iI0ZGRkZGRiI+CiAgPHRk
IGFsaWduPSJjZW50ZXIiPjxpbnB1dCB0eXBlPSJjaGVja2JveCIgbmFtZT0ibGF5ZXJfc3RhdHVz
W10iIHZhbHVlPSJbbGVnX2dyb3VwX25hbWVdIiBbaWYgbmFtZT1sYXllcl9zdGF0dXMgb3Blcj1l
cSAgdmFsdWU9MV1DSEVDS0VEWy9pZl1baWYgbmFtZT1sYXllcl9zdGF0dXMgb3Blcj1lc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