From 76e8a800dacf59c9c7342cfaadca036083bc6fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 19 Oct 2011 23:47:25 +0200 Subject: [PATCH] special precautions must be taken in updateBackBufferData --- lib/OpenLayers/Layer/Grid.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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}; }