Merge branch 'three' of https://github.com/tschaub/openlayers into three
This commit is contained in:
@@ -3,3 +3,5 @@ goog.require('ol.bounds');
|
||||
goog.require("ol.map");
|
||||
goog.require("ol.loc");
|
||||
goog.require("ol.projection");
|
||||
|
||||
goog.require("ol.Tile");
|
||||
|
||||
52
src/ol/Tile.js
Normal file
52
src/ol/Tile.js
Normal file
@@ -0,0 +1,52 @@
|
||||
goog.provide('ol.Tile');
|
||||
|
||||
/**
|
||||
* The Tile class.
|
||||
* @constructor
|
||||
*/
|
||||
ol.Tile = function() {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Element}
|
||||
*/
|
||||
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);
|
||||
};
|
||||
})();
|
||||
@@ -9,13 +9,14 @@
|
||||
<script type="text/javascript" src="jasmine-1.2.0/jasmine-html.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script type="text/javascript" src="http://localhost:9810/compile?id=ol&mode=RAW"></script>
|
||||
<script type="text/javascript" src="http://localhost:9810/compile?id=ol&mode=SIMPLE"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script type="text/javascript" src="spec/ol/Bounds.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/Loc.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/Map.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/Projection.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/Tile.test.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
|
||||
24
test/spec/ol/Tile.test.js
Normal file
24
test/spec/ol/Tile.test.js
Normal file
@@ -0,0 +1,24 @@
|
||||
describe("ol.Tile", function() {
|
||||
|
||||
describe("creating a tile", function() {
|
||||
it("creates a tile instance", function() {
|
||||
var tile = new ol.Tile();
|
||||
expect(tile instanceof ol.Tile).toBe(true);
|
||||
});
|
||||
it("sets an image node in the instance", function() {
|
||||
var tile = new ol.Tile();
|
||||
expect(tile.getImg()).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("setting a source", function() {
|
||||
var tile;
|
||||
beforeEach(function() {
|
||||
tile = new ol.Tile();
|
||||
});
|
||||
it("sets the image source", function() {
|
||||
tile.setImgSrc("http://foo/img");
|
||||
expect(tile.getImg().src).toEqual("http://foo/img");
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user