Make tileSize a config option for ol.source.XYZ

This commit is contained in:
Andreas Hocevar
2014-09-04 11:59:43 -06:00
parent 5de537001f
commit ec00cd3222
3 changed files with 22 additions and 1 deletions

View File

@@ -5053,6 +5053,7 @@ olx.source.WMTSOptions.prototype.urls;
* minZoom: (number|undefined),
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
* tilePixelRatio: (number|undefined),
* tileSize: (number|undefined),
* tileUrlFunction: (ol.TileUrlFunctionType|undefined),
* url: (string|undefined),
* urls: (Array.<string>|undefined),
@@ -5129,6 +5130,14 @@ olx.source.XYZOptions.prototype.tileLoadFunction;
olx.source.XYZOptions.prototype.tilePixelRatio;
/**
* The tile size used by the tile service. Default is `256` pixels.
* @type {number|undefined}
* @api
*/
olx.source.XYZOptions.prototype.tileSize;
/**
* Optional function to get tile URL given a tile coordinate and the projection.
* Required if url or urls are not provided.

View File

@@ -22,7 +22,8 @@ ol.source.XYZ = function(options) {
var tileGrid = new ol.tilegrid.XYZ({
extent: ol.tilegrid.extentFromProjection(projection),
maxZoom: options.maxZoom
maxZoom: options.maxZoom,
tileSize: options.tileSize
});
goog.base(this, {

View File

@@ -3,6 +3,17 @@ goog.provide('ol.test.source.XYZ');
describe('ol.source.XYZ', function() {
describe('constructor', function() {
it('can be constructed with a custom tile size', function() {
var tileSource = new ol.source.XYZ({
tileSize: 512
});
expect(tileSource.getTileGrid().getTileSize(0)).to.be(512);
});
});
describe('tileUrlFunction', function() {
var xyzTileSource, tileGrid;