From 1ede97ae18db33fc2ff4ff59efb43285e31680ab Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 18 Aug 2014 23:37:09 -0600 Subject: [PATCH] Respect the tileSize option for XYZ grids --- externs/olx.js | 14 +++++++++++--- src/ol/tilegrid/xyztilegrid.js | 6 ++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 4c170ec6e2..2773c35a18 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -5094,7 +5094,8 @@ olx.tilegrid.WMTSOptions.prototype.tileSizes; /** * @typedef {{extent: (ol.Extent|undefined), * maxZoom: (number|undefined), - * minZoom: (number|undefined)}} + * minZoom: (number|undefined), + * tileSize: (number|undefined)}} * @api */ olx.tilegrid.XYZOptions; @@ -5103,8 +5104,8 @@ olx.tilegrid.XYZOptions; /** * Extent for the tile grid. The origin for an XYZ tile grid is the top-left * corner of the extent. The zero level of the grid is defined by the - * resolution at which one 256 x 256 tile fits in the provided extent. If not - * provided, the extent of the EPSG:3857 projection is used. + * resolution at which one tile fits in the provided extent. If not provided, + * the extent of the EPSG:3857 projection is used. * @type {ol.Extent|undefined} */ olx.tilegrid.XYZOptions.prototype.extent; @@ -5124,6 +5125,13 @@ olx.tilegrid.XYZOptions.prototype.maxZoom; olx.tilegrid.XYZOptions.prototype.minZoom; +/** + * Tile size in pixels. Default is 256. (Only square tiles are supported.) + * @type {number|undefined} + */ +olx.tilegrid.XYZOptions.prototype.tileSize; + + /** * @typedef {{resolutions: !Array.}} * @api diff --git a/src/ol/tilegrid/xyztilegrid.js b/src/ol/tilegrid/xyztilegrid.js index 47638ebba0..60b5b1df8e 100644 --- a/src/ol/tilegrid/xyztilegrid.js +++ b/src/ol/tilegrid/xyztilegrid.js @@ -24,18 +24,16 @@ goog.require('ol.tilegrid.TileGrid'); * @api */ ol.tilegrid.XYZ = function(options) { - // TODO: accept a tileSize option - var tileSize = ol.DEFAULT_TILE_SIZE; var extent = goog.isDef(options.extent) ? options.extent : ol.proj.EPSG3857.EXTENT; var resolutions = ol.tilegrid.resolutionsFromExtent( - extent, options.maxZoom, tileSize); + extent, options.maxZoom, options.tileSize); goog.base(this, { minZoom: options.minZoom, origin: ol.extent.getCorner(extent, ol.extent.Corner.TOP_LEFT), resolutions: resolutions, - tileSize: tileSize + tileSize: options.tileSize }); };