diff --git a/lib/OpenLayers/Tile.js b/lib/OpenLayers/Tile.js index e4219a074d..5dbb729fe5 100644 --- a/lib/OpenLayers/Tile.js +++ b/lib/OpenLayers/Tile.js @@ -77,14 +77,38 @@ OpenLayers.Tile.prototype = { }, /** - */ - draw:function() { + * Clear whatever is currently in the tile, then return whether or not + * it should actually be re-drawn. + * + * @returns Whether or not the tile should actually be drawn. Note that + * this is not really the best way of doing things, but such is + * the way the code has been developed. Subclasses call this and + * depend on the return to know if they should draw or not. + * @type Boolean + */ + draw: function() { + + //clear tile's contents and mark as not drawn this.clear(); - return ((this.layer.displayOutsideMaxExtent - || (this.layer.maxExtent - && this.bounds.intersectsBounds(this.layer.maxExtent, false))) - && !(this.layer.buffer == 0 - && !this.bounds.intersectsBounds(this.layer.map.getExtent(), false))); + + var maxExtent = this.layer.maxExtent; + var withinMaxExtent = (maxExtent && + this.bounds.intersectsBounds(maxExtent, false)); + + var mapExtent = this.layer.map.getExtent(); + var withinMapExtent = (mapExtent && + this.bounds.intersectsBounds(mapExtent, false)); + + // There are two cases where we *wouldn't* want to draw the tile: + // + // 1) If the tile is outside its layer's maxExtent + // 2) When the layer's buffer is 0, if the tile is outside the map's + // extent (out of view) + // + // ...what we return is the opposite of the above conditions :-) + // + return ( (withinMaxExtent || this.layer.displayOutsideMaxExtent) && + (withinMapExtent || (this.layer.buffer != 0)) ); }, /**