«»

Technicality

· 7TH OF JUNE, THE YEAR 2005

CHAMELEON: LEGENDTEMPLATE ISSUES

Chameleon’s LegendTemplate widget has weird issues with groups. If you use groups and some of your layers aren’t in groups, Chameleon won’t display them after zooming or updating the map in any way. I was trying to use ungrouped layers to hide them from the legend. The solution from the list was to create a separate group and metadata for hidden layers and use [if] clauses in the legend template. Mapfile looks like this:


LAYER
NAME "Water"
GROUP "hidden"
METADATA
"legendvis" "hidden"
END
STATUS ON
DATA "/path/to/data"
TYPE POLYGON
CLASS
STYLE
COLOR 153 204 255
END
END
END

and now my legend template looks like this:


[leg_group_html order=ascending opt_flag=15]
[if name=legendvis oper=isnull]

[leg_group_name]

[/if]
[/leg_group_html]

[leg_layer_html opt_flag=15]
[if name=layer_group oper=neq value=hidden]

[/if]
[if name=layer_group oper=eq value=hidden]
[if name=layer_status oper=neq value=0]

[/if]
[/if]

[/leg_layer_html]

[leg_class_html]

[/leg_class_html]

Note that even hidden layers need to have a form input name legendlayername[], otherwise Chameleon will overlook it.

Another annoying issue was that if you had a separate annotation layer for highway labels, you’d get a legend listing for the data layer and the annotation layer. Again, list to the rescue: layers with the same name are turned on and off together, so if you hide one of them, it will turn on and off with the remaining visible one.

NO COMMENTS YET

LEAVE A COMMENT

name=layer_status oper=eq value=2]CHECKED[/if]> [if name=MetadataURL oper=isset][leg_layer_name][/if]
[if name=MetadataURL oper=isnull][leg_layer_name][/if]
  [leg_class_name]
(required)
(required)