diff --git a/examples/wmc.html b/examples/wmc.html index 956800ec68..95ebaf720e 100644 --- a/examples/wmc.html +++ b/examples/wmc.html @@ -19,7 +19,7 @@ OpenLayers.IMAGE_RELOAD_ATTEMPTS = 2; OpenLayers.Util.onImageLoadErrorColor = "transparent"; - var format = new OpenLayers.Format.WMC(); + var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}}); var doc, context, map; function init() { @@ -137,7 +137,10 @@
- This is an example of parsing WMC documents. + This is an example of parsing WMC documents.
+ The format class has a layerOptions property, which can be used + to control the default options of the layer when it is created + by the parser.
diff --git a/lib/OpenLayers/Format/WMC.js b/lib/OpenLayers/Format/WMC.js index f48abed6c7..890dcce3f4 100644 --- a/lib/OpenLayers/Format/WMC.js +++ b/lib/OpenLayers/Format/WMC.js @@ -26,6 +26,14 @@ OpenLayers.Format.WMC = OpenLayers.Class({ * {String} Specify a version string if one is known. */ version: null, + + /** + * Property: layerOptions + * {Object} Default options for layers created by the parser. These + * options are overridden by the options which are read from the + * capabilities document. + */ + layerOptions: null, /** * Property: parser diff --git a/lib/OpenLayers/Format/WMC/v1.js b/lib/OpenLayers/Format/WMC/v1.js index ab36463cb3..e8d3941708 100644 --- a/lib/OpenLayers/Format/WMC/v1.js +++ b/lib/OpenLayers/Format/WMC/v1.js @@ -193,11 +193,15 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, { * {} A WMS layer. */ getLayerFromInfo: function(layerInfo) { + var options = layerInfo.options; + if (this.layerOptions) { + OpenLayers.Util.applyDefaults(options, this.layerOptions); + } var layer = new OpenLayers.Layer.WMS( layerInfo.title, layerInfo.href, layerInfo.params, - layerInfo.options + options ); return layer; },