[Chameleon] HTML Legend with Javascript

Robin Brown rbrown at unb.ca
Fri Oct 1 13:46:10 EDT 2004


Paul,

I have made all the changes you indicated but I still have the refresh problem.  The
code creates an expanding/collapsing legend but with any zoom/update etc, all folders
go back to the starting state of closed.

Am I missing something?  Should my legend still have all divisions with
style="display:'none'"? or should I be checking for something?

Robin


Quoting Paul Spencer <pagameba at magma.ca>:

> Warning: This message has had one or more attachments removed
> Warning: (jsExpander.js).
> Warning: Please read the "VirusWarning.txt" attachment(s) for more information.
> 
> Robin,
> 
> this gets a little more complicated ... I've extracted the code into a 
> separate js and css file (attached).
> 
> You can remove the cExpander related javascript and <style> sections in 
> your application template and add the following:
> 
> <script language="JavaScript" src="jsExpander.js"></script>
> <link href="jsExpander.css" rel="stylesheet" type="text/css">
> 
> Your legend template is slightly modified, in the group section add:
> 
> //this is the existing line
> oGroup = new cExpander( CWCDHTML_GetLayer( '[leg_group_name]', true ));
> //this is the new line
> goExpanderManager.add( oGroup );
> 
> in your application template, you will also need to add:
> 
> <input type="hidden" name="ExpanderStatus" value="[$ExpanderStatus|$]">
> 
> and right after the legend template widget you will need to add:
> 
>    <cwc2 type="LegendTemplate" visible="true" embedded="true" 
> template="fancy_legend.html" popupstyleresource="TextButtons" 
> popupwidth="500" popupheight="400" status="false" menubar="false"/>
> 
> <script language="JavaScript" type="text/javascript">
> goExpanderManager.formElement = document.forms[0].ExpanderStatus;
> goExpanderManager.initialize();
> </script>
> 
> Cheers,
> 
> Paul
> 
> Robin Brown wrote:
> > Paul,
> > 
> > Nope, not working:)  I quickly gave up as I would need too many variables to get
> > everything running smoothly and as you suggested, this would cause problems in the
> > future.  I am now using the code you so kindly provided.  I am having trouble with
> the
> > refresh problem.  Is it possible to change the legend template file from the
> chameleon
> > template where I have the script?  I tried to check the value of
> > this.element.style.display in my legend template and use this value but I get an
> error.
> >  I think it is because on the initial render, these values would not be set yet? 
> I'm
> > not entirely sure it is even possible to do this.  Sorry to be asking so many
> > questions.  I am new to all of this and have been struggling with the legend for
> the
> > last 2+ weeks.  Also, is it ok for me to put this up on the wiki after I get it
> > functioning properly?  It is really your code but if you don't mind, I would like
> to do
> > anything I can to help new users as there is not much out there on creating
> dynamic
> > legends.  Thanks again for all your help.
> > 
> > Robin
> > 
> > 
> > Quoting Paul Spencer <pagameba at magma.ca>:
> > 
> > 
> >>let me know if you get it working ... I did try a solution that used 
> >>metadata in the map file but I generally avoid that as changes to the 
> >>map file can break things if you are not very careful about keeping all 
> >>the metadata synchronized etc.
> >>
> >>Robin Brown wrote:
> >>
> >>>Paul,
> >>>
> >>>Wow, thanks.  This looks very complicated.  I would not have been able to do this
> >>
> >>on my
> >>
> >>>own!  I think though that I am going to try something else first:)  I was looking
> >>
> >>at
> >>
> >>>the wiki for HTML legends and I saw that you can set wms variables and check them
> >>
> >>in
> >>
> >>>the legend template.  I thought for each layer I can specify if it has classes or
> >>
> >>not. 
> >>
> >>>If it does, I will start a new division and end that division in the
> >>
> >>[leg_class_html]
> >>
> >>>section.  If the layer doesn't have classes, I won't bother starting a new
> >>
> >>division. 
> >>
> >>>That way I don't have to worry about closing for those that had no classes.  Does
> >>
> >>this
> >>
> >>>make sense?  I think it will be something like this:
> >>>
> >>>
> >>
> >>-- 
> >>  -----------------------------------------------------------------
> >>|Paul Spencer                           pspencer at dmsolutions.ca   |
> >>|-----------------------------------------------------------------|
> >>|Applications & Software Development                              |
> >>|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
> >>  -----------------------------------------------------------------
> >>
> >>
> > 
> > 
> > 
> 
> -- 
>   -----------------------------------------------------------------
> |Paul Spencer                           pspencer at dmsolutions.ca   |
> |-----------------------------------------------------------------|
> |Applications & Software Development                              |
> |DM Solutions Group Inc                 http://www.dmsolutions.ca/|
>   -----------------------------------------------------------------
> 


-- 
NB Aquatic Data Warehouse
Canadian Rivers Institute
University of New Brunswick
Hugh John Fleming Forestry Complex
Sir James Dunn Wildlife Research Center
Room 263
1350 Regent Street
Fredericton, NB
E3C 2G6

Phone:    (506) 458-7557
Email:     rbrown at unb.ca


More information about the Chameleon mailing list