necessary adaptations to the Tile.IFrame mixin - back buffering is disabled when using POST and iframe tiles
This commit is contained in:
@@ -29,38 +29,50 @@ OpenLayers.Tile.Image.IFrame = {
|
||||
useIFrame: null,
|
||||
|
||||
/**
|
||||
* Method: updateBackBuffer
|
||||
* Update the <backBufferData>, and return a new or reposition the
|
||||
* backBuffer. When a backbuffer is returned, the tile's markup is not
|
||||
* available any more.
|
||||
* Method: draw
|
||||
* Set useIFrame in the instance, and operate the to/from image from/to
|
||||
* iframe switch, if necessary. Then call the parent function.
|
||||
*
|
||||
* Returns:
|
||||
* {HTMLDivElement} the tile's markup in a cloned element, or undefined if
|
||||
* no backbuffer is currently available or needed
|
||||
* {Boolean}
|
||||
*/
|
||||
updateBackBuffer: function() {
|
||||
this.url = this.layer.getURL(this.bounds);
|
||||
draw: function() {
|
||||
var draw = OpenLayers.Tile.Image.prototype.shouldDraw.call(this);
|
||||
if(draw) {
|
||||
|
||||
// this.url isn't set to the currect value yet, so we call getURL
|
||||
// on the layer and store the result in a local variable
|
||||
var url = this.layer.getURL(this.bounds);
|
||||
|
||||
var usedIFrame = this.useIFrame;
|
||||
this.useIFrame = this.maxGetUrlLength !== null && !this.layer.async &&
|
||||
this.url.length > this.maxGetUrlLength;
|
||||
this.useIFrame = this.maxGetUrlLength !== null &&
|
||||
!this.layer.async &&
|
||||
url.length > this.maxGetUrlLength;
|
||||
|
||||
var fromIFrame = usedIFrame && !this.useIFrame;
|
||||
var toIFrame = !usedIFrame && this.useIFrame;
|
||||
|
||||
if(fromIFrame || toIFrame) {
|
||||
// switch between get (image) and post (iframe)
|
||||
this.clear();
|
||||
|
||||
// Switching between GET (image) and POST (iframe).
|
||||
|
||||
// We remove the imgDiv (really either an image or an iframe)
|
||||
// from the frame and set it to null to make sure initImage
|
||||
// will call createImage.
|
||||
|
||||
if(this.imgDiv && this.imgDiv.parentNode === this.frame) {
|
||||
this.frame.removeChild(this.imgDiv);
|
||||
}
|
||||
this.imgDiv = null;
|
||||
|
||||
// And if we had an iframe we also remove the event pane.
|
||||
|
||||
if(fromIFrame) {
|
||||
// remove eventPane
|
||||
this.frame.removeChild(this.frame.firstChild);
|
||||
this.resetBackBuffer();
|
||||
}
|
||||
}
|
||||
if (!this.useIFrame) {
|
||||
OpenLayers.Tile.Image.prototype.updateBackBuffer.apply(this, arguments);
|
||||
}
|
||||
return OpenLayers.Tile.Image.prototype.draw.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -183,6 +195,22 @@ OpenLayers.Tile.Image.IFrame = {
|
||||
} else {
|
||||
OpenLayers.Tile.Image.prototype.setImgSrc.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: cloneMarkup
|
||||
* Override cloneMarkup to not attempt cloning when we use an iframe.
|
||||
* Moving an iframe from one element to another makes it necessary to
|
||||
* reload the iframe because its content is lost. So we just give up.
|
||||
*
|
||||
* Returns:
|
||||
* {DOMElement}
|
||||
*/
|
||||
cloneMarkup: function() {
|
||||
var clone;
|
||||
if(!this.useIFrame) {
|
||||
clone = OpenLayers.Tile.Image.prototype.cloneMarkup.call(this);
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user