<div dir="ltr"><div class="gmail_quote"><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,</div><div>I'm using 5 layers and passing random values to VIEWPARAMS to select the wanted area. I added a layer switcher(mentioned in red at the bottom of the script) to show/hide layers. but switch layer component doesn't appear on openlayers map viewer. Please be kind to respond. need help.</div>






<div><br></div><div>Regards.</div><div><br></div><div><font color="#274e13"><script src="wms_files/OpenLayers.js" type="text/javascript"></script></font></div><font color="#274e13"><script defer="defer" type="text/javascript"><br>






var legs = "<%= geoParam %>";<br>var layer_one_legs = "<%= geoParamLayerOne %>";<br>var layer_two_legs = "<%= geoParamLayerTwo %>";<br>var layer_three_legs = "<%= geoParamLayerThree %>";<br>






var layer_four_legs = "<%= geoParamLayerFour %>";<br>var layer_four_five = "<%= geoParamLayerFive %>";<br><br></font><div><font color="#274e13">var map;<br>var base;<br><br></font></div><div>






<font color="#274e13">var layer_one;<br>var layer_two;<br>var layer_three;<br>var layer_four;<br>var layer_five;<br><br></font></div><div><font color="#274e13">/* pink tile avoidance */<br>OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;<br>






/* make OL compute scale according to WMS spec */<br>OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;</font><div><font color="#274e13"><br></font></div><font color="#274e13">function init() {<br><br>format = 'image/png';</font><div>






<span style="white-space:pre-wrap"><font color="#274e13">                                                               </font></span></div><font color="#274e13">var bounds = new OpenLayers.Bounds(<br>                    97057.023,<br>                    174768.406,<br>                    118472.391,<br>






                    192859.141);<br>var options = {<br>                    controls : [],<br>                    maxExtent : bounds,<br>                    maxResolution : 83.65378125000001,<br>                    projection : "EPSG:2020",<br>






                    units : 'm'<br>};</font><div><font color="#274e13"><span style="white-space:pre-wrap">    </span>map = new OpenLayers.Map('map', options);</font></div><div><span style="white-space:pre-wrap"><font color="#274e13">                                                                                                             </font></span></div>






<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:40px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-width:initial;border-color:initial;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">






<font color="#274e13">/* setup base layer */<br>base = new OpenLayers.Layer.WMS(<br>"Base",<br>"<a href="http://localhost:8080/geoserver/wms" target="_blank">http://localhost:8080/geoserver/wms</a>",<br>




{<br>LAYERS : 'rda2',<br>

transparent: "true",<br>singleTile: true,<br>format : format<br>},<br>{<br>buffer : 0,<br>isBaseLayer : true,<br>displayInLayerSwitcher:false<br>});</font></blockquote><div><span style="white-space:pre-wrap"><font color="#274e13">                                                                                                              </font></span></div>






<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:40px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-width:initial;border-color:initial;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">






<font color="#274e13">/* setup layer_one */<br>layer_one = new OpenLayers.Layer.WMS(<br>"Layer 01",<br>"<a href="http://localhost:8080/geoserver/wms" target="_blank">http://localhost:8080/geoserver/wms</a>",<br>




{<br>
VIEWPARAMS: layer_one_legs,<br>
LAYERS : 'RDA2_VIEW_LAYER_ONE',<br>transparent: "true",<br>singleTile: true,<br>format : format<br>},<br>{<br>buffer : 0,<br>isBaseLayer : false,<br>displayInLayerSwitcher:true<br>});</font></blockquote>






<div><span style="white-space:pre-wrap"><font color="#274e13">                                                                                                            </font></span></div><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:40px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-width:initial;border-color:initial;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">






<font color="#274e13">/* setup layer_two */<br>layer_two = new OpenLayers.Layer.WMS(<br>"Layer 02",<br>"<a href="http://localhost:8080/geoserver/wms" target="_blank">http://localhost:8080/geoserver/wms</a>",<br>




{<br>
VIEWPARAMS: layer_two_legs,<br>
LAYERS : 'RDA2_VIEW_LAYER_TWO',<br>transparent: "true",<br>singleTile: true,<br>format : format<br>},<br>{<br>buffer : 0,<br>isBaseLayer : false,<br>displayInLayerSwitcher:true<br>});</font></blockquote>






<div><span style="white-space:pre-wrap"><font color="#274e13">                                                                                                            </font></span></div><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:40px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-width:initial;border-color:initial;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">






<font color="#274e13">/* setup layer_three */<br>layer_three = new OpenLayers.Layer.WMS(<br>"Layer 03",<br>"<a href="http://localhost:8080/geoserver/wms" target="_blank">http://localhost:8080/geoserver/wms</a>",<br>




{<br>

VIEWPARAMS: layer_three_legs,<br>LAYERS : 'RDA2_VIEW_LAYER_THREE',<br>transparent: "true",<br>singleTile: true,<br>format : format<br>},<br>{<br>buffer : 0,<br>isBaseLayer : false,<br>displayInLayerSwitcher:true<br>






});</font></blockquote><div><span style="white-space:pre-wrap"><font color="#274e13">                                                                                                         </font></span></div><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:40px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-width:initial;border-color:initial;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">






<font color="#274e13">/* setup layer_four */<br>layer_four = new OpenLayers.Layer.WMS(<br>"Layer 04",<br>"<a href="http://localhost:8080/geoserver/wms" target="_blank">http://localhost:8080/geoserver/wms</a>",<br>




{<br>

VIEWPARAMS: layer_four_legs,<br>LAYERS : 'RDA2_VIEW_LAYER_FOUR',<br>transparent: "true",<br>singleTile: true,<br>format : format<br>},<br>{<br>buffer : 0,<br>isBaseLayer : false,<br>displayInLayerSwitcher:true<br>






});</font></blockquote><div><span style="white-space:pre-wrap"><font color="#274e13">                                                                                                         </font></span></div><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:40px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-width:initial;border-color:initial;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">






<font color="#274e13">/* setup layer_five */<br>layer_five = new OpenLayers.Layer.WMS(<br>"Layer 05",<br>"<a href="http://localhost:8080/geoserver/wms" target="_blank">http://localhost:8080/geoserver/wms</a>",<br>




{<br>

VIEWPARAMS: layer_four_five,<br>LAYERS : 'RDA2_VIEW_LAYER_FIVE',<br>transparent: "true",<br>singleTile: true,<br>format : format<br>},<br>{<br>buffer : 0,<br>isBaseLayer : false,<br>displayInLayerSwitcher:true<br>






});</font></blockquote><div><span style="white-space:pre-wrap"><font color="#274e13">                                                                                                         </font></span></div><font color="#274e13">/* map.addLayers([untiled, tiled ]); */<br>map.addLayers([base, layer_five, layer_four, layer_three, layer_two, layer_one]);</font><div>






<font color="#274e13"><br></font></div><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:40px;border-top-style:none;border-right-style:none;border-bottom-style:none;border-left-style:none;border-width:initial;border-color:initial;padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px">






<font color="#274e13">/* build up all controls */</font><br><font color="#274e13">map.addControl(new OpenLayers.Control.PanZoomBar(</font><br><font color="#274e13">{</font><br><font color="#274e13">position : new OpenLayers.Pixel(2,15)</font><br>






<font color="#274e13">}));</font><br><font color="#274e13">map.addControl(new OpenLayers.Control.Navigation());</font><br><font color="#cc0000">map.addControl(new OpenLayers.Control.LayerSwitcher());</font><br><font color="#274e13">map.zoomToExtent(bounds);</font><br>






<font color="#274e13">}</font></blockquote><div><span style="white-space:pre-wrap"><font color="#274e13">                                                                                                     </font></span></div><div><font color="#274e13"></script></font></div></div></div></blockquote></div>

</blockquote></div></div></div></div></div><div><br></div>-- <br>Me on Web<br><a href="http://dushan888.wordpress.com" target="_blank">http://dushan888.wordpress.com</a><div><a href="http://www.linkedin.com/pub/dushan-basnayake/18/9a7/8b9" target="_blank">http://www.linkedin.com/pub/dushan-basnayake/18/9a7/8b9</a><br>

<div><a href="http://www.twitter.com/Dushi" target="_blank">http://www.twitter.com/Dushi</a><br><br></div></div>
</div>