Add format-level layerOptions configuration property to WMC parser, to support

the configuration of user-preferred layer options in order to allow 
configurability of options like buffer, ratio, etc. r=ahocevar (Closes #1411).


git-svn-id: http://svn.openlayers.org/trunk/openlayers@6534 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2008-03-16 12:21:15 +00:00
parent ca4a8d1ebf
commit cd27825fb5
3 changed files with 18 additions and 3 deletions
+5 -2
View File
@@ -19,7 +19,7 @@
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 2; OpenLayers.IMAGE_RELOAD_ATTEMPTS = 2;
OpenLayers.Util.onImageLoadErrorColor = "transparent"; OpenLayers.Util.onImageLoadErrorColor = "transparent";
var format = new OpenLayers.Format.WMC(); var format = new OpenLayers.Format.WMC({'layerOptions': {buffer: 0}});
var doc, context, map; var doc, context, map;
function init() { function init() {
@@ -137,7 +137,10 @@
<button onclick="readWMC(true);">read and merge</button> <button onclick="readWMC(true);">read and merge</button>
<textarea id="wmc">paste WMC doc here</textarea> <textarea id="wmc">paste WMC doc here</textarea>
<div id="docs"> <div id="docs">
This is an example of parsing WMC documents. This is an example of parsing WMC documents. <br />
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.
</div> </div>
</body> </body>
</html> </html>
+8
View File
@@ -27,6 +27,14 @@ OpenLayers.Format.WMC = OpenLayers.Class({
*/ */
version: null, 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 * Property: parser
* {Object} Instance of the versioned parser. Cached for multiple read and * {Object} Instance of the versioned parser. Cached for multiple read and
+5 -1
View File
@@ -193,11 +193,15 @@ OpenLayers.Format.WMC.v1 = OpenLayers.Class(OpenLayers.Format.XML, {
* {<OpenLayers.Layer.WMS>} A WMS layer. * {<OpenLayers.Layer.WMS>} A WMS layer.
*/ */
getLayerFromInfo: function(layerInfo) { getLayerFromInfo: function(layerInfo) {
var options = layerInfo.options;
if (this.layerOptions) {
OpenLayers.Util.applyDefaults(options, this.layerOptions);
}
var layer = new OpenLayers.Layer.WMS( var layer = new OpenLayers.Layer.WMS(
layerInfo.title, layerInfo.title,
layerInfo.href, layerInfo.href,
layerInfo.params, layerInfo.params,
layerInfo.options options
); );
return layer; return layer;
}, },