Using the extent provided to the image layer constructor as the default maxExtent. To set a custom maxExtent (as always), use the maxExtent property of the options argument. r=me (closes #1867)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@8613 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2009-01-09 05:35:07 +00:00
parent 27e9f855e9
commit 438418c5bb
2 changed files with 22 additions and 1 deletions

View File

@@ -30,7 +30,10 @@ OpenLayers.Layer.Image = OpenLayers.Class(OpenLayers.Layer, {
/**
* Property: extent
* {<OpenLayers.Bounds>} The image bounds in map units
* {<OpenLayers.Bounds>} 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]);

View File

@@ -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);