diff --git a/lib/OpenLayers/Layer/Image.js b/lib/OpenLayers/Layer/Image.js index 63c7c40ca1..f34db25c5a 100644 --- a/lib/OpenLayers/Layer/Image.js +++ b/lib/OpenLayers/Layer/Image.js @@ -30,7 +30,10 @@ OpenLayers.Layer.Image = OpenLayers.Class(OpenLayers.Layer, { /** * Property: extent - * {} The image bounds in map units + * {} The image bounds in map units. This extent will + * also be used as the default maxExtent for the layer. If you wish + * to have a maxExtent that is different than the image extent, set the + * maxExtent property of the options argument (as with any other layer). */ extent: null, @@ -67,6 +70,7 @@ OpenLayers.Layer.Image = OpenLayers.Class(OpenLayers.Layer, { initialize: function(name, url, extent, size, options) { this.url = url; this.extent = extent; + this.maxExtent = extent; this.size = size; OpenLayers.Layer.prototype.initialize.apply(this, [name, options]); diff --git a/tests/Layer/Image.html b/tests/Layer/Image.html index 2eb7b0ec87..7127c585a1 100644 --- a/tests/Layer/Image.html +++ b/tests/Layer/Image.html @@ -37,6 +37,23 @@ t.ok( layer.projection == null, "default layer projection correctly set"); t.ok( layer.options instanceof Object, "layer.options correctly initialized as a non-null Object" ); } + + function test_maxExtent(t) { + t.plan(2); + var layer; + + // test that the image extent is set as the default maxExtent + var extent = new OpenLayers.Bounds(1, 2, 3, 4); + var size = new OpenLayers.Size(2, 2); + layer = new OpenLayers.Layer.Image("Test", "foo", extent, size); + t.eq(layer.maxExtent.toString(), extent.toString(), "extent set as default maxExtent"); + + // test that the maxExtent can be set explicitly + var maxExtent = new OpenLayers.Bounds(10, 20, 30, 40); + layer = new OpenLayers.Layer.Image("Test", "foo", extent, size, {maxExtent: maxExtent}); + t.eq(layer.maxExtent.toString(), maxExtent.toString(), "maxExtent can be set explicitly"); + + } function test_Layer_Image_tileTests (t) { t.plan(7);