diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index fc2232a6a8..69584c2e97 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -490,10 +490,14 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { updateBackBufferData: function() { // updateBackBufferData is called asynchronously when tiles are // received, so we need to check that the map is still there - if (this.map) { + if(this.map) { var resolution = this.map.getResolution(); this.backBufferData.resolution = this.getServerResolution(resolution); - var topLeftTile = this.grid[0][0]; + } + // the top left tile might have been destroyed, so its bounds + // property may be null + var topLeftTile = this.grid[0][0]; + if(topLeftTile.bounds) { this.backBufferData.lonlat = {lon: topLeftTile.bounds.left, lat: topLeftTile.bounds.top}; }