Technicality
· 10TH OF AUGUST, THE YEAR 2005HIDDEN ANNOTATION LAYERS IN CHAMELEON
A little while ago I was trying to get a roads layer to show up in the Chameleon legend but not its corresponding annotation layer. Someone mentioned if I just gave the layers the same name but hid one using a different group and conditional statements in my html legend file, the two layers would turn on and off together, but only the “visible” layer would show up in the legend. This apparently worked at the the time, but didn’t today, possibly due to a Chameleon upgrade, more likely due to my own muching around.
My ugly fix: make the hidden form elements for the hidden layers type ‘checkbox’ instead of ‘hidden’, given them an ID using the leg_layer_name, and just add an onClick to the visible layer’s input that calls a function that toggles the hidden checkbox.
Legend Template:
[leg_layer_html opt_flag=15]
[if name=layer_group oper=neq value=hidden]
[if name=MetadataURL oper=isnull][leg_layer_name][/if]
[/if]
[if name=layer_group oper=eq value=hidden]
[if name=layer_status oper=neq value=0]
[/if]
JavaScript:
function mb_toggle_hidden_input( layer_name ) {
if( inp = document.getElementById( 'leg_hidden_'+layer_name ) ) {
inp.click();
}
}
CSS:
.mb_hidden_input {
visibility: hidden;
}

NO COMMENTS YET