getTemplate method to get the Mustache template from the TileJSON

This commit is contained in:
Petr Sloup
2014-09-30 11:43:24 +02:00
parent ef816d30ed
commit 4b605d40d9

View File

@@ -51,6 +51,12 @@ ol.source.TileUTFGrid = function(options) {
*/
this.tileCache = new ol.TileCache();
/**
* @private
* @type {string|undefined}
*/
this.template_ = undefined;
var request = new goog.net.Jsonp(options.url);
request.send(undefined, goog.bind(this.handleTileJSONResponse, this));
};
@@ -73,6 +79,15 @@ ol.source.TileUTFGrid.prototype.expireCache = function(usedTiles) {
};
/**
* @return {string|undefined} The template from TileJSON.
* @api
*/
ol.source.TileUTFGrid.prototype.getTemplate = function() {
return this.template_;
};
/**
* @param {ol.Coordinate} coordinate Coordinate.
* @param {number} resolution Resolution.
@@ -123,6 +138,8 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
});
this.tileGrid = tileGrid;
this.template_ = tileJSON.template;
var grids = tileJSON.grids;
if (!goog.isDefAndNotNull(grids)) {
this.setState(ol.source.State.ERROR);