Opened 22 years ago

Closed 22 years ago

Last modified 22 years ago

#114 closed defect (fixed)

mode=legend returns ALL layers no matter what

Reported by: jdoyon@… Owned by: sfournier@…
Priority: high Milestone:
Component: MapServer C Library Version: 3.6
Severity: critical Keywords:
Cc:

Description

Hello,

When I use the mode=legend request, the HTML legend I get back has ALL layers 
turned on, regardless of what map extent I provide it.

I switched it to the gif legend to see if it was a ;arger problem, but the gif 
legend returned had only the appropriate layers turned on ... So this problem 
is specific to the HTML Legend.

I'm using a request like:

/cgi-bin/mapserv?
map=/home/mapdata/aoc_v3/english/25102.map&imgext=1108557.943775+-
527851.211669+1900362.600025+175152.922385&mode=legend

Thanks,
J.F.

Attachments (2)

legend.html (687 bytes ) - added by jdoyon@… 22 years ago.
My legend template
92.map (18.2 KB ) - added by jdoyon@… 22 years ago.
One of the mapfiles I'm using

Download all attachments as: .zip

Change History (17)

comment:1 by jdoyon@…, 22 years ago

OK I've noticed that it only uses the defaults from the mapfile as well.  I 
tried using an optflag=15, and it had no effect, I'm not seeing ALL layers.  I 
also added a checbox feature, and the layers that should be checked aren't 
which means that layer_status isn't set right or something ....

comment:2 by dmorissette, 22 years ago

Cc: morissette@… added
Owner: changed from morissette@… to sfournier@…

comment:3 by sfournier@…, 22 years ago

JF,

Did you try to set all your layers (in map file) to "ON" without the optflag 
set ?

Also, can you forward me your template ? I'll take a look. Thanks

Sacha

comment:4 by jdoyon@…, 22 years ago

Hmmmm no, and I'd rather not change my mapfiles ... The layers are either "off" 
or "default" ... And the layers allways displayed in the legend are the ones 
set to default ... And even then when I use a checkbox next to a "default" 
layer, it doesn't appear checked as it should (Although of course doing so 
makes no real sense, but it's a good test).  I could try setting them to "on", 
and maybe I will, but I'm worried this might get confusing in the future for 
our content developpers, having layers "on" that aren't .. a strange MapServer 
behavior I'd really like to see change :) In the mean time, find some attached 
files.

by jdoyon@…, 22 years ago

Attachment: legend.html added

My legend template

by jdoyon@…, 22 years ago

Attachment: 92.map added

One of the mapfiles I'm using

comment:5 by jdoyon@…, 22 years ago

OK, I tried setting to "ON" and it still doesn't show up, in the example 
mapfile here I have four layers I want to control via a checkbox, look for the 
keywords "single" "divorced" and there's 2 others ... I tried setting single to 
on, but in this example, the legend STILL insists on only returning "default" 
layers, but NOT the ones that are "on" or "off", even with optflag=15 ...

comment:6 by jdoyon@…, 22 years ago

Sorry just an addition/clarification: it shows ALL default layers, regardless 
of the scale also. So in some cases we have 3 layers that "follow" each other 
in the range of scales, but all 3 show up in the legend, at ALL scales.  Look 
at the "Water" layers for example.

comment:7 by sfournier@…, 22 years ago

Resolution: fixed
Status: newclosed
Ok fixed. For some reason, extends was'not adjusted when generating legend 
template.

comment:8 by jdoyon@…, 22 years ago

Resolution: fixed
Status: closedreopened
OK, it works much better now! I'm still having a problem with the fact that 
checkboxes don't appeared checked, that is an "if" statement on layer_status 
doesn't seem to work. Here's the exceprt of my legend template:

[if name=checkable value=1]
<td><input type="checkbox" name="layer" value="[leg_layer_name]" [if 
name=layer_status value=1]checked[/if]></td>
[/if]

Thanks,
J.F.

comment:9 by sfournier@…, 22 years ago

Does your layers status in your map file are set to default ? If so, the if statement  
return allways false if you expect value "1" (on) cause default is "2".

If it is not the probleme, please send me your map file.

Sacha

comment:10 by dmorissette, 22 years ago

If it's a DEFAULT STATUS thing, then you could try the following to emulate the 
behavior of an 'or' logical operator:

[if name=checkable value=1]
<td><input type="checkbox" name="layer" value="[leg_layer_name]" [if 
name=layer_status value=1]checked[/if][if 
name=layer_status value=2]checked[/if]></td>
[/if]

comment:11 by jdoyon@…, 22 years ago

indeed, my mistake, sorry, got that fixed, noticed something else though ... 
turns out I had optflag=15 on, which means ALL layers should've been showing, 
right ? Well no, instead it's behaving as if optflag is unset (default bahvior 
of showing only layers that are actually drawn on the map and with legend order 
NOT negative).

FYI, the ultimate goal is to have a group of layers (the ones that are 
marked "checkable") ALLWAYS appear in the legend, with the classes appearing 
only for the layer actually turned on. I should be able to achieve this with 
nested if's and using the optflag on the classes and the such I'm hoping, but I 
need the optflag to work :)

Thanks,
J.F.

comment:12 by sfournier@…, 22 years ago

I'm asking, just in case: Are you using optflag or opt_flag ? The good is "opt_flag".

comment:13 by jdoyon@…, 22 years ago

oops again on my part :) OK, now that works better :)

Yes another one:

I have maps that have all thematic content off by default, and then layers are 
turned on and off via the url (obvisouly, that's why I wanted the checkboxes :)

the problem is that when I turn on a layer via the url, it turns on in the map, 
but not in the legend ... no checkboxes, no classes ... and I checkd I have 
both status 1 and 2 tested in the legend template :)

I'm guessing the "hook" happens to early in the map drawing stage or something?

Thanks,
J.F.

comment:14 by sfournier@…, 22 years ago

I'm uanble to reproduce the problem. Can you send me your template file and 
map file please.

Sacha

comment:15 by jdoyon@…, 22 years ago

Resolution: fixed
Status: reopenedclosed
never mind! I figured out the problem, it was on my end ... Sorry about all 
this, the pressure is starting to get to me :)

Closing ...
Note: See TracTickets for help on using tickets.