[OpenLayers-Commits] r12404 - in
sandbox/camptocamp/clientzoom/lib/OpenLayers: . Tile
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Tue Sep 20 04:40:32 EDT 2011
Author: erilem
Date: 2011-09-20 01:40:31 -0700 (Tue, 20 Sep 2011)
New Revision: 12404
Modified:
sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer.js
sandbox/camptocamp/clientzoom/lib/OpenLayers/Tile/BackBufferable.js
sandbox/camptocamp/clientzoom/lib/OpenLayers/Tile/Image.js
Log:
apply Andreas' patch to BackBufferable.js and Layer.js, with small modifications, and change createBackBuffer to insertBackBuffer
Modified: sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer.js
===================================================================
--- sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer.js 2011-09-20 01:35:17 UTC (rev 12403)
+++ sandbox/camptocamp/clientzoom/lib/OpenLayers/Layer.js 2011-09-20 08:40:31 UTC (rev 12404)
@@ -1247,11 +1247,11 @@
* {<OpenLayers.Pixel>} An <OpenLayers.Pixel> which is the passed-in
* <OpenLayers.LonLat>,translated into view port pixels.
*/
- getViewPortPxFromLonLat: function (lonlat) {
+ getViewPortPxFromLonLat: function (lonlat, resolution) {
var px = null;
if (lonlat != null) {
- var resolution = this.map.getResolution();
- var extent = this.map.getExtent();
+ resolution = resolution || this.map.getResolution();
+ var extent = this.map.calculateBounds(null, resolution);
px = new OpenLayers.Pixel(
(1/resolution * (lonlat.lon - extent.left)),
(1/resolution * (extent.top - lonlat.lat))
Modified: sandbox/camptocamp/clientzoom/lib/OpenLayers/Tile/BackBufferable.js
===================================================================
--- sandbox/camptocamp/clientzoom/lib/OpenLayers/Tile/BackBufferable.js 2011-09-20 01:35:17 UTC (rev 12403)
+++ sandbox/camptocamp/clientzoom/lib/OpenLayers/Tile/BackBufferable.js 2011-09-20 08:40:31 UTC (rev 12404)
@@ -119,9 +119,12 @@
data = this.backBufferData,
tile = this.getTile(),
backBuffer = data.tile,
- resolution = data.resolution,
mapResolution = map.getResolution(),
- ratio = resolution ? resolution / mapResolution : 1,
+ prevResolution = data.resolution,
+ currResolution = layer.getServerSupportedResolution ?
+ layer.getServerSupportedResolution(mapResolution) :
+ mapResolution,
+ ratio = prevResolution ? prevResolution / currResolution : 1,
// Cases where we don't position and return a back buffer, but only
// update backBufferData and return undefined:
@@ -132,34 +135,31 @@
// (3) we don't have a tile available that we could use as buffer
noTile = !(tile && tile.childNodes.length > 0),
// (4) no backbuffer is displayed for a tile that's still loading
- noBackBuffer = !backBuffer && this.isLoading,
- // (5) the layer div is scaled or is to be scaled
- scaledLayer = layer.getResolutionScale() != 1 ||
- layer.getServerSupportedResolution(mapResolution)
- != mapResolution;
- if (notNeeded || noParent || noTile || noBackBuffer || scaledLayer) {
+ noBackBuffer = !backBuffer && this.isLoading;
+
+ if (notNeeded || noParent || noTile || noBackBuffer) {
this.setBackBufferData();
return;
}
// Create a back buffer tile and add it to the DOM
if (!backBuffer) {
- backBuffer = this.createBackBuffer();
+ backBuffer = this.insertBackBuffer();
// some browsers fire the onload event before the image is
// displayed, so we keep the buffer until the whole layer finished
// loading to avoid visual glitches
layer.events.register("loadend", this, this.resetBackBuffer);
data.tile = backBuffer;
- layer.div.insertBefore(backBuffer, tile);
}
// Position the back buffer now that we have one
var lonLat = {lon: data.bounds.left, lat: data.bounds.top},
- position = map.getPixelFromLonLat(lonLat),
+ position = layer.getViewPortPxFromLonLat(lonLat, currResolution),
containerStyle = map.layerContainerDiv.style,
leftOffset = parseInt(containerStyle.left, 10),
topOffset = parseInt(containerStyle.top, 10),
style = backBuffer.style;
+
style.left = (position.x - leftOffset) + "%";
style.top = (position.y - topOffset) + "%";
style.width = (this.size.w * ratio) + "%";
Modified: sandbox/camptocamp/clientzoom/lib/OpenLayers/Tile/Image.js
===================================================================
--- sandbox/camptocamp/clientzoom/lib/OpenLayers/Tile/Image.js 2011-09-20 01:35:17 UTC (rev 12403)
+++ sandbox/camptocamp/clientzoom/lib/OpenLayers/Tile/Image.js 2011-09-20 08:40:31 UTC (rev 12404)
@@ -320,14 +320,16 @@
},
/**
- * Method: createBackBuffer
- * Create a copy of this tile's markup for the <layer>'s backBufferDiv
+ * Method: insertBackBuffer
+ * Create a copy of this tile's markup and insert it to the layer
+ * div.
*
* Returns:
- * {DOMElement} a clone of the tile content
+ * {DOMElement} The back buffer.
*/
- createBackBuffer: function() {
+ insertBackBuffer: function() {
var frame = this.frame.cloneNode(false);
+ this.layer.div.insertBefore(frame, this.frame);
frame.appendChild(this.imgDiv);
this.imgDiv = null;
return frame;
More information about the Commits
mailing list