diff --git a/lib/OpenLayers/Handler/RegularPolygon.js b/lib/OpenLayers/Handler/RegularPolygon.js index 5aec1189cf..933160dd17 100644 --- a/lib/OpenLayers/Handler/RegularPolygon.js +++ b/lib/OpenLayers/Handler/RegularPolygon.js @@ -55,6 +55,12 @@ OpenLayers.Handler.RegularPolygon = OpenLayers.Class(OpenLayers.Handler.Drag, { */ snapToggle: 'shiftKey', + /** + * Property: layerOptions + * {Object} Any optional properties to be set on the sketch layer. + */ + layerOptions: null, + /** * APIProperty: persist * {Boolean} Leave the feature rendered until clear is called. Default @@ -130,7 +136,9 @@ OpenLayers.Handler.RegularPolygon = OpenLayers.Class(OpenLayers.Handler.Drag, { * cancel callback will receive a geometry. */ initialize: function(control, callbacks, options) { - this.style = OpenLayers.Util.extend(OpenLayers.Feature.Vector.style['default'], {}); + if(!(options && options.layerOptions && options.layerOptions.styleMap)) { + this.style = OpenLayers.Util.extend(OpenLayers.Feature.Vector.style['default'], {}); + } OpenLayers.Handler.prototype.initialize.apply(this, [control, callbacks, options]); @@ -159,14 +167,14 @@ OpenLayers.Handler.RegularPolygon = OpenLayers.Class(OpenLayers.Handler.Drag, { var activated = false; if(OpenLayers.Handler.prototype.activate.apply(this, arguments)) { // create temporary vector layer for rendering geometry sketch - var options = { + var options = OpenLayers.Util.extend({ displayInLayerSwitcher: false, // indicate that the temp vector layer will never be out of range // without this, resolution properties must be specified at the // map-level for this temporary layer to init its resolutions // correctly calculateInRange: OpenLayers.Function.True - }; + }, this.layerOptions); this.layer = new OpenLayers.Layer.Vector(this.CLASS_NAME, options); this.map.addLayer(this.layer); activated = true;