Commit tile-reuse branch back to trunk. This branch offers numerous performance
improvements in the form of reduced memory use and lower element creating costs, hopefully making the OpenLayers code more usable in internet explorer as well as less of a memory hog in Firefox and other browsers. Additionally, a buffer is available around the main map grid which allows tiles to be loaded outside of the viewing area for faster dragging. git-svn-id: http://svn.openlayers.org/trunk/openlayers@1137 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -773,14 +773,25 @@ OpenLayers.Util.createDiv = function(id, px, sz, imgURL, position,
|
||||
* @param {String} imgURL
|
||||
* @param {String} position
|
||||
* @param {String} border
|
||||
* @param {Boolean} delayDisplay
|
||||
*
|
||||
* @returns A DOM Image created with the specified attributes.
|
||||
* @type DOMElement
|
||||
*/
|
||||
OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border) {
|
||||
OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border,
|
||||
delayDisplay) {
|
||||
|
||||
image = document.createElement("img");
|
||||
|
||||
if(delayDisplay) {
|
||||
image.style.display = "none";
|
||||
Event.observe(image, "load",
|
||||
OpenLayers.Util.onImageLoad.bindAsEventListener(image));
|
||||
Event.observe(image, "error",
|
||||
OpenLayers.Util.onImageLoadError.bindAsEventListener(image));
|
||||
|
||||
}
|
||||
|
||||
//set special properties
|
||||
image.style.alt = id;
|
||||
image.galleryImg = "no";
|
||||
@@ -796,10 +807,22 @@ OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border) {
|
||||
position = "relative";
|
||||
}
|
||||
OpenLayers.Util.modifyDOMElement(image, id, px, sz, position, border);
|
||||
|
||||
|
||||
return image;
|
||||
};
|
||||
|
||||
|
||||
OpenLayers.Util.onImageLoad = function() {
|
||||
this.style.backgroundColor = null;
|
||||
this.style.display = "";
|
||||
};
|
||||
|
||||
OpenLayers.Util.onImageLoadError = function() {
|
||||
this.style.backgroundColor = "pink";
|
||||
};
|
||||
|
||||
|
||||
OpenLayers.Util.alphaHack = function() {
|
||||
var arVersion = navigator.appVersion.split("MSIE");
|
||||
var version = parseFloat(arVersion[1]);
|
||||
@@ -852,18 +875,28 @@ OpenLayers.Util.modifyAlphaImageDiv = function(div, id, px, sz, imgURL,
|
||||
* @param {String} position
|
||||
* @param {String} border
|
||||
* @param {String} sizing 'crop', 'scale', or 'image'. Default is "scale"
|
||||
* @param {Boolean} delayDisplay
|
||||
*
|
||||
* @returns A DOM Div created with a DOM Image inside it. If the hack is
|
||||
* needed for transparency in IE, it is added.
|
||||
* @type DOMElement
|
||||
*/
|
||||
OpenLayers.Util.createAlphaImageDiv = function(id, px, sz, imgURL,
|
||||
position, border, sizing) {
|
||||
position, border, sizing, delayDisplay) {
|
||||
|
||||
var div = OpenLayers.Util.createDiv();
|
||||
var img = OpenLayers.Util.createImage();
|
||||
var img = OpenLayers.Util.createImage(null, null, null, null, null, null,
|
||||
false);
|
||||
div.appendChild(img);
|
||||
|
||||
if (delayDisplay) {
|
||||
img.style.display = "none";
|
||||
Event.observe(img, "load",
|
||||
OpenLayers.Util.onImageLoad.bindAsEventListener(div));
|
||||
Event.observe(img, "error",
|
||||
OpenLayers.Util.onImageLoadError.bindAsEventListener(div));
|
||||
}
|
||||
|
||||
OpenLayers.Util.modifyAlphaImageDiv(div, id, px, sz, imgURL,
|
||||
position, border, sizing);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user