[Chameleon] javascript to turn on a layer

Delfos, Jacob jacob.delfos at maunsell.com
Tue Mar 14 18:31:58 EST 2006


Jojin,
 
Have you tried implementing the script? If it didn't work, did you get
any javascript errors?
 
By the way, the script you pasted below isn't exactly what I gave you,
but I think Julien has pointed out the typos. Note that you have
actually changed the script to turn the aerial layer on, rather than
turn all the other layers off (which is what you initially said you
wanted to do). You  can change this behaviour using the != operator, and
set layer checked to 'false'.

Regards,

Jacob


________________________________

	From: chameleon-bounces at lists.maptools.org
[mailto:chameleon-bounces at lists.maptools.org] On Behalf Of JR Santillan
	Sent: 14 March 2006 19:01
	To: Chameleon
	Subject: [Chameleon] javascript to turn on a layer
	
	
	Hello all.
	
	I am trying to use javascript to turn on a layer (an aerial
photograph) but its not working. Jacob Delfos gave a rough draft of the
script and i experimented on it. (I am not knowlegdeable in Javascript.)
	
	In the map file, the layer name for the aerial photograph is
"Aerial".
	
	Here's the script:
	
	            <a href="javascript:becomeAerial()">Go to aerial
mode</a>
	
	            <script>
	            function becomeAerial()
	            {
	                
	
for(i=0;i<document.form[0].legendlayername[].length;i++)
	                    {
	
if(document.form[0].legendlayername[i].value!="Aerial")
	                            {
	
document.form[0].legendlayername[i].checked=true;
	                            }
	                    }
	                document.form[0].submit();
	            }
	            </script>
	
	
	and the Legend Layer Template is:
	
	
	[leg_layer_html order=ascending opt_flag=15]
	  <tr bgcolor="#ffffff">
	    <td><input type="radio" name="my_legend"
onclick="CWCSelectLayer('[leg_layer_name]', true)"[if name=selected
value=1] CHECKED[/if] ></td>
	    <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="20"</td>
	    [if name=wms_name oper=isnull]
	    <td><a href="#"
onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
class="label">[leg_layer_name]</span></a></td>
	  </tr>
	    [/if]
	    [if name=wms_name oper=isset]
	    <td><a href="#"
onclick="javascript:LegendTemplateLayerInfo('[leg_layer_name]');"><span
class="label">[metadata name=WMS_TITLE]</span></a></td>
	  </tr>
	    [/if]
	[/leg_layer_html]
	
	
	
	---
	
	I hope somebody could help. Thanks.
	
	
	Jojin
	

	________________________________

	Brings words and photos together (easily) with
	PhotoMail
<http://us.rd.yahoo.com/mail_us/taglines/PMall/*http://photomail.mail.ya
hoo.com> - it's free and works with Yahoo! Mail.




More information about the Chameleon mailing list