Project

General

Profile

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
/*
6
 * @class 
7
 * 
8
 * This is a class designed to designate a single tile, however
9
 * it is explicitly designed to do relatively little. Tiles store information
10
 * about themselves -- such as the URL that they are related to, and their 
11
 * size - but do not add themselves to the layer div automatically, for 
12
 * example.
13
 */
14
OpenLayers.Tile = Class.create();
15
OpenLayers.Tile.prototype = {
16
    
17
    /** @type String */
18
    id: null,
19
    
20
    /** @type OpenLayers.Layer */
21
    layer: null,
22
    
23
    /** @type String url of the request */
24
    url:null,
25

    
26
    /** @type OpenLayers.Bounds */
27
    bounds:null,
28
    
29
    /** @type OpenLayers.Size */
30
    size:null,
31
    
32
    /** Top Left pixel of the tile
33
    * @type OpenLayers.Pixel */
34
    position:null,
35

    
36
    /** @type Boolean */
37
    drawn: false,
38

    
39
    /**
40
    * @constructor
41
    *
42
    * @param {OpenLayers.Layer} layer
43
    * @param {OpenLayers.Pixel} position
44
    * @param {OpenLayers.Bounds} bounds
45
    * @param {String} url
46
    * @param {OpenLayers.Size} size
47
    */   
48
    initialize: function(layer, position, bounds, url, size) {
49
        if (arguments.length > 0) {
50
            this.layer = layer;
51
            this.position = position;
52
            this.bounds = bounds;
53
            this.url = url;
54
            this.size = size;
55

    
56
            //give the tile a unique id based on its BBOX.
57
            this.id = OpenLayers.Util.createUniqueID("Tile_");
58
        }
59
    },
60
    
61
    /** nullify references to prevent circular references and memory leaks
62
    */
63
    destroy:function() {
64
        this.layer  = null;
65
        this.bounds = null;
66
        this.size = null;
67
        this.position = null;
68
    },
69

    
70
    /**
71
    */
72
    draw:function() {
73
        this.drawn = true;
74
    },
75
    
76
    /** 
77
     * @param {OpenLayers.Bounds}
78
     * @param {OpenLayers.pixel} position
79
     * @param {Boolean} redraw Redraw tile after moving? 
80
     *                         Default is true
81
     */
82
    moveTo: function (bounds, position, redraw) {
83
        if (redraw == null) {
84
            redraw = true;
85
        }
86

    
87
        this.clear();
88
        this.bounds = bounds.clone();
89
        this.position = position.clone();
90
        if (redraw) {
91
            this.draw();
92
        }
93
    },
94

    
95
    /** Clear the tile of any bounds/position-related data so that it can 
96
     *   be reused in a new location.
97
     */
98
    clear: function() {
99
        this.drawn = false;
100
    },
101

    
102
    /** @final @type String */
103
    CLASS_NAME: "OpenLayers.Tile"
104
};
105

    
(12-12/13)