From afe53aba7de077f7d521981f78fe9514ee1b4139 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 18 Dec 2012 13:48:16 +0100 Subject: [PATCH] Put backbuffer below all layers, except when panning --- lib/OpenLayers/Layer/Grid.js | 10 ++++++++-- tests/Layer/Grid.html | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index b7101cec2c..46c640a5b6 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -695,7 +695,11 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { if(!backBuffer) { return; } - this.div.insertBefore(backBuffer, this.div.firstChild); + if (resolution === this.gridResolution) { + this.div.insertBefore(backBuffer, this.div.firstChild); + } else { + this.map.layerContainerDiv.insertBefore(backBuffer, this.map.baseLayer.div); + } this.backBuffer = backBuffer; // set some information in the instance for subsequent @@ -775,7 +779,9 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { delete this._transitionElement; } if(this.backBuffer) { - this.div.removeChild(this.backBuffer); + if (this.backBuffer.parentNode) { + this.backBuffer.parentNode.removeChild(this.backBuffer); + } this.backBuffer = null; this.backBufferResolution = null; if(this.backBufferTimerId !== null) { diff --git a/tests/Layer/Grid.html b/tests/Layer/Grid.html index c9cff3e57d..dc607d1ead 100644 --- a/tests/Layer/Grid.html +++ b/tests/Layer/Grid.html @@ -1043,7 +1043,7 @@ layer.applyBackBuffer(2); t.ok(layer.backBuffer === backBuffer, 'back buffer set in layer'); - t.ok(layer.div.firstChild === backBuffer, + t.ok(map.layerContainerDiv.firstChild === backBuffer, 'back buffer inserted as first child'); t.eq(layer.backBuffer.style.left, '250px', 'back buffer has correct left'); @@ -1063,7 +1063,7 @@ layer.applyBackBuffer(2); t.ok(layer.backBuffer === backBuffer, 'back buffer set in layer'); - t.ok(layer.div.firstChild === backBuffer, + t.ok(map.layerContainerDiv.firstChild === backBuffer, 'back buffer inserted as first child'); t.eq(layer.backBuffer.style.left, '230px', 'back buffer has correct left');