Allow custom tileGrid in ol.source.XYZ
This commit is contained in:
@@ -5358,6 +5358,7 @@ olx.source.WMTSOptions.prototype.wrapX;
|
|||||||
* projection: ol.proj.ProjectionLike,
|
* projection: ol.proj.ProjectionLike,
|
||||||
* maxZoom: (number|undefined),
|
* maxZoom: (number|undefined),
|
||||||
* minZoom: (number|undefined),
|
* minZoom: (number|undefined),
|
||||||
|
* tileGrid: (ol.tilegrid.TileGrid|undefined),
|
||||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
|
||||||
* tilePixelRatio: (number|undefined),
|
* tilePixelRatio: (number|undefined),
|
||||||
* tileSize: (number|ol.Size|undefined),
|
* tileSize: (number|ol.Size|undefined),
|
||||||
@@ -5422,6 +5423,14 @@ olx.source.XYZOptions.prototype.maxZoom;
|
|||||||
olx.source.XYZOptions.prototype.minZoom;
|
olx.source.XYZOptions.prototype.minZoom;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tile grid.
|
||||||
|
* @type {ol.tilegrid.TileGrid}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.source.XYZOptions.prototype.tileGrid;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optional function to load a tile given a URL.
|
* Optional function to load a tile given a URL.
|
||||||
* @type {ol.TileLoadFunctionType|undefined}
|
* @type {ol.TileLoadFunctionType|undefined}
|
||||||
|
|||||||
@@ -19,11 +19,12 @@ ol.source.XYZ = function(options) {
|
|||||||
var projection = goog.isDef(options.projection) ?
|
var projection = goog.isDef(options.projection) ?
|
||||||
options.projection : 'EPSG:3857';
|
options.projection : 'EPSG:3857';
|
||||||
|
|
||||||
var tileGrid = ol.tilegrid.createXYZ({
|
var tileGrid = goog.isDef(options.tileGrid) ? options.tileGrid :
|
||||||
extent: ol.tilegrid.extentFromProjection(projection),
|
ol.tilegrid.createXYZ({
|
||||||
maxZoom: options.maxZoom,
|
extent: ol.tilegrid.extentFromProjection(projection),
|
||||||
tileSize: options.tileSize
|
maxZoom: options.maxZoom,
|
||||||
});
|
tileSize: options.tileSize
|
||||||
|
});
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
attributions: options.attributions,
|
attributions: options.attributions,
|
||||||
|
|||||||
@@ -5,6 +5,14 @@ describe('ol.source.XYZ', function() {
|
|||||||
|
|
||||||
describe('constructor', function() {
|
describe('constructor', function() {
|
||||||
|
|
||||||
|
it('can be constructed with a custom tile grid', function() {
|
||||||
|
var tileGrid = ol.tilegrid.createXYZ();
|
||||||
|
var tileSource = new ol.source.XYZ({
|
||||||
|
tileGrid: tileGrid
|
||||||
|
});
|
||||||
|
expect(tileSource.getTileGrid()).to.be(tileGrid);
|
||||||
|
});
|
||||||
|
|
||||||
it('can be constructed with a custom tile size', function() {
|
it('can be constructed with a custom tile size', function() {
|
||||||
var tileSource = new ol.source.XYZ({
|
var tileSource = new ol.source.XYZ({
|
||||||
tileSize: 512
|
tileSize: 512
|
||||||
|
|||||||
Reference in New Issue
Block a user