diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index cb516cbe96..c31d195f0e 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -25,6 +25,12 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { */ tileSize: null, + /** + * APIProperty: tileExtent + * {} + */ + tileExtent: null, + /** APIProperty: tileOptions * {Object} optional configuration options for instances * created by this Layer, if supported by the tile class. @@ -446,7 +452,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * {OpenLayers.Bounds} */ getMaxExtent: function() { - return this.maxExtent; + return this.tileExtent || this.maxExtent; }, /** diff --git a/tests/Layer/WMS.html b/tests/Layer/WMS.html index 0e50bff424..ec3e153863 100644 --- a/tests/Layer/WMS.html +++ b/tests/Layer/WMS.html @@ -154,7 +154,6 @@ map.destroy(); } - function test_Layer_WMS_clone (t) { t.plan(4); @@ -381,6 +380,39 @@ } + function test_tileExtent(t) { + t.plan(4); + + var dummy = new OpenLayers.Layer(null, {isBaseLayer: true}); + var unconstrained = new OpenLayers.Layer.WMS( + null, "http://example.com/wms", + {layers: "unconstrained"}, + {isBaseLayer: false, buffer: 0} + ); + var constrained = new OpenLayers.Layer.WMS( + null, "http://example.com/wms-c", + {layers: "constrained"}, + {buffer: 0, isBaseLayer: false, tileExtent: new OpenLayers.Bounds(-180, -90, 180, 90)} + ); + var map = new OpenLayers.Map({ + div: "map", + maxExtent: new OpenLayers.Bounds(-185, -95, 185, 95), + layers: [dummy, unconstrained, constrained], + center: new OpenLayers.LonLat(0, 0), + zoom: 1 + }); + + t.eq(unconstrained.grid[1][0].bounds.bottom, -95, "unconstrained bottom correct"); + t.eq(unconstrained.grid[1][0].bounds.left, -185, "unconstrained left correct"); + t.eq(constrained.grid[1][0].bounds.bottom, -90, "constrained bottom correct"); + t.eq(constrained.grid[1][0].bounds.left, -180, "constrained left correct"); + + map.destroy(); + + } + + + // DEPRECATED -- REMOVE IN 3.0 function test_Layer_Untiled_WMS(t) { t.plan(1);