--- E:/OpenLayers-svn/lib/OpenLayers/Tile/Image.js	Thu Dec 13 14:38:08 2007
+++ E:/OpenLayers-2.5/lib/OpenLayers/Tile/Image.js	Thu Dec 13 17:14:30 2007
@@ -42,6 +42,10 @@
      * {Boolean} True if the png alpha hack needs to be applied on the layer's div.
      */
     layerAlphaHack: null,
+    
+    oldBounds: null,
+    
+    zoom: -1,
 
     /** TBD 3.0 - reorder the parameters to the init function to remove 
      *             URL. the getUrl() function on the layer gets called on 
@@ -67,6 +71,8 @@
         this.frame.style.position = 'absolute'; 
 
         this.layerAlphaHack = this.layer.alpha && OpenLayers.Util.alphaHack();
+        
+        this.oldBounds = bounds.clone();
     },
 
     /** 
@@ -99,6 +105,7 @@
     draw:function() {
         if (this.layer != this.layer.map.baseLayer && this.layer.reproject) {
             this.bounds = this.getBoundsFromBaseLayer(this.position);
+            this.oldBounds = this.bounds.clone();
         }
         if (!OpenLayers.Tile.prototype.draw.apply(this, arguments)) {
             return false;    
@@ -120,10 +127,35 @@
         
         this.url = this.layer.getURL(this.bounds);
         // position the frame 
-        OpenLayers.Util.modifyDOMElement(this.frame, 
-                                         null, this.position, this.size);   
+        var imageSize = null;
+        if (this.layer.singleTile) {
+            var zoomChanged = false;
+            if (this.zoom != this.layer.map.getZoom()) {
+                this.zoom = this.layer.map.getZoom();
+                zoomChanged = true;
+            }
+            
+            if (zoomChanged) {
+                var topLeftPx = this.layer.getViewPortPxFromLonLat(
+                    new OpenLayers.LonLat(this.oldBounds.left, this.oldBounds.top));
+                var bottomRightPx = this.layer.getViewPortPxFromLonLat(
+                    new OpenLayers.LonLat(this.oldBounds.right, this.oldBounds.bottom));
+                
+                imageSize = new OpenLayers.Size(bottomRightPx.x - topLeftPx.x, 
+                                                  bottomRightPx.y - topLeftPx.y);
+                OpenLayers.Util.modifyDOMElement(this.frame, null, topLeftPx, imageSize);
+            } else {
+                imageSize = this.layer.getImageSize(); 
+            }
 
-        var imageSize = this.layer.getImageSize(); 
+            this.oldBounds = this.bounds.clone();
+        } else {
+            OpenLayers.Util.modifyDOMElement(this.frame, 
+                                             null, this.position, this.size);   
+
+            imageSize = this.layer.getImageSize(); 
+        }
+        
         if (this.layerAlphaHack) {
             OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
                     null, null, imageSize, this.url);
@@ -141,7 +173,7 @@
      *   be reused in a new location.
      */
     clear: function() {
-        if(this.imgDiv) {
+        if(this.imgDiv && !this.layer.singleTile) {
             this.imgDiv.style.display = "none";
         }
     },
@@ -203,6 +235,17 @@
         // can register when a tile has finished loading.
         var onload = function() {
             
+            if (this.layer.singleTile) {
+                OpenLayers.Util.modifyDOMElement(this.frame, null, this.position, this.size);
+                var imageSize = this.layer.getImageSize(); 
+                if (this.layerAlphaHack) {
+                    OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
+                            null, null, imageSize);
+                } else {
+                    OpenLayers.Util.modifyDOMElement(this.imgDiv,
+                            null, null, imageSize) ;
+                }
+            }
             //normally isLoading should always be true here but there are some 
             // right funky conditions where loading and then reloading a tile
             // with the same url *really*fast*. this check prevents sending 
