diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 3c77ac1b6d..ba2057bdf5 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -1098,11 +1098,17 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { }); //if that was the last tile, then trigger a 'loadend' on the layer if (this.tileQueue.length === 0 && this.numLoadingTiles === 0) { - this.loading = false; - this.events.triggerEvent("loadend"); - if(this.backBuffer) { - this.removeBackBuffer(); - } + // give the last tile time to render before firing loadend and + // removing the backbuffer. + var delay = this.tileSize.w * this.tileSize.h / 32768; + var that = this; + window.setTimeout(function() { + that.loading = false; + that.events.triggerEvent("loadend"); + if(that.backBuffer) { + that.removeBackBuffer(); + } + }, delay); } };