From 434178ef49ddd34e27788c30e7b8eb146289b269 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 27 Mar 2013 17:46:36 +0100 Subject: [PATCH] Making backbuffer order configurable In OpenLayers 2.12, the backbuffer for each layer was placed right below the layer itself. With animated zooming, that was changed so backbuffers are all placed below the base layer. As it turned out, this is only good for certain kinds of layers (e.g. street labels), so the default now is to place the backbuffer right below its layer again. But the transitionEffect option can now have a new value, 'map-resize', which will cause the backbuffer to be placed below the base layer. --- lib/OpenLayers/Layer/Grid.js | 19 ++++++++++++++----- tests/Layer/Grid.html | 12 ++++++++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/OpenLayers/Layer/Grid.js b/lib/OpenLayers/Layer/Grid.js index 6e69c35f6b..034c72c3f8 100644 --- a/lib/OpenLayers/Layer/Grid.js +++ b/lib/OpenLayers/Layer/Grid.js @@ -98,9 +98,14 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { * Two posible values: * * "resize" - Existing tiles are resized on zoom to provide a visual - * effect of the zoom having taken place immediately. As the - * new tiles become available, they are drawn over top of the - * resized tiles (this is the default setting). + * effect of the zoom having taken place immediately. As the + * new tiles become available, they are drawn over top of the + * resized tiles (this is the default setting). + * "map-resize" - Existing tiles are resized on zoom and placed below the + * base layer. New tiles for the base layer will cover existing tiles. + * This setting is recommended when having an overlay duplicated during + * the transition is undesirable (e.g. street labels or big transparent + * fills). * null - No transition effect. * * Using "resize" on non-opaque layers can cause undesired visual @@ -705,8 +710,12 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, { backBuffer.id = this.div.id + '_bb'; backBuffer.className = 'olBackBuffer'; backBuffer.style.position = 'absolute'; - backBuffer.style.zIndex = this.map.Z_INDEX_BASE.BaseLayer - - (this.map.getNumLayers() - this.map.getLayerIndex(this)); + var map = this.map; + backBuffer.style.zIndex = this.transitionEffect === 'resize' ? + this.getZIndex() - 1 : + // 'map-resize': + map.Z_INDEX_BASE.BaseLayer - + (map.getNumLayers() - map.getLayerIndex(this)); for(var i=0, lenI=this.grid.length; i