]> git.openstreetmap.org Git - rails.git/blob - public/lib/OpenLayers/Control.js
bugfix for non-intersecting intersections (trac #592)
[rails.git] / public / lib / OpenLayers / Control.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.Control = Class.create();
8 OpenLayers.Control.prototype = {
9
10     /** this gets set in the addControl() function in OpenLayers.Map
11     * @type OpenLayers.Map */
12     map: null,
13
14     /** @type DOMElement */
15     div: null,
16
17     /** @type OpenLayers.Pixel */
18     position: null,
19
20     /**
21     * @constructor
22     */
23     initialize: function (options) {
24         Object.extend(this, options);
25     },
26
27     /**
28     * @param {OpenLayers.Pixel} px
29     *
30     * @returns A reference to the DIV DOMElement containing the control
31     * @type DOMElement
32     */
33     draw: function (px) {
34         if (this.div == null) {
35             this.div = OpenLayers.Util.createDiv();
36         }
37         if (px != null) {
38             this.position = px.copyOf();
39         }
40         this.moveTo(this.position);        
41         return this.div;
42     },
43
44     /**
45     * @param {OpenLayers.Pixel} px
46     */
47     moveTo: function (px) {
48         if ((px != null) && (this.div != null)) {
49             this.div.style.left = px.x + "px";
50             this.div.style.top = px.x + "px";
51         }
52     },
53
54     /**
55     */
56     destroy: function () {
57         // eliminate circular references
58         this.map = null;
59     },
60
61     /** @final @type String */
62     CLASS_NAME: "OpenLayers.Control"
63 };