<DIV>Hi Paul,</DIV>
<DIV> </DIV>
<DIV>It works !!! </DIV>
<DIV> </DIV>
<DIV>I needed to create a metadata for each layer to retrieve group name </DIV>
<DIV>and i changed the checkbox for the layer like this</DIV>
<DIV>id="layer-[metadata name=group]-[metadata name=layer_index]"</DIV>
<DIV> </DIV>
<DIV>Thank you !!!</DIV>
<DIV><BR><B><I>Paul Spencer <pspencer@dmsolutions.ca></I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Edith,<BR><BR>I would tackle this by doing the following:<BR><BR>1. add metadata to each of your layers called layer_index and make it <BR>sequential 0 - nLayers<BR><BR>2. build your legend template file like this:<BR><BR>[leg_group_html]<BR><INPUT type=checkbox onchange="toogleGroup( this <br>)" name=[leg_group_name]>[leg_group_name]<BR><BR>[/leg_group_html]<BR>[leg_layer_html]<BR><INPUT id="layer_[layer_group]_[metadata <br>name=layer_index]" type=checkbox value=[leg_layer_name] name=legendlayername[] <br>onclick='toggleLayer( this )'>[leg_layer_name]<BR><BR>[/leg_layer_html]<BR><BR><BR>3. add a couple of javascript functions to your template<BR><BR>function toggleGroup( obj )<BR>{<BR>var nLayers = 20; //set to number of layers in map file<BR>for(i=0; i<NLAYERS; i++)<br> {<BR>var layer_cb = document.getElementById( 'layer_'+obj.name+'_'+i );<BR>if (layer_cb)<BR>layer_cb.checked =
obj.checked;<BR>}<BR>}<BR><BR>function toggleLayer( obj )<BR>{<BR>var group = (obj.id.split( "_" ))[1];<BR>var group_cb = document.getElementById( group );<BR>//case 1: unchecked layer, can uncheck the group<BR>if (group_cb)<BR>{<BR>if (!obj.checked)<BR>{<BR>group_cb.checked = false;<BR>return;<BR>}<BR>else // now have to check all the layers in this group<BR>{<BR>var nLayers = 20; //set to number of layers in map file<BR>for(i=0; i<NLAYERS; i++)<br> {<BR>layer_cb = document.getElementById( 'layer_'group+'_'+i );<BR>if (cb && !cb.checked) //stop if any are unchecked<BR>{<BR>group_cb.checked = false;<BR>return;<BR>}<BR>}<BR>group_cb.checked = true; //all checked, can turn on group<BR>}<BR>}<BR>}<BR><BR>Note this code is extremely rough and completely untested. Good Luck!!!<BR><BR>Cheers<BR><BR>Paul<BR><BR>Edith TAKI wrote:<BR>> Hi,<BR>> <BR>> Thank you Ferencik for your solution but you don"t need to <BR>> select/unselect layers in a group for your solution
...<BR>> <BR>> My legend is generated dynamicaly with mapfile and legend_template and <BR>> look like that<BR>> <BR>> <BR>> Group 1<BR>> <BR>> * layer 1<BR>> * layer 2<BR>> * layer 3<BR>> <BR>> Group 2<BR>> <BR>> * layer1<BR>> * layer2<BR>> <BR>> <BR>> and i have a checkbox for each line ; those for layers are coded like that :<BR>> <BR>> <INPUT type=checkbox name=legendlayername[] <br>> value="[leg_layer_name]"<BR>> [if name=layer_status oper=eq value=1]CHECKED[/if]<BR>> [if name=layer_status oper=eq value=2]CHECKED[/if]><BR>> <BR>> </SPAN><BR>> <BR>> what i need now is to code the group so that a click on a group could <BR>> check ou uncheck the layers depending.<BR>> <BR>> For map refreshing, I used CWCJSAPI and i just solve the problem of <BR>> navigation buttons like zoomin zoomout, they no longer refresh all the page;<BR>> Only Update button need now to reload the page but I have
no idea for <BR>> Javascript so it'll be difficult !!<BR>> <BR>> Thank you for your help<BR>> <BR>> */Jano Ferencik <FERENCIK.IOAN@PERSONAL.RO>/* wrote:<BR>> <BR>> Hi Edith<BR>> <BR>> the situation is like this..I created a javascript treemenu wich I<BR>> am attaching<BR>> to this email as a zip archive....you can modify and use it<BR>> ....but....there are<BR>> 2 things..<BR>> 1 as long as The update Map widget refreshes the page You can do<BR>> nothing about<BR>> it... the menu will allways refresh and appear like on first<BR>> load...you could<BR>> solve this by creating some javascript handling some events...wich<BR>> will keep the<BR>> opened group open after refreshing....the script should use the :active<BR>> pseudoclass of group(wich in this case must be links)...(this is<BR>> only an advice<BR>> )...I though one tome to do it but could take me a loomng time as my<BR>> javascript<BR>> skills are only
basic<BR>> <BR>> In my case I have another problem...I fave a huge number of layers<BR>> in may<BR>> Chameleon application(about 50) and I created a legend on multiple<BR>> levels...it<BR>> is refreshing i! tself on Update Map and second I think that the<BR>> number of layers<BR>> conducted to decreasing of speed when loading the map....<BR>> A possibble solution could be the new Ka-Map project from DM<BR>> solutions(ie. the<BR>> map doesn't refresh itslelf on the basic actions like panning or<BR>> zooming or<BR>> layer controls).....but you will have to wait for the application<BR>> Ka-map to be<BR>> released....i think it will happen soon(ask Paul Spencer about this) :))<BR>> <BR>> Regards<BR>> <BR>> <BR>> > Hi list,<BR>> ><BR>> > I have a problem similar to jstreeview ; I developped<BR>> legendTemplate to show<BR>> at page load only groups so the user could developp a group by<BR>> clicking its
id<BR>> to show the layers in the group ; I have two problems :<BR>> > 1 - using Javascript to hide / show layers for each group.<BR>> > I think Jano Ferencik (who first posted about Jstreeview) succeed<BR>> doing<BR>> > this ; could you help me ?<BR>> > 2 - I have the same problem after Update, the page looks like on<BR>> the fisrt<BR>> > l! oading and user loose his environnment, only groups are visible.<BR>> ><BR>> > can somebody have any suggestions ?<BR>> ><BR>> > Thanks<BR>> ><BR>> ><BR>> ><BR>> ><BR>> > ---------------------------------<BR>> > Post your free ad now! Yahoo! Canada Personals<BR>> ><BR>> <BR>> <BR>> <BR>> <BR>> <BR>> ___________________________<BR>> Cv-ul tau ia 500 euro/luna!<BR>> http://500.myjob.ro<BR>> <BR>> <BR>> ------------------------------------------------------------------------<BR>> Post your free ad now!
*Yahoo! Canada Personals* <BR>> <HTTP: ca.personals.yahoo.com /><BR>> <BR>> <BR>> ------------------------------------------------------------------------<BR>> <BR>> <BR>> <!-- LEGEND--><BR>> [leg_group_html]<BR>> </BLOCKQUOTE><BR>>
<DIV id=[leg_group_name]><BR>> <BR>>
<DIV class=groupLabel><BR>> <BR>> <INPUT type=checkbox name=legendgroupname[] <br>> value="[leg_group_name]"<BR>> [if name=layer_status oper=eq value=1]CHECKED[/if]<BR>> [if name=layer_status oper=eq value=2]CHECKED[/if]<BR>> onclick="checkAll();"><BR>> <BR>> <A onclick="toggleLayer('[leg_group_name]_layer');" href="javascript:void(0);">[leg_group_name] </A><BR>> </DIV><!-- GroupLabel--><BR>> <BR>> </DIV><BR>>
<DIV id=[leg_group_name]_layer style="DISPLAY: none"><BR>> [/leg_group_html]<BR>> <BR>> [leg_layer_html order=ascending opt_flag=15]<BR>> <BR>>
<DIV><BR>> [if name=SHOWINLEGEND oper=isnull]<BR>> <SPAN class=layerTitle><BR>> <INPUT type=checkbox name=legendlayername[] <br>> value="[leg_layer_name]"<BR>> [if name=layer_status oper=eq value=1]CHECKED[/if]<BR>> [if name=layer_status oper=eq value=2]CHECKED[/if]><BR>> <BR>> </SPAN><BR>> <BR>> <SPAN><BR>> <IMG src="http://ca.f611.mail.yahoo.com/ym/[leg_icon]"><BR>> </SPAN><BR>> <BR>> <BR>> [if name=wms_title oper=isnull]<BR>> <SPAN class=layerLabel>[leg_layer_name] </SPAN><BR>> [/if]<BR>> <BR>> [if name=wms_title oper=isset]<BR>> <SPAN class=layerLabel>[metadata name=WMS_TITLE] </SPAN><BR>> [/if]<BR>> <BR>> <BR>> [/if]<BR>> <BR>> [if name=SHOWINLEGEND oper=isset]<BR>> <INPUT type=hidden value=[leg_layer_name] name=legendlayername[]><BR>> [/if]<BR>> </DIV><BR>> [/leg_layer_html]<BR>> <BR>>
<SCRIPT language=javascript><br>> <br>> function checkAll()<br>> {<br>> <br>> }<br>> <br>> </SCRIPT>
<BR>> <BR>> <BR>> ------------------------------------------------------------------------<BR>> <BR>> _______________________________________________<BR>> Chameleon mailing list<BR>> Chameleon@lists.maptools.org<BR>> http://lists.maptools.org/mailman/listinfo/chameleon<BR><BR>-- <BR>+-----------------------------------------------------------------+<BR>|Paul Spencer pspencer@dmsolutions.ca |<BR>+-----------------------------------------------------------------+<BR>|Applications & Software Development |<BR>|DM Solutions Group Inc http://www.dmsolutions.ca/|<BR>+-----------------------------------------------------------------+<BR>
<BLOCKQUOTE></BLOCKQUOTE></DIV><p><br><hr size=1>Post your free ad now! <a href="http://ca.personals.yahoo.com/"><b>Yahoo! Canada Personals</b></a><br>