[OpenLayers-Users] Loading WMC layers at overlays?

jvanulde jvanulde at NRCAN.GC.CA
Wed Aug 13 20:08:46 EDT 2008


Thanks Bart that worked.  Below is the code in case someone else can use it:

--------------------------

        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 2;
        OpenLayers.Util.onImageLoadErrorColor = "transparent";
        
        var layerOptions = {
            isBaseLayer: false,
            singleTile: true,
            buffer: 0,
            ratio: 1
            };
        
        var format = new OpenLayers.Format.WMC({'layerOptions':
layerOptions});
        var map, context;
        
        function initMap() 
        {           
            // parse wmc into context object            
            var wmc =
document.getElementById('hiddenWMCContentsField').value;
            
            context = format.read(wmc, {map: map});
            
            for (var i=0; i<context.layers.length;i++) 
            { 
              var layer = context.layers[i]; 
              layer.params.TRANSPARENT = 'TRUE'; 
            }
          
            // construct a map given the context
            var mapOptions = {
                maxExtent: context.bounds,
                projection: context.srs
                };
                
            map = new OpenLayers.Map("map", mapOptions);
            
            // create a fake base layer
            var baseLayerOptions = {
                isBaseLayer: true, 
                displayInLayerSwitcher: false
                };
                
            var fake = new OpenLayers.Layer('fake', baseLayerOptions);
            map.addLayer(fake);            

            // add the context layers to the map
            map.addLayers(context.layers);
                 
            map.addControl(new OpenLayers.Control.LayerSwitcher());
            map.zoomToMaxExtent();     
        }
-- 
View this message in context: http://www.nabble.com/Loading-WMC-layers-at-overlays--tp18859376p18973615.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list