Add worldwind support to OpenLayers. To define a worldwind layer, you need a URL, a lzd (level zero degrees), a maxZoom level, and a param name 'T' to define the map you're pulling from.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@695 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2006-06-23 04:20:46 +00:00
parent bd166b5ac1
commit e0c564c0e3
3 changed files with 102 additions and 0 deletions

41
examples/worldwind.html Normal file
View File

@@ -0,0 +1,41 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
#map {
width: 800px;
height: 475px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
<!--
function init(){
var map = new OpenLayers.Map('map', {'maxResolution': .0703125*4});
var ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
var ww = new OpenLayers.Layer.WorldWind( "Bathy",
"http://worldwind25.arc.nasa.gov/tile/tile.aspx?", 36, 4,
{T:"bmng.topo.bathy.200406"});
ww.setTileSize(new OpenLayers.Size(512,512));
var ww2 = new OpenLayers.Layer.WorldWind( "LANDSAT",
"http://worldwind25.arc.nasa.gov/tile/tile.aspx", 2.25, 4,
{T:"105"});
ww2.setTileSize(new OpenLayers.Size(512,512));
map.addLayers([ol_wms, ww, ww2]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(-71.4, 42.3), 8);
}
// -->
</script>
</head>
<body onload="init()">
<h1>OpenLayers Example</h1>
<div id="map"></div>
</body>
</html>

View File

@@ -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",

View File

@@ -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"
});