add an ol.Tile class

This commit is contained in:
Éric Lemoine
2012-06-19 14:50:27 +02:00
parent 1043a53fe1
commit ce20ba066c
4 changed files with 77 additions and 0 deletions

50
src/ol/Tile.js Normal file
View File

@@ -0,0 +1,50 @@
goog.provide('ol.Tile');
/**
* @constructor
*/
ol.Tile = function() {
/**
* @private
*/
this.img_ = ol.Tile.createImage();
};
/**
* Load the tile for a given URL.
* @param {string} src The src URL.
*/
ol.Tile.prototype.load = function(src) {
this.setImgSrc(src);
};
/**
* Set the image src.
* @param {string|undefined} src The src URL.
* @return {ol.Tile}
*/
ol.Tile.prototype.setImgSrc = function(src) {
this.img_.src = src;
return this;
};
/**
* Get the image node.
* @return {Element}
*/
ol.Tile.prototype.getImg = function() {
return this.img_;
};
/**
* Create an image node. This is done by cloning
* an image template.
* @return {Element}
*/
ol.Tile.createImage = (function() {
var img = document.createElement("img");
return function() {
return img.cloneNode(false);
};
})();