MapTools.org

[maplab-users] (LONG) Question/Problem with Legends

woodbri@swoodbridge.com woodbri@swoodbridge.com
Sun, 29 Sep 2002 16:47:56 -0400
Hi all,

I have run into an interesting problem when I tried to move a working 
mapfile into maplab and suddenly a bunch of my layers vanished! I 
have tracked this down to what I think is causing the problem.

The mapfile was create when I was originally playing around with 
mapserver skins, which has been superseded by the legend_templates 
code. I have a bunch of related layers the all have the same name 
because I did not want lots of layers all label as Roads when they 
really is only one Road layer, but mapserver requires us to have 
multiple layers to style the roads differently at different zoom 
scales.

So we have GROUP to groups layers together, we have a bunch of LAYERs 
that belong to a GROUP and these can be a mix of spatial object and 
annotation object layers.

So it seems that because I use the same layer names for the layers 
that I want grouped the legend templates generates multiple entries 
in the html like

name="layer[]" value="highway"

and there is no what to differentiate from the multiple entries. I 
suppose I need to make the names unique, but I have not been able to 
figure out how to get groups to work.

So I am very confused now about how I HAVE to set these up in the map 
file and what I have to do to the legend_template.html file to get 
these to display.

I would appreciate some insight as to how to work around this 
problem.

Thanks,
  -Steve W.

I made the following change to my legend_template.html file to hide 
ANNOTATION layers from being displayed in the legend and it works 
great in the http://iMapTools.com/vmap0a demo

--------------------- legend_template.html -----------------
[leg_layer_html Opt_Flag=15]
[if name=layer_type oper=neq value=4]
<tr bgcolor="#FFFFFF">
  <td align="center">
    <input type="checkbox" name="layer_status[]" 
value="[leg_layer_name]" [if name=layer_status oper=eq 
value=1]CHECKED[/if][if name=layer_status oper=eq 
value=2]CHECKED[/if]>
  </td>
  <td><img src="[leg_icon height=10 width=20]" height=10 
width=20></td>
  <td><font face="Arial, Helvetica, sans-serif" size="2">[if 
name=layer_name oper=neq value=][leg_layer_name][/if][if 
name=layer_name value=]* Name Not Set*[/if]</font></td>
</tr>
[/if]
[if name=layer_type oper=eq value=4]
    <input type="hidden" name="layer_status[]" 
value="[leg_layer_name]">
[/if]
[/leg_layer_html]
------------ end of file ---------------

My mapfile contains the following layers for "highways"

  LAYER
    NAME "highways"
    STATUS ON
    #  TILEINDEX "tgrindex"
    #  DATA majroads
    TYPE LINE
    TILEINDEX "majrdtile"
    CLASSITEM "CLASS"
    MINSCALE 3000000
    MAXSCALE 9000000
    TOLERANCE 3
    HEADER "html/roads_header.html"
    FOOTER "html/roads_footer.html"
    TEMPLATE "html/roads.html"
    METADATA
      "DESCRIPTION"    "Major Roads"
      "RESULT_FIELDS"    "TLID NAME CFCC FRADDL TOADDL FRADDR TOADDR 
ZIPL ZIPR RTE_NUM"
    END
    CLASS
      NAME "Interstate"
      EXPRESSION /^I/
      SYMBOL "circle"
      COLOR 0 0 0
      SIZE 3
      OVERLAYSYMBOL "circle"
      OVERLAYCOLOR 244 0 0
      OVERLAYSIZE 1
    END
  END
  # highways
  LAYER
    NAME "highways"
    STATUS ON
    #  TILEINDEX "tgrindex"
    #  DATA majroads
    TYPE LINE
    TILEINDEX "majrdtile"
    CLASSITEM "CLASS"
    MINSCALE 275000
    MAXSCALE 2999999
    TOLERANCE 3
    HEADER "html/roads_header.html"
    FOOTER "html/roads_footer.html"
    TEMPLATE "html/roads.html"
    METADATA
      "DESCRIPTION"    "Major Roads"
      "RESULT_FIELDS"    "TLID NAME CFCC FRADDL TOADDL FRADDR TOADDR 
ZIPL ZIPR RTE_NUM"
    END
    CLASS
      NAME "US Hwy"
      EXPRESSION /^U/
      SYMBOL "circle"
      COLOR 0 0 0
      SIZE 3
      OVERLAYSYMBOL "circle"
      OVERLAYCOLOR 0 244 0
      OVERLAYSIZE 1
    END
    CLASS
      NAME "Interstate"
      EXPRESSION /^I/
      SYMBOL "circle"
      COLOR 0 0 0
      SIZE 3
      OVERLAYSYMBOL "circle"
      OVERLAYCOLOR 244 0 0
      OVERLAYSIZE 1
    END
  END
  # highways
  LAYER
    NAME "highways"
    STATUS ON
    DATA "majroads"
    TYPE LINE
    TILEINDEX "tgrindex"
    CLASSITEM "CLASS"
    MAXSCALE 274999
    TOLERANCE 3
    HEADER "html/roads_header.html"
    FOOTER "html/roads_footer.html"
    TEMPLATE "html/roads.html"
    METADATA
      "DESCRIPTION"    "Highways"
      "RESULT_FIELDS"    "TLID NAME CFCC FRADDL TOADDL FRADDR TOADDR 
ZIPL ZIPR RTE_NUM"
    END
    CLASS
      NAME "Interstate"
      EXPRESSION /^[IU]/
      SYMBOL "circle"
      COLOR 0 0 0
      SIZE 4
      OVERLAYSYMBOL "circle"
      OVERLAYCOLOR 244 0 0
      OVERLAYSIZE 2
    END
    CLASS
      NAME "Highways"
      EXPRESSION /^[SC]/
      SYMBOL "circle"
      COLOR 0 0 0
      SIZE 4
      OVERLAYSYMBOL "circle"
      OVERLAYCOLOR 0 244 0
      OVERLAYSIZE 2
    END
  END
  # highways
  LAYER
    NAME "highways"
    STATUS ON
    #  TILEINDEX "tgrindex"
    #  DATA majroads
    TYPE ANNOTATION
    TILEINDEX "majrdtile"
    CLASSITEM "CLASS"
    MINSCALE 3000000
    MAXSCALE 9000000
    LABELITEM "RTE_NUM"
    TEMPLATE "ttt.html"
    CLASS
      EXPRESSION /^I/
      # dummy color
      SYMBOL "interstate_shield"
      COLOR 0 0 0
      LABEL
        SIZE TINY
        POSITION CC
        #      MINFEATURESIZE 25
        MINDISTANCE 150
        MINFEATURESIZE AUTO
        COLOR 255 255 255
        PARTIALS FALSE
      END
    END
  END
  # highway annotation
  LAYER
    NAME "highways"
    STATUS ON
    #  TILEINDEX "tgrindex"
    #  DATA majroads
    TYPE ANNOTATION
    TILEINDEX "majrdtile"
    CLASSITEM "CLASS"
    MINSCALE 275000
    MAXSCALE 2999999
    LABELITEM "RTE_NUM"
    TEMPLATE "ttt.html"
    CLASS
      EXPRESSION /^U/
      # dummy color
      SYMBOL "us_highway_shield"
      COLOR 0 0 0
      LABEL
        SIZE TINY
        POSITION CC
        #      MINFEATURESIZE 25
        MINDISTANCE 150
        MINFEATURESIZE AUTO
        COLOR 0 0 0
        PARTIALS FALSE
      END
    END
    CLASS
      EXPRESSION /^I/
      # dummy color
      SYMBOL "interstate_shield"
      COLOR 0 0 0
      LABEL
        SIZE TINY
        POSITION CC
        #      MINFEATURESIZE 25
        MINDISTANCE 150
        MINFEATURESIZE AUTO
        COLOR 255 255 255
        PARTIALS FALSE
      END
    END
  END
  # highway annotation
  LAYER
    NAME "highways"
    STATUS ON
    DATA "majroads"
    TYPE ANNOTATION
    TILEINDEX "tgrindex"
    CLASSITEM "CLASS"
    MAXSCALE 274999
    LABELITEM "RTE_NUM"
    TEMPLATE "ttt.html"
    CLASS
      EXPRESSION /^I/
      # dummy color
      SYMBOL "interstate_shield"
      COLOR 0 0 0
      LABEL
        SIZE TINY
        POSITION CC
        #      MINFEATURESIZE 25
        MINDISTANCE 150
        COLOR 255 255 255
        PARTIALS FALSE
      END
    END
    CLASS
      EXPRESSION /^U/
      # dummy color
      SYMBOL "us_highway_shield"
      COLOR 0 0 0
      LABEL
        SIZE TINY
        POSITION CC
        #      MINFEATURESIZE 25
        MINDISTANCE 150
        COLOR 0 0 0
        PARTIALS FALSE
      END
    END
    CLASS
      EXPRESSION /^S/
      # dummy color
      SYMBOL "rect"
      COLOR 255 205 205
      OUTLINECOLOR 0 0 0
      SIZE 18
      LABEL
        SIZE TINY
        POSITION CC
        OFFSET 0 3
        #      MINFEATURESIZE 25
        MINDISTANCE 150
        COLOR 0 0 0
        PARTIALS FALSE
      END
    END
    CLASS
      EXPRESSION /^C/
      # dummy color
      SYMBOL "rect"
      COLOR 255 255 255
      OUTLINECOLOR 0 0 0
      SIZE 18
      LABEL
        SIZE TINY
        POSITION CC
        OFFSET 0 3
        #      MINFEATURESIZE 25
        MINDISTANCE 150
        COLOR 0 0 0
        PARTIALS FALSE
      END
    END
  END
  # highway annotation


And at SCALE 1:7784738 which falls into the 3-9 Mil scale range above 
the html for the highway legend items looks like this:

    <input type="hidden" name="layer_status[]" value="highways">

    <input type="hidden" name="layer_status[]" value="highways">

    <input type="hidden" name="layer_status[]" value="highways">

<tr bgcolor="#FFFFFF">
  <td align="center">
    <input type="checkbox" name="layer_status[]" value="highways" >
  </td>
  <td><img src="/web2/tmp/1033328613_22_0_20_10.gif" height=10 
width=20></td>
  <td><font face="Arial, Helvetica, sans-serif" 
size="2">highways</font></td>
</tr>

<tr bgcolor="#FFFFFF">
  <td align="center">
    <input type="checkbox" name="layer_status[]" value="highways" >
  </td>
  <td><img src="/web2/tmp/1033328613_21_0_20_10.gif" height=10 
width=20></td>
  <td><font face="Arial, Helvetica, sans-serif" 
size="2">highways</font></td>
</tr>

<tr bgcolor="#FFFFFF">
  <td align="center">
    <input type="checkbox" name="layer_status[]" value="highways" 
CHECKED>
  </td>
  <td><img src="/web2/tmp/1033328613_20_0_20_10.gif" height=10 
width=20></td>
  <td><font face="Arial, Helvetica, sans-serif" 
size="2">highways</font></td>
</tr>







This archive was generated by Pipermail.