]> git.openstreetmap.org Git - rails.git/blob - public/lib/OpenLayers/Layer.js
be a bit more specific when a way is a member of a relation. Actually return an error...
[rails.git] / public / lib / OpenLayers / Layer.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 /**
5  * @class
6  */
7 OpenLayers.Layer = Class.create();
8 OpenLayers.Layer.prototype = {
9
10     /** @type String */
11     name: null,
12
13     /** @type DOMElement */
14     div: null,
15
16     /** This variable is set in map.addLayer, not within the layer itself
17     * @type OpenLayers.Map */
18     map: null,
19     
20     /**
21      * @constructor
22      * 
23      * @param {String} name
24      */
25     initialize: function(name) {
26         if (arguments.length > 0) {
27             this.name = name;
28             if (this.div == null) {
29                 this.div = OpenLayers.Util.createDiv();
30                 this.div.style.width = "100%";
31                 this.div.style.height = "100%";
32             }
33         }
34     },
35     
36     /**
37      * Destroy is a destructor: this is to alleviate cyclic references which
38      * the Javascript garbage cleaner can not take care of on its own.
39      */
40     destroy: function() {
41         if (this.map != null) {
42             this.map.removeLayer(this);
43         }
44         this.map = null;
45     },
46
47     /**
48     * @params {OpenLayers.Bounds} bound
49     * @params {Boolean} zoomChanged tells when zoom has changed, as layers have to do some init work in that case.
50     */
51     moveTo: function (bound, zoomChanged) {
52         // not implemented here
53         return;
54     },
55     
56     /**
57      * @param {OpenLayers.Map} map
58      */
59     setMap: function(map) {
60         this.map = map;
61     },
62   
63     /**
64      * @returns Whether or not the layer is a base layer. This should be 
65      *          determined individually by all subclasses. 
66      * @type Boolean
67      */
68     isBaseLayer: function() {
69        //this function should be implemented by all subclasses.
70     },
71     
72     /**
73     * @returns Whether or not the layer is visible
74     * @type Boolean
75     */
76     getVisibility: function() {
77         return (this.div.style.display != "none");
78     },
79
80     /** 
81     * @param {bool} visible
82     */
83     setVisibility: function(visible) {
84         this.div.style.display = (visible) ? "block" : "none";
85         if ((visible) && (this.map != null)) {
86             this.moveTo(this.map.getExtent());
87         }
88     },
89     
90     /** @final @type String */
91     CLASS_NAME: "OpenLayers.Layer"
92 };