Commit an untiled WMS class, per discussion in #kamap. Partly this is a demonstration of how quick it can be to develop in OpenLayers.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@672 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
<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');
|
||||||
|
|
||||||
|
var ol_wms = new OpenLayers.Layer.UntiledWMS( "OpenLayers WMS",
|
||||||
|
"http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'} );
|
||||||
|
|
||||||
|
map.addLayers([ol_wms]);
|
||||||
|
map.addControl(new OpenLayers.Control.LayerSwitcher());
|
||||||
|
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
|
||||||
|
}
|
||||||
|
// -->
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body onload="init()">
|
||||||
|
<h1>OpenLayers Example</h1>
|
||||||
|
<div id="map"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -65,6 +65,7 @@ if (typeof(_OPENLAYERS_SFL_) == "undefined") {
|
|||||||
// "OpenLayers/Layer/Yahoo.js",
|
// "OpenLayers/Layer/Yahoo.js",
|
||||||
"OpenLayers/Layer/Grid.js",
|
"OpenLayers/Layer/Grid.js",
|
||||||
"OpenLayers/Layer/KaMap.js",
|
"OpenLayers/Layer/KaMap.js",
|
||||||
|
"OpenLayers/Layer/UntiledWMS.js",
|
||||||
"OpenLayers/Layer/Markers.js",
|
"OpenLayers/Layer/Markers.js",
|
||||||
"OpenLayers/Layer/Text.js",
|
"OpenLayers/Layer/Text.js",
|
||||||
"OpenLayers/Layer/WMS.js",
|
"OpenLayers/Layer/WMS.js",
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
/* 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.UntiledWMS = Class.create();
|
||||||
|
OpenLayers.Layer.UntiledWMS.prototype =
|
||||||
|
Object.extend( new OpenLayers.Layer.Grid(), {
|
||||||
|
|
||||||
|
/** @final @type hash */
|
||||||
|
DEFAULT_PARAMS: { service: "WMS",
|
||||||
|
version: "1.1.1",
|
||||||
|
request: "GetMap",
|
||||||
|
styles: "",
|
||||||
|
exceptions: "application/vnd.ogc.se_inimage",
|
||||||
|
format: "image/jpeg"
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*
|
||||||
|
* @param {str} name
|
||||||
|
* @param {str} url
|
||||||
|
* @param {hash} params
|
||||||
|
*/
|
||||||
|
initialize: function(name, url, params) {
|
||||||
|
var newArguments = new Array();
|
||||||
|
if (arguments.length > 0) {
|
||||||
|
//uppercase params
|
||||||
|
params = OpenLayers.Util.upperCaseObject(params);
|
||||||
|
newArguments.push(name, url, params);
|
||||||
|
}
|
||||||
|
OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
|
||||||
|
|
||||||
|
if (arguments.length > 0) {
|
||||||
|
OpenLayers.Util.applyDefaults(
|
||||||
|
this.params,
|
||||||
|
OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/** WFS layer is never a base class.
|
||||||
|
* @type Boolean
|
||||||
|
*/
|
||||||
|
isBaseLayer: function() {
|
||||||
|
return (this.params.TRANSPARENT != true);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {String} name
|
||||||
|
* @param {hash} params
|
||||||
|
*
|
||||||
|
* @returns A clone of this OpenLayers.Layer.WMS, with the passed-in
|
||||||
|
* parameters merged in.
|
||||||
|
* @type OpenLayers.Layer.WMS
|
||||||
|
*/
|
||||||
|
clone: function (name, params) {
|
||||||
|
var mergedParams = {};
|
||||||
|
Object.extend(mergedParams, this.params);
|
||||||
|
Object.extend(mergedParams, params);
|
||||||
|
var obj = new OpenLayers.Layer.WMS(name, this.url, mergedParams);
|
||||||
|
obj.setTileSize(this.tileSize);
|
||||||
|
return obj;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* addTile creates a tile, initializes it (via 'draw' in this case), and
|
||||||
|
* adds it to the layer div.
|
||||||
|
*
|
||||||
|
* @param {OpenLayers.Bounds} bounds
|
||||||
|
*
|
||||||
|
* @returns The added OpenLayers.Tile.Image
|
||||||
|
* @type OpenLayers.Tile.Image
|
||||||
|
*/
|
||||||
|
addTile:function(bounds,position) {
|
||||||
|
url = this.getFullRequestString(
|
||||||
|
{BBOX:bounds.toBBOX(),
|
||||||
|
WIDTH:this.map.getSize().w,
|
||||||
|
HEIGHT:this.map.getSize().h});
|
||||||
|
|
||||||
|
return new OpenLayers.Tile.Image(this, position, bounds,
|
||||||
|
url, this.map.getSize());
|
||||||
|
},
|
||||||
|
moveTo:function(bounds,zoomChanged) {
|
||||||
|
this.div.innerHTML = "";
|
||||||
|
tile = this.addTile(bounds, new OpenLayers.Pixel(-parseInt(this.map.layerContainerDiv.style.left), -parseInt(this.map.layerContainerDiv.style.top)));
|
||||||
|
tile.draw();
|
||||||
|
},
|
||||||
|
/** @final @type String */
|
||||||
|
CLASS_NAME: "OpenLayers.Layer.UntiledWMS"
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user