Legends not updating?
Peter Kingsbury
peter.kingsbury at GMAIL.COM
Thu Sep 1 08:22:38 PDT 2005
Thanks for your reply!
I have found a way to enable the legend the way I want, only showing
metadata-including layers. I've also modified the LegendTemplate widget
(set ControlVisibility="true"). So far everything seems fine.
Now the issue exists where the layers will disappear after updating the
map! The first click results in the proper "on" layer being hidden, but
any non-default layers are hidden. A following update to the map will
remove all layers except those controlled by the legend. Strange!
The "always on" rivers layer which stays put after the first Update, but
disappears after subsequent updates, and a normal initially-invisible
layer which the legend controls just fine:
#----------------------------------
LAYER
GROUP "Base Layers"
NAME "Rivers"
TYPE POLYGON
DATA rivers
STATUS DEFAULT
CLASS
NAME "Rivers"
COLOR 48 100 230
OUTLINECOLOR 64 128 255
END
METADATA
SHOWINLEGEND "no"
END
END
LAYER
GROUP "Sites"
NAME "Sites"
TYPE POINT
DATA sites
TOLERANCE 6
STATUS OFF
HEADER '../query/query_header.html'
FOOTER '../query/query_footer.html'
MAXSCALE 30000
METADATA
SHOWINLEGEND "yes"
END
CLASSITEM "sites"
LABELITEM "sites"
END
#----------------------------------
The legend template layer section:
[leg_layer_html order_metadata=legend_order opt_flag=15]
[if name=SHOWINLEGEND oper=eq value="yes"]
<tr bgcolor="#ffffff">
<td align="center" width=20>
<input type="checkbox" name="legendlayername[]"
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 width=20 height=18]" width="20"
height="18">
</td>
<td>
<span class="label">[leg_layer_name]</span>
</td>
</tr>
[/if]
[/leg_layer_html]
And finally, the LegendTemplate widget:
<cwc2
type="LegendTemplate"
visible="true"
embedded="true"
template="legend_template.html"
popupstyleresource="TextButtons"
popupwidth="500"
popupheight="400"
status="false"
menubar="false"
/>
Is this a circular catch-22 problem? Is there a way around this behavior?
Best regards,
- Peter
Ken Boss wrote:
>Peter--
>
>It's been awhile since I've thought about this (so take the advice with some salt), but my approach to the checkbox portion of html legends has been more along these lines:
>
> <input type="radio" name="[leg_layer_name]"
> [if name=layer_status oper=neq value=0]
> CHECKED
> [/if]
> >
>
>HTH,
>
>--Ken
>
>
>
>
>>>>Peter Kingsbury <peter.kingsbury at GMAIL.COM> 8/31/2005 2:39:56 PM >>>
>>>>
>>>>
>Hello all,
>
>Grief once again with my legends.
>
>The symptom is that, if the Layer status in the .MAP file is set to OFF,
>the layer doesn't show up ... if set to ON, it shows up. This behavior
>so far is normal.
>
>However, when checking/unchecking layers from the LegendTemplate widget,
>then clicking Update, the page refreshes, and all layers listed in the
>LegendTemplate become unchecked!
>
>I've gone through the documentation numerous times, and I am unable to
>find anything that might be wrong with the code. I've also used the
>sample legend template HTML code, which results in much the same
>behavior. Not sure where to look at this point. Going to give it a go
>again tomorrow.
>
>I've included the legend_template.html and widget code below.
>
>Any insight is appreciated!
>
>Best regards,
>- Peter
>
>
>
>---- legend_template.html ----
>[leg_group_html]
> <tr>
> <td colspan=3 bgcolor=#cccccc><b>[leg_group_name]</b></td>
> </tr>
>[/leg_group_html]
>
>[leg_layer_html order_metadata=legend_order opt_flag=15]
> <tr>
> <td>
> <input type=checkbox name=layer_status value=
> [if name=layer_status oper=eq value=1]on[/if]
> [if name=layer_status oper=eq value=0]off[/if]>
> </td>
> <td>
> <img src="[leg_icon width=20 height=18]" width="20" height="18">
> </td>
> <td>
> <span class="label">
> [leg_layer_name]
> </span>
> </td>
> </tr >
>[/leg_layer_html]
>---- end legend_template.html ----
>
>---- chameleon widget ----
> <cwc2
> type="LegendTemplate"
> visible="true"
> embedded="true"
> template="legend_template.html"
> popupstyleresource="TextButtons"
> popupwidth="500"
> popupheight="400"
> status="false"
> menubar="false"
> controlvisibility="false"
> />
>---- end chameleon widget ----
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20050901/7633f6f2/attachment.htm>
More information about the MapServer-users
mailing list