Tiles should not load data outside maxExtent unless the

'displayOutsideMaxExtent' option on the layer is set to true. Add
tests, docs, and code.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@1531 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-10-03 01:08:00 +00:00
parent 66a5d90965
commit 2cb4306beb
5 changed files with 67 additions and 10 deletions

View File

@@ -22,6 +22,7 @@ of different layers.
getViewPortPxFromLonLat({OpenLayers.LonLat|lonlat}) -- {OpenLayers.Pixel} -- Returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat, translated into view port pixels
* Parameters
displayOutsideMaxExtent -- Determine whether images or data are loaded outside the maxExtent. Default is false.
isBaseLayer -- This determines whether the layer is a base layer or an overlay. Only one Base Layer can be displayed on the map at once. Default is false.
projection -- SRS string to describe the layer. If this is set on the map before the Layer is added to the map, it will inherit from the map.
maxExtent -- an OpenLayers.Bounds for the layer. This is the maximum geographic extent of the layer. If this is set on the map before the Layer is added to the map, it will inherit from the map.

View File

@@ -78,6 +78,9 @@ OpenLayers.Layer.prototype = {
/** @type float */
maxScale: null,
/** @type Boolean */
displayOutsideMaxExtent: false,
/**

View File

@@ -49,13 +49,17 @@ OpenLayers.Tile.Image.prototype =
}
this.imgDiv.style.display = "none";
if (this.layer.alpha) {
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
null, this.position, this.size, this.url);
} else {
this.imgDiv.src = this.url;
OpenLayers.Util.modifyDOMElement(this.imgDiv,
null, this.position, this.size) ;
if (this.layer.displayOutsideMaxExtent || (this.layer.maxExtent &&
(this.bounds.intersectsBounds(this.layer.maxExtent,false))
)) {
if (this.layer.alpha) {
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
null, this.position, this.size, this.url);
} else {
this.imgDiv.src = this.url;
OpenLayers.Util.modifyDOMElement(this.imgDiv,
null, this.position, this.size) ;
}
}
},

View File

@@ -63,7 +63,10 @@ OpenLayers.Tile.WFS.prototype =
this.clear();
}
OpenLayers.Tile.prototype.draw.apply(this, arguments);
this.loadFeaturesForRegion(this.requestSuccess);
if (this.layer.displayOutsideMaxExtent || (this.layer.maxExtent &&
this.layer.maxExtent.intersectsBounds(this.bounds, false))) {
this.loadFeaturesForRegion(this.requestSuccess);
}
},
/** get the full request string from the ds and the tile params

View File

@@ -27,7 +27,7 @@
function test_02_Tile_Image_draw (t) {
t.plan( 5 );
var layer = new Object(); //bogus layer
var layer = {maxExtent:new OpenLayers.Bounds(-180,-90,180,90)}; //bogus layer
layer.div = document.createElement("div");
var position = new OpenLayers.Pixel(20,30);
var bounds = new OpenLayers.Bounds(1,2,3,4);
@@ -51,11 +51,57 @@
t.eq( tile.imgDiv.style.width, "5px", "Image width is correct" );
t.eq( tile.imgDiv.style.height, "6px", "Image height is correct" );
}
function test_03_Tile_Image_OutsideMaxExtent(t) {
t.plan( 11 );
var position = new OpenLayers.Pixel(20,30);
var bounds = new OpenLayers.Bounds(1,2,3,4);
var url = "http://www.openlayers.org/dev/tests/tileimage";
var size = new OpenLayers.Size(5,6);
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'});
map.addLayer(layer);
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-90,-180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "", "Images against side of maxextent don't load");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-181,-91,180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Images over edges of maxextent do load");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-181,-90,180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Images over edges of maxextent do load");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-180,-90,180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering all of extent loads");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-80,-45,80,45), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering small part of extent loads");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-95,185,95), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering more than all of extent loads");
layer.displayOutsideMaxExtent=1;
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-90,-180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Images against side of maxextent do load with displayOutsideMaxExtent");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-181,-90,180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Images over edges of maxextent do load with displayOutsideMaxExtent set");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-180,-90,180,90), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering all of extent loads with display outside max extent");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-80,-45,80,45), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering small part of extent loads with display outside max extent");
tile = new OpenLayers.Tile.Image(layer, position, new OpenLayers.Bounds(-185,-95,185,95), url, size);
tile.draw()
t.eq(tile.imgDiv.src, "http://www.openlayers.org/dev/tests/tileimage", "Image covering more than all of extent loads");
}
// -->
</script>
</head>
<body>
<div id="map"></div>
</body>
</html>