]> git.openstreetmap.org Git - rails.git/blob - public/lib/OpenLayers/Layer/WMS/Untiled.js
4486c4f02aa31fd54d413ae69377e3fe702d01f8
[rails.git] / public / lib / OpenLayers / Layer / WMS / Untiled.js
1 /* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
2  * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
3  * text of the license. */
4 // @require: OpenLayers/Layer/Grid.js
5 /**
6 * @class
7 */
8 OpenLayers.Layer.WMS.Untiled = Class.create();
9 OpenLayers.Layer.WMS.Untiled.prototype = 
10   Object.extend( new OpenLayers.Layer.Grid(), {
11
12     /** @final @type hash */
13     DEFAULT_PARAMS: { service: "WMS",
14                       version: "1.1.1",
15                       request: "GetMap",
16                       styles: "",
17                       exceptions: "application/vnd.ogc.se_inimage",
18                       format: "image/jpeg"
19                      },
20
21     /**
22     * @constructor
23     *
24     * @param {str} name
25     * @param {str} url
26     * @param {hash} params
27     */
28     initialize: function(name, url, params) {
29         var newArguments = new Array();
30         if (arguments.length > 0) {
31             //uppercase params
32             params = OpenLayers.Util.upperCaseObject(params);
33             newArguments.push(name, url, params);
34         }
35         OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
36         
37         if (arguments.length > 0) {
38             OpenLayers.Util.applyDefaults(
39                            this.params, 
40                            OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
41                            );
42         }
43     },    
44
45     
46     /** WFS layer is never a base class. 
47      * @type Boolean
48      */
49     isBaseLayer: function() {
50         return (this.params.TRANSPARENT != true);
51     },
52     
53     /**
54     * @param {String} name
55     * @param {hash} params
56     *
57     * @returns A clone of this OpenLayers.Layer.WMS, with the passed-in
58     *          parameters merged in.
59     * @type OpenLayers.Layer.WMS
60     */
61     clone: function (name, params) {
62         var mergedParams = {};
63         Object.extend(mergedParams, this.params);
64         Object.extend(mergedParams, params);
65         var obj = new OpenLayers.Layer.WMS(name, this.url, mergedParams);
66         obj.setTileSize(this.tileSize);
67         return obj;
68     },
69
70     /**
71     * addTile creates a tile, initializes it (via 'draw' in this case), and 
72     * adds it to the layer div. 
73     *
74     * @param {OpenLayers.Bounds} bounds
75     *
76     * @returns The added OpenLayers.Tile.Image
77     * @type OpenLayers.Tile.Image
78     */
79     addTile:function(bounds,position) {
80         url = this.getFullRequestString(
81                      {BBOX:bounds.toBBOX(),
82                       WIDTH:this.map.getSize().w,
83                       HEIGHT:this.map.getSize().h});
84         
85         return new OpenLayers.Tile.Image(this, position, bounds, 
86                                              url, this.map.getSize());
87     },
88     moveTo:function(bounds,zoomChanged, minor) {
89         if (!minor) {
90             this.div.innerHTML = "";
91             tile = this.addTile(bounds, new OpenLayers.Pixel(-parseInt(this.map.layerContainerDiv.style.left), -parseInt(this.map.layerContainerDiv.style.top)));
92             tile.draw();
93         }
94     },
95     /** @final @type String */
96     CLASS_NAME: "OpenLayers.Layer.WMS.Untiled"
97 });