Layer/WMS

WMS Layer


Three args to constructor:

  • name -- used for display purposes
  • url -- URL of WMS Service
  • params -- {param:'name'} style list of parameters. Via this setting, you can also override existing settings, such as the format. All params are forced to uppercase. Default parameters are:
    DEFAULT_PARAMS: { SERVICE: "WMS",                                              
     VERSION: "1.1.1",                                            
     REQUEST: "GetMap",                                           
     STYLES: "",                                                  
     EXCEPTIONS: "application/vnd.ogc.se_inimage",                
     FORMAT: "image/jpeg"                                         
    },                                                            

Typically, the one people want to edit most is the 'format' attribute.


Full params example:

  layer = new OpenLayers.Layer.WMS( "My WMS", 
                                    "http://url.to.my.wms.server",
		                    {layers: 'layer1,layer2,layer3','VERSION': "1.1.1",'units': 'meters'},
                                    {'maxExtent': new OpenLayers.Bounds(minx,miny,maxx,maxy),'maxResolution': "auto"} 
                                  );


Multiple URLs example:

  var urlArray = ["http://labs.metacarta.com/wms-c/Basic.py",
                  "http://monitor.metacarta.com/wms-c/Basic.py"];

  layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
                                    urlArray,
                                    {layers: 'basic'} );