版本2.10
/*2010-11-21 huanggp 修改2处对象为空错误保护
lib\OpenLayers\Tile\Image.js
281行
renderTile: function() {
if (this.imgDiv == null) {
this.initImgDiv();
}
try{
this.imgDiv.viewRequestID = this.layer.map.viewRequestID;
}catch(e){
}
if (this.layer.async) {
// 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
// the callback 'positionFrame' when the image request returns.
this.layer.getURLasync(this.bounds, this, "url", this.positionImage);
} else {
// 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);
// position the frame immediately
this.positionImage();
}
return true;
},
lib\OpenLayers\Layer.js
917行
getResolution: function() {
try{
var zoom = this.map.getZoom();
return this.getResolutionForZoom(zoom);
}catch(e){
}
},
*/
/*2011-01-10 huanggp 修改1处对象为空错误保护
lib\OpenLayers\Layer\Grid.js
624行
shiftRow:function(prepend) {
var modelRowIndex = (prepend) ? 0 : (this.grid.length - 1);
var grid = this.grid;
var modelRow = grid[modelRowIndex];
var resolution = this.map.getResolution();
var deltaY = (prepend) ? -this.tileSize.h : this.tileSize.h;
var deltaLat = resolution * -deltaY;
var row = (prepend) ? grid.pop() : grid.shift();
for (var i=0, len=modelRow.length; i<len; i++) {
var modelTile = modelRow[i];
var bounds = modelTile.bounds.clone();
var position = modelTile.position.clone();
bounds.bottom = bounds.bottom + deltaLat;
bounds.top = bounds.top + deltaLat;
position.y = position.y + deltaY;
try{
row[i].moveTo(bounds, position);
}catch(e){
}
}
if (prepend) {
grid.unshift(row);
} else {
grid.push(row);
}
},
*/
/*2011-01-19 yangkun 恢复1处对象为空错误保护
lib\OpenLayers\Layer\Grid.js
624行
shiftRow:function(prepend) {
var modelRowIndex = (prepend) ? 0 : (this.grid.length - 1);
var grid = this.grid;
var modelRow = grid[modelRowIndex];
var resolution = this.map.getResolution();
var deltaY = (prepend) ? -this.tileSize.h : this.tileSize.h;
var deltaLat = resolution * -deltaY;
var row = (prepend) ? grid.pop() : grid.shift();
for (var i=0, len=modelRow.length; i<len; i++) {
var modelTile = modelRow[i];
var bounds = modelTile.bounds.clone();
var position = modelTile.position.clone();
bounds.bottom = bounds.bottom + deltaLat;
bounds.top = bounds.top + deltaLat;
position.y = position.y + deltaY;
row[i].moveTo(bounds, position);
}
if (prepend) {
grid.unshift(row);
} else {
grid.push(row);
}
},
*/
/*2011-05-21 huanggp 修改显示过度效果
OpenLayers/lib/OpenLayers/Tile/Image.js
/**
* Method: startTransition 开始显示过度效果
* This method is invoked on tiles that are backBuffers for tiles in the
* grid. The grid tile is about to be cleared and a new tile source
* loaded. This is where the transition effect needs to be started
* to provide visual continuity.
*/
startTransition: function() {
// backBufferTile has to be valid and ready to use
if (!this.backBufferTile || !this.backBufferTile.imgDiv) {
return;
}
// calculate the ratio of change between the current resolution of the
// backBufferTile and the layer. If several animations happen in a
// row, then the backBufferTile will scale itself appropriately for
// each request.
var ratio = 1;
if (this.backBufferTile.resolution) {
ratio = this.backBufferTile.resolution / this.layer.getResolution();
}
// if the ratio is not the same as it was last time (i.e. we are
// zooming), then we need to adjust the backBuffer tile
//A
//OpenLayers
//if (ratio != this.lastRatio) {
//update by huanggp
if (this.backBufferTile.resolution != this.layer.getResolution()) {
if (this.layer.transitionEffect == 'resize') {
// In this case, we can just immediately resize the
// backBufferTile.
var upperLeft = new OpenLayers.LonLat(
this.backBufferTile.bounds.left,
this.backBufferTile.bounds.top
);
var size = new OpenLayers.Size(
this.backBufferTile.size.w * ratio,
this.backBufferTile.size.h * ratio
);
var px = this.layer.map.getLayerPxFromLonLat(upperLeft);
OpenLayers.Util.modifyDOMElement(this.backBufferTile.frame,
null, px, size);
var imageSize = this.backBufferTile.imageSize;
imageSize = new OpenLayers.Size(imageSize.w * ratio,
imageSize.h * ratio);
var imageOffset = this.backBufferTile.imageOffset;
if(imageOffset) {
imageOffset = new OpenLayers.Pixel(
imageOffset.x * ratio, imageOffset.y * ratio
);
}
OpenLayers.Util.modifyDOMElement(
this.backBufferTile.imgDiv, null, imageOffset, imageSize
) ;
this.backBufferTile.show();
}
} else {
// default effect is just to leave the existing tile
// until the new one loads if this is a singleTile and
// there was no change in resolution. Otherwise we
// don't bother to show the backBufferTile at all
if (this.layer.singleTile) {
this.backBufferTile.show();
} else {
this.backBufferTile.hide();
}
}
this.lastRatio = ratio;
},
OpenLayers/lib/OpenLayers/Layer.js
/**
* APIMethod: getResolutionForZoom 根据地图显示级别获取图层当前分辨率
*
* Parameter:
* zoom - {Float}
*
* Returns:
* {Float} A suitable resolution for the specified zoom.
*/
getResolutionForZoom: function(zoom) {
//B
//OpenLayers
//zoom = Math.max(0, Math.min(zoom, this.resolutions.length - 1));
//update by huanggp
if(this.options.topLevel){
zoom = Math.max(0, Math.min(zoom - this.options.topLevel, this.resolutions.length - 1));
}else{
zoom = Math.max(0, Math.min(zoom, this.resolutions.length - 1));
}
var resolution;
if(this.map.fractionalZoom) {
var low = Math.floor(zoom);
var high = Math.ceil(zoom);
resolution = this.resolutions[low] -