diff --git a/examples/worldwind.html b/examples/worldwind.html new file mode 100644 index 0000000000..8bb076920e --- /dev/null +++ b/examples/worldwind.html @@ -0,0 +1,41 @@ + + + + + + + +

OpenLayers Example

+
+ + diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index b56d55edda..567d28cef9 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -67,6 +67,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") { "OpenLayers/Layer/KaMap.js", "OpenLayers/Layer/Markers.js", "OpenLayers/Layer/Text.js", + "OpenLayers/Layer/WorldWind.js", "OpenLayers/Layer/WMS.js", "OpenLayers/Layer/WFS.js", "OpenLayers/Layer/WMS/Untiled.js", diff --git a/lib/OpenLayers/Layer/WorldWind.js b/lib/OpenLayers/Layer/WorldWind.js new file mode 100644 index 0000000000..53929db2e4 --- /dev/null +++ b/lib/OpenLayers/Layer/WorldWind.js @@ -0,0 +1,60 @@ +/* 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: { + }, + + // 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) { + var zoom = this.map.getZoom(); + var extent = this.map.getFullExtent(); + zoom = zoom - Math.log(this.map.maxResolution / (this.lzd/512))/Math.log(2); + if (this.map.getResolution() <= (this.lzd/512) && zoom <= this.zoomLevels) { + var deg = this.lzd/Math.pow(2,zoom); + var x = Math.floor((bounds.left - extent.left)/deg); + var y = Math.floor((bounds.bottom - extent.bottom)/deg); + var url = this.getFullRequestString( + { L: zoom, + X: x, + Y: y + }); + 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; + } + }, + /** @final @type String */ + CLASS_NAME: "OpenLayers.Layer.WorldWind" +});