<span class="Apple-style-span" style="font-family: verdana; white-space: pre-wrap; ">All -
<br></span><div><span class="Apple-style-span" style="font-family: verdana; white-space: pre-wrap; ">I&#39;m trying to modify the custom LayerSwitcher provided by Semantica: <a href="http://n2.nabble.com/Layer-selection-in-LayerSwitcher-td789021.html#a790967">http://n2.nabble.com/Layer-selection-in-LayerSwitcher-td789021.html#a790967</a></span></div>
<div><span class="Apple-style-span" style="font-family: verdana; white-space: pre-wrap; ">
This LayerSwitcher customization is very cool and I am trying to modify it to load layers without using WMC. However, I have an invalid layer parameter (or another missing parameter) that I cannot fix. Can anyone help? I&#39;ve merged this code with the WMC example as a start but am not getting too far.

&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>&quot;&gt;
&lt;html xmlns=&quot;<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>&quot;&gt;
&lt;head&gt;
&lt;meta content=&quot;text/html; charset=utf-8&quot; http-equiv=&quot;Content-Type&quot; /&gt;
&lt;title&gt;OpenLayers - Custom Layer Switcher&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
body
{
        font-family: Arial, Helvetica, sans-serif;
        font-size: 80%
}
#map
{
        font-size: small;
        border: 1px solid #ccc;
}
p
{
        margin: 0;
}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;../lib/OpenLayers.js&quot;&gt;&lt;/script&gt;

    &lt;script type=&quot;text/javascript&quot;&gt;






        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 2;
        OpenLayers.Util.onImageLoadErrorColor = &quot;transparent&quot;;

        var format = new OpenLayers.Format.WMC({&#39;layerOptions&#39;: {buffer: 0}});
        var doc, context, map, layerSwitcher;

                //var layerOptions = {
                //        isBaseLayer: false,
                //        singleTile: true,
                //        buffer: 0,
                //        ratio: 1
                //};


        function init() {

            var options = {
                maxExtent: new OpenLayers.Bounds(-130, 14, -60, 55)
            };
            map = new OpenLayers.Map(&quot;map&quot;, options);

            var jpl = new OpenLayers.Layer.WMS(
                &quot;NASA Global Mosaic&quot;,
                &quot;<a href="http://t1.hypercube.telascience.org/cgi-bin/landsat7">http://t1.hypercube.telascience.org/cgi-bin/landsat7</a>&quot;,
                {layers: &quot;landsat7&quot;, transparent: &quot;TRUE&quot;},
                {
                    isBaseLayer: false,
                    maxExtent: new OpenLayers.Bounds(-130, 14, -60, 55),
                    maxResolution: 0.1,
                    displayInLayerSwitcher: true,
                    numZoomLevels: 4,
                    minResolution: 0.02
                }
            );

            var vmap = new OpenLayers.Layer.WMS(
                &quot;OpenLayers WMS&quot;,
                &quot;<a href="http://labs.metacarta.com/wms/vmap0">http://labs.metacarta.com/wms/vmap0</a>&quot;,
                {layers: &quot;basic&quot;},
                {
                    isBaseLayer: false,
                    maxExtent: new OpenLayers.Bounds(-130, 14, -60, 55),
                    displayInLayerSwitcher: true,
                    maxResolution: 0.1,
                    numZoomLevels: 4,
                    minResolution: 0.02
                }
            );

            var roads = new OpenLayers.Layer.WMS(
                &quot;Transportation Network&quot;,
                &quot;<a href="http://lioapp.lrc.gov.on.ca/cubeserv/cubeserv.pl">http://lioapp.lrc.gov.on.ca/cubeserv/cubeserv.pl</a>&quot;,
                {layers: &quot;na_road:CCRS&quot;},
                {
                    isBaseLayer: false,
                    maxExtent: new OpenLayers.Bounds(
                        -166.532, 4.05046, -0.206818, 70.287
                    ),
                    displayInLayerSwitcher: true,
                    opacity: 0.6,
                    minScale: 32000000,
                    numZoomLevels: 4,
                    maxScale: 6200000
                }
            );

            var nexrad = new OpenLayers.Layer.WMS(
                &quot;Radar 3:1&quot;,
                &quot;<a href="http://columbo.nrlssc.navy.mil/ogcwms/servlet/WMSServlet/AccuWeather_Maps.wms">http://columbo.nrlssc.navy.mil/ogcwms/servlet/WMSServlet/AccuWeather_Maps.wms</a>&quot;,
                {layers: &quot;3:1&quot;},
                {
                    isBaseLayer: false,
                    maxExtent: new OpenLayers.Bounds(
                        -131.029495239, 14.5628967285,
                        -61.0295028687, 54.562896728
                    ),
                    opacity: 0.8,
                    singleTile: true,
                    visibility: true,
                    maxResolution: 0.1,
                    numZoomLevels: 4,
                    minResolution: 0.02
                }
            );

                        // create a fake base layer
                        var baseLayerOptions = {
                                isBaseLayer: true,
                                displayInLayerSwitcher: false
                        };
                        var fake = new OpenLayers.Layer(&#39;fake&#39;, baseLayerOptions);
                        map.addLayer(fake);

            map.addLayers([jpl, vmap, roads, nexrad]);

                        // add the LayerSwitcher (a.k.a. Map Legend)
                        layerSwitcher = new OpenLayers.Control.LayerSwitcher();
                        layerSwitcher.ascending = false;
            map.addControl(layerSwitcher);
                        layerSwitcher.getLegendGraphics(false);

            map.setCenter(new OpenLayers.LonLat(-95, 34.5), 1);

                        // create a new event handler for single click query
                        var clickEventHandler = new OpenLayers.Handler.Click({ &#39;map&#39;: map }, { &#39;click&#39;: function(e) { doGetFeatureInfo(e); } });
                        clickEventHandler.activate();
        };



        function readWMC(merge) {
            //var text = document.getElementById(&quot;wmc&quot;).value;
            var text = document.getElementById(&#39;hidWMC&#39;).value

            if(merge) {
                try {
                    map = format.read(text, {map: map});
                } catch(err) {
                    document.getElementById(&quot;wmc&quot;).value = err;
                }
            } else {
                map.destroy();
                try {
                    map = format.read(text, {map: &quot;map&quot;});
                    map.addControl(new OpenLayers.Control.LayerSwitcher());
                } catch(err) {
                    document.getElementById(&quot;wmc&quot;).value = err;
                }
            }
        }



        function doGetFeatureInfo(evt) {
            var layerId = layerSwitcher.activeLayer;

            if(evt) {
                var activeLayer = map.getLayer(layerId);

                if(activeLayer) {

                    var url =   activeLayer.getFullRequestString({
                                REQUEST: &quot;GetFeatureInfo&quot;,
                                EXCEPTIONS: &quot;application/vnd.ogc.se_xml&quot;,
                                BBOX: activeLayer.map.getExtent().toBBOX(),
                                X: evt.xy.x,
                                Y: evt.xy.y,
                                INFO_FORMAT: &#39;text/html&#39;,
                                QUERY_LAYERS: activeLayer.params.LAYERS,
                                WIDTH: activeLayer.map.size.w,
                                HEIGHT: activeLayer.map.size.h});

                    var popupWindow = window.open(url, &quot;GetFeatureInfo&quot;, &quot;width=550,height=350,status=yes,scrollbars=yes,resizable=yes&quot;);

                                        if(popupWindow) {
                                                popupWindow.focus();
                                        } else {
                                                return true;
                                        }

                    OpenLayers.Event.stop(evt);

                }
            }
        }
    &lt;/script&gt;

&lt;/head&gt;

&lt;body onload=&quot;init()&quot;&gt;
&lt;h2&gt;Extended Layer Switcher&lt;/h2&gt;
&lt;p&gt;This is a demonstration of a custom layer switcher that allows users to control layer opacity,
layer position, layer visibility and layer selection (for querying).  &lt;/p&gt;
&lt;hr /&gt;
&lt;div id=&quot;map&quot; style=&quot;width: 750px; height: 500px;&quot;&gt;&lt;/div&gt;
&lt;/body&gt;

&lt;/html&gt;


</span></div>