Files
openlayers/lib/OpenLayers/Layer/WorldWind.js
crschmidt 0ba7961df4 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
2006-08-09 03:47:33 +00:00

78 lines
2.3 KiB
JavaScript

/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
* See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
* text of the license. */
// @require: OpenLayers/Layer/Grid.js
/**
* @class
*/
OpenLayers.Layer.WorldWind = Class.create();
OpenLayers.Layer.WorldWind.prototype =
Object.extend( new OpenLayers.Layer.Grid(), {
DEFAULT_PARAMS: {
},
/** WorldWind layer is always a base layer
*
* @type Boolean
*/
isBaseLayer: true,
// LevelZeroTileSizeDegrees
lzd: null,
zoomLevels: null,
initialize: function(name, url, lzd, zoomLevels, params) {
this.lzd = lzd;
this.zoomLevels = zoomLevels;
var newArguments = new Array();
newArguments.push(name, url, params);
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
this.params = (params ? params : {});
if (arguments.length > 0 && params) {
OpenLayers.Util.applyDefaults(
this.params,
this.DEFAULT_PARAMS
);
}
},
addTile:function(bounds,position) {
if (this.map.getResolution() <= (this.lzd/512)
&& this.getZoom() <= this.zoomLevels) {
return new OpenLayers.Tile.Image(this, position, bounds,
url, this.tileSize);
} else {
var tile = new Object();
tile.draw = function() {};
tile.destroy = function() {};
tile.bounds = bounds;
tile.bounds = position;
return tile;
}
},
getZoom: function () {
var zoom = this.map.getZoom();
var extent = this.map.getMaxExtent();
zoom = zoom - Math.log(this.map.maxResolution / (this.lzd/512))/Math.log(2);
return zoom;
},
getURL: function (bounds) {
var deg = this.lzd/Math.pow(2,this.getZoom());
var x = Math.floor((bounds.left - extent.left)/deg);
var y = Math.floor((bounds.bottom - extent.bottom)/deg);
return this.getFullRequestString(
{ L: zoom,
X: x,
Y: y
});
},
/** @final @type String */
CLASS_NAME: "OpenLayers.Layer.WorldWind"
});