rewrite of Untiled.js to only create the div's once, and from then on just modify the attributes. this should be faster.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@930 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -89,6 +89,15 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/** Once HTTPRequest has set the map, we can load the image div
|
||||||
|
*
|
||||||
|
* @param {OpenLayers.Map} map
|
||||||
|
*/
|
||||||
|
setMap: function(map) {
|
||||||
|
OpenLayers.Layer.HTTPRequest.prototype.setMap.apply(this, arguments);
|
||||||
|
this.loadImageDiv();
|
||||||
|
},
|
||||||
|
|
||||||
/** When it is not a minor move (ie when panning or when done dragging)
|
/** When it is not a minor move (ie when panning or when done dragging)
|
||||||
* reload and recenter the div.
|
* reload and recenter the div.
|
||||||
*
|
*
|
||||||
@@ -98,59 +107,120 @@ OpenLayers.Layer.WMS.Untiled.prototype =
|
|||||||
*/
|
*/
|
||||||
moveTo:function(bounds, zoomChanged, minor) {
|
moveTo:function(bounds, zoomChanged, minor) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!minor) {
|
if (!minor) {
|
||||||
|
|
||||||
|
if (bounds == null) {
|
||||||
|
bounds = this.map.getExtent();
|
||||||
|
}
|
||||||
|
|
||||||
var size = this.map.getSize().copyOf();
|
var size = this.map.getSize().copyOf();
|
||||||
|
|
||||||
|
// get the url
|
||||||
//get the url
|
|
||||||
var url = this.getFullRequestString( {BBOX: bounds.toBBOX(),
|
var url = this.getFullRequestString( {BBOX: bounds.toBBOX(),
|
||||||
WIDTH: size.w,
|
WIDTH: size.w,
|
||||||
HEIGHT: size.h} );
|
HEIGHT: size.h} );
|
||||||
|
|
||||||
|
|
||||||
//clear previous wms image
|
// always position at upper left corner of current viewspace
|
||||||
this.div.innerHTML = "";
|
|
||||||
|
|
||||||
//always position at upper left corner of current viewspace
|
|
||||||
var tl = new OpenLayers.Pixel(0,0);
|
var tl = new OpenLayers.Pixel(0,0);
|
||||||
var pos = this.map.getLayerPxFromViewPortPx(tl);
|
var pos = this.map.getLayerPxFromViewPortPx(tl);
|
||||||
|
|
||||||
//create div
|
// first hide before all modifications
|
||||||
|
Element.hide(this.imgDiv);
|
||||||
|
|
||||||
|
// update div
|
||||||
|
var img = this.imgDiv;
|
||||||
if (this.transparent) {
|
if (this.transparent) {
|
||||||
this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null,
|
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
|
||||||
pos,
|
null,
|
||||||
size,
|
pos,
|
||||||
url,
|
size,
|
||||||
"absolute");
|
url);
|
||||||
|
img = this.imgDiv.childNodes[0];
|
||||||
} else {
|
} else {
|
||||||
this.imgDiv = OpenLayers.Util.createImage(null,
|
OpenLayers.Util.modifyDOMElement(this.imgDiv,
|
||||||
pos,
|
null,
|
||||||
size,
|
pos,
|
||||||
url,
|
size);
|
||||||
"absolute");
|
this.imgDiv.src = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.div.appendChild(this.imgDiv);
|
// wait until image is done loading to show again
|
||||||
|
Event.observe(img,
|
||||||
|
"load",
|
||||||
|
this.showDiv.bindAsEventListener(this));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/** Helper function that allows us to first hide the imgDiv, then make all
|
||||||
|
* the changes (position, size, url). Then when the url is done loading,
|
||||||
|
* we call this function to show the imgDiv.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
showDiv: function() {
|
||||||
|
Element.show(this.imgDiv);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Once HTTPRequest has updated the url, reload the image div
|
||||||
* @param {String} newUrl
|
* @param {String} newUrl
|
||||||
*/
|
*/
|
||||||
setUrl: function(newUrl) {
|
setUrl: function(newUrl) {
|
||||||
OpenLayers.Layer.HTTPRequest.prototype.setUrl.apply(this, arguments);
|
OpenLayers.Layer.HTTPRequest.prototype.setUrl.apply(this, arguments);
|
||||||
this.moveTo(this.map.getExtent());
|
this.moveTo();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/** Once HTTPRequest has updated new params, reload the image div
|
||||||
* @param {Object} newParams
|
* @param {Object} newParams
|
||||||
*/
|
*/
|
||||||
mergeNewParams:function(newParams) {
|
mergeNewParams:function(newParams) {
|
||||||
OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,
|
OpenLayers.Layer.HTTPRequest.prototype.mergeNewParams.apply(this,
|
||||||
arguments);
|
arguments);
|
||||||
this.moveTo(this.map.getExtent());
|
this.moveTo();
|
||||||
|
},
|
||||||
|
|
||||||
|
/** This function first removes the previous image div, then adds a new
|
||||||
|
* one according to the transparency property.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
loadImageDiv: function() {
|
||||||
|
|
||||||
|
var size = this.map.getSize().copyOf();
|
||||||
|
var bounds = this.map.getExtent();
|
||||||
|
|
||||||
|
var url = "";
|
||||||
|
if (bounds != null) {
|
||||||
|
url = this.getFullRequestString( {BBOX: bounds.toBBOX(),
|
||||||
|
WIDTH: size.w,
|
||||||
|
HEIGHT: size.h} );
|
||||||
|
}
|
||||||
|
|
||||||
|
//clear previous wms image (removes imgDiv)
|
||||||
|
this.div.innerHTML = "";
|
||||||
|
|
||||||
|
//always position at upper left corner of current viewspace
|
||||||
|
var tl = new OpenLayers.Pixel(0,0);
|
||||||
|
var pos = this.map.getLayerPxFromViewPortPx(tl);
|
||||||
|
|
||||||
|
//create div
|
||||||
|
if (this.transparent) {
|
||||||
|
this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null,
|
||||||
|
pos,
|
||||||
|
size,
|
||||||
|
url,
|
||||||
|
"absolute");
|
||||||
|
} else {
|
||||||
|
this.imgDiv = OpenLayers.Util.createImage(null,
|
||||||
|
pos,
|
||||||
|
size,
|
||||||
|
url,
|
||||||
|
"absolute");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.div.appendChild(this.imgDiv);
|
||||||
},
|
},
|
||||||
|
|
||||||
/** @final @type String */
|
/** @final @type String */
|
||||||
|
|||||||
Reference in New Issue
Block a user