From ef33f015043151091aef65b9620c809f6cd0d9e7 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 19 Apr 2012 12:02:18 +0200 Subject: [PATCH] Respect alwaysInRange from prototype, but allow changes in addOptions. --- lib/OpenLayers/Layer.js | 7 ++++++- tests/Layer.html | 10 ++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js index 05747f2cbf..158301174a 100644 --- a/lib/OpenLayers/Layer.js +++ b/lib/OpenLayers/Layer.js @@ -338,6 +338,11 @@ OpenLayers.Layer = OpenLayers.Class({ this.metadata = {}; + options = OpenLayers.Util.extend({}, options); + // make sure we respect alwaysInRange if set on the prototype + if (this.alwaysInRange != null) { + options.alwaysInRange = this.alwaysInRange; + } this.addOptions(options); this.name = name; @@ -858,7 +863,7 @@ OpenLayers.Layer = OpenLayers.Class({ alwaysInRange = false; } } - if(this.alwaysInRange == null) { + if(this.options.alwaysInRange == null) { this.alwaysInRange = alwaysInRange; } diff --git a/tests/Layer.html b/tests/Layer.html index eb2c9270f7..bd089abf6d 100644 --- a/tests/Layer.html +++ b/tests/Layer.html @@ -174,6 +174,16 @@ t.eq(log, 0, "addOptions doesn't call initResolutions when layer is not in map"); } + function test_addOptionsScale(t) { + t.plan(1); + var map = new OpenLayers.Map("map"); + var layer = new OpenLayers.Layer.WMS(); + map.addLayer(layer); + map.zoomToMaxExtent(); + layer.addOptions({maxResolution: 0.5, numZoomLevels: 15}); + t.eq(layer.alwaysInRange, false, "alwaysInRange should not be true anymore"); + } + function test_Layer_StandardOptionsAccessors (t) { t.plan( 4 );