Don't check based on layer.maxExtent.

layer.maxExtent is always set as soon as the layer is added to a map. Instead, making behavior consistent with tiled layers: don't display outside maxExtent except when displayOutsideMaxExtent is set to true or the layer's extent equals the world bounds for maps with a baseLayer that has wrapDateLine set to true.
This commit is contained in:
ahocevar
2012-03-09 23:50:09 +01:00
parent 0ff2f9a457
commit e52c97f741
2 changed files with 34 additions and 17 deletions

View File

@@ -782,28 +782,32 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
var tileWidth = bounds.getWidth() * this.ratio;
var tileHeight = bounds.getHeight() * this.ratio;
var tileBounds =
new OpenLayers.Bounds(
center.lon - (tileWidth / 2),
center.lat - (tileHeight / 2),
center.lon + (tileWidth / 2),
center.lat + (tileHeight / 2)
);
//adjust tile bounds to fit in maxExtent restriction
//if there is a maxExtent restriction
if(this.maxExtent) {
new OpenLayers.Bounds(center.lon - (tileWidth/2),
center.lat - (tileHeight/2),
center.lon + (tileWidth/2),
center.lat + (tileHeight/2));
// adjust tile bounds so they do not exceed maxExtent, except when the
// layer's maxExtent equals the world bounds or displayOutsideMaxExtent
// is set to true
var ignoreMaxExtent =
(this.map.baseLayer.wrapDateLine &&
this.maxExtent.equals(this.map.getMaxExtent())) ||
this.displayOutsideMaxExtent;
if(!ignoreMaxExtent) {
tileBounds.bottom = Math.max(this.maxExtent.bottom, tileBounds.bottom);
tileBounds.top = Math.min(this.maxExtent.top, tileBounds.top);
tileBounds.left = Math.max(this.maxExtent.left, tileBounds.left);
tileBounds.right = Math.min(this.maxExtent.right, tileBounds.right);
tileWidth = tileBounds.getWidth();
tileHeight = tileBounds.getHeight();
var resolution = this.map.getResolution();
this.tileSize = new OpenLayers.Size(
tileWidth / resolution,
tileHeight / resolution
);
}
var resolution = this.map.getResolution(),
size = this.tileSize;
size.w = (tileWidth / resolution) | 0;
size.h = (tileHeight / resolution) | 0;
var px = this.map.getLayerPxFromLonLat({
lon: tileBounds.left,