Made Tile.Image.IFrame an addin which will be used only if a layer is configured with the maxGetUrlLength option. This deprecates Layer.WMS.Post. r=tschaub (closes #2824)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10755 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -76,7 +76,24 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
* effects when the tile is moved or changes resolution.
|
||||
*/
|
||||
backBufferTile: null,
|
||||
|
||||
|
||||
/**
|
||||
* APIProperty: maxGetUrlLength
|
||||
* {Number} If set, requests that would result in GET urls with more
|
||||
* characters than the number provided will be made using form-encoded
|
||||
* HTTP POST. It is good practice to avoid urls that are longer than 2048
|
||||
* characters.
|
||||
*
|
||||
* Caution:
|
||||
* Older versions of Gecko based browsers (e.g. Firefox < 3.5) and
|
||||
* Opera < 10.0 do not fully support this option.
|
||||
*
|
||||
* Note:
|
||||
* Do not use this option for layers that have a transitionEffect
|
||||
* configured - IFrame tiles from POST requests can not be resized.
|
||||
*/
|
||||
maxGetUrlLength: null,
|
||||
|
||||
/** TBD 3.0 - reorder the parameters to the init function to remove
|
||||
* URL. the getUrl() function on the layer gets called on
|
||||
* each draw(), so no need to specify it here.
|
||||
@@ -90,9 +107,14 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
* bounds - {<OpenLayers.Bounds>}
|
||||
* url - {<String>} Deprecated. Remove me in 3.0.
|
||||
* size - {<OpenLayers.Size>}
|
||||
* options - {Object}
|
||||
*/
|
||||
initialize: function(layer, position, bounds, url, size) {
|
||||
OpenLayers.Tile.prototype.initialize.apply(this, arguments);
|
||||
initialize: function(layer, position, bounds, url, size, options) {
|
||||
options = options || {};
|
||||
if (options.maxGetUrlLength !== null) {
|
||||
OpenLayers.Util.applyDefaults(options, OpenLayers.Tile.Image.IFrame);
|
||||
}
|
||||
OpenLayers.Tile.prototype.initialize.apply(this, [layer, position, bounds, url, size, options]);
|
||||
|
||||
this.url = url; //deprecated remove me
|
||||
|
||||
@@ -100,7 +122,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
this.frame.style.overflow = 'hidden';
|
||||
this.frame.style.position = 'absolute';
|
||||
|
||||
this.layerAlphaHack = this.layer.alpha && OpenLayers.Util.alphaHack();
|
||||
this.layerAlphaHack = this.layer.alpha && OpenLayers.Util.alphaHack();
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -109,22 +131,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
*/
|
||||
destroy: function() {
|
||||
if (this.imgDiv != null) {
|
||||
if (this.layerAlphaHack) {
|
||||
// unregister the "load" handler
|
||||
OpenLayers.Event.stopObservingElement(this.imgDiv.childNodes[0]);
|
||||
}
|
||||
|
||||
// unregister the "load" and "error" handlers. Only the "error" handler if
|
||||
// this.layerAlphaHack is true.
|
||||
OpenLayers.Event.stopObservingElement(this.imgDiv);
|
||||
|
||||
if (this.imgDiv.parentNode == this.frame) {
|
||||
this.frame.removeChild(this.imgDiv);
|
||||
this.imgDiv.map = null;
|
||||
}
|
||||
this.imgDiv.urls = null;
|
||||
// abort any currently loading image
|
||||
this.imgDiv.src = OpenLayers.Util.getImagesLocation() + "blank.gif";
|
||||
this.removeImgDiv();
|
||||
}
|
||||
this.imgDiv = null;
|
||||
if ((this.frame != null) && (this.frame.parentNode == this.layer.div)) {
|
||||
@@ -142,7 +149,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
|
||||
OpenLayers.Tile.prototype.destroy.apply(this, arguments);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Method: clone
|
||||
*
|
||||
@@ -281,13 +288,8 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
* position it correctly, and set its url.
|
||||
*/
|
||||
renderTile: function() {
|
||||
if (this.imgDiv == null) {
|
||||
this.initImgDiv();
|
||||
}
|
||||
|
||||
this.imgDiv.viewRequestID = this.layer.map.viewRequestID;
|
||||
|
||||
if (this.layer.async) {
|
||||
this.initImgDiv();
|
||||
// Asyncronous image requests call the asynchronous getURL method
|
||||
// on the layer to fetch an image that covers 'this.bounds', in the scope of
|
||||
// 'this', setting the 'url' property of the layer itself, and running
|
||||
@@ -297,12 +299,9 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
// syncronous image requests get the url and position the frame immediately,
|
||||
// and don't wait for an image request to come back.
|
||||
|
||||
// needed for changing to a different server for onload error
|
||||
if (this.layer.url instanceof Array) {
|
||||
this.imgDiv.urls = this.layer.url.slice();
|
||||
}
|
||||
|
||||
this.url = this.layer.getURL(this.bounds);
|
||||
|
||||
this.initImgDiv();
|
||||
|
||||
// position the frame immediately
|
||||
this.positionImage();
|
||||
@@ -356,10 +355,12 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
* Creates the imgDiv property on the tile.
|
||||
*/
|
||||
initImgDiv: function() {
|
||||
|
||||
if (this.imgDiv) {
|
||||
return;
|
||||
}
|
||||
var offset = this.layer.imageOffset;
|
||||
var size = this.layer.getImageSize(this.bounds);
|
||||
|
||||
|
||||
if (this.layerAlphaHack) {
|
||||
this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null,
|
||||
offset,
|
||||
@@ -380,7 +381,12 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
null,
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
// needed for changing to a different server for onload error
|
||||
if (this.layer.url instanceof Array) {
|
||||
this.imgDiv.urls = this.layer.url.slice();
|
||||
}
|
||||
|
||||
this.imgDiv.className = 'olTileImage';
|
||||
|
||||
/* checkImgURL used to be used to called as a work around, but it
|
||||
@@ -396,7 +402,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
this.layer.div.appendChild(this.frame);
|
||||
|
||||
if(this.layer.opacity != null) {
|
||||
|
||||
|
||||
OpenLayers.Util.modifyDOMElement(this.imgDiv, null, null, null,
|
||||
null, null, null,
|
||||
this.layer.opacity);
|
||||
@@ -408,7 +414,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
//bind a listener to the onload of the image div so that we
|
||||
// can register when a tile has finished loading.
|
||||
var onload = function() {
|
||||
|
||||
|
||||
//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
|
||||
@@ -419,7 +425,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
this.events.triggerEvent("loadend");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if (this.layerAlphaHack) {
|
||||
OpenLayers.Event.observe(this.imgDiv.childNodes[0], 'load',
|
||||
OpenLayers.Function.bind(onload, this));
|
||||
@@ -427,7 +433,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
OpenLayers.Event.observe(this.imgDiv, 'load',
|
||||
OpenLayers.Function.bind(onload, this));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Bind a listener to the onerror of the image div so that we
|
||||
// can registere when a tile has finished loading with errors.
|
||||
@@ -444,6 +450,35 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
};
|
||||
OpenLayers.Event.observe(this.imgDiv, "error",
|
||||
OpenLayers.Function.bind(onerror, this));
|
||||
|
||||
this.imgDiv.viewRequestID = this.layer.map.viewRequestID;
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: removeImgDiv
|
||||
* Removes the imgDiv from the DOM and stops listening to events on it.
|
||||
*/
|
||||
removeImgDiv: function() {
|
||||
// unregister the "load" and "error" handlers. Only the "error" handler if
|
||||
// this.layerAlphaHack is true.
|
||||
OpenLayers.Event.stopObservingElement(this.imgDiv);
|
||||
|
||||
if (this.imgDiv.parentNode == this.frame) {
|
||||
this.frame.removeChild(this.imgDiv);
|
||||
this.imgDiv.map = null;
|
||||
}
|
||||
this.imgDiv.urls = null;
|
||||
|
||||
var child = this.imgDiv.firstChild;
|
||||
//check for children (alphaHack img or IFrame)
|
||||
if (child) {
|
||||
OpenLayers.Event.stopObservingElement(child);
|
||||
this.imgDiv.removeChild(child);
|
||||
delete child;
|
||||
} else {
|
||||
// abort any currently loading image
|
||||
this.imgDiv.src = OpenLayers.Util.getImagesLocation() + "blank.gif";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user