From 843334627ed91f464d91591b94885d7adbf6fce2 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 10 Sep 2013 18:27:53 -0600 Subject: [PATCH] Moving maxZoom default to XYZ source. No reason this convenience should be restricted to the OSM layer. --- src/objectliterals.jsdoc | 3 ++- src/ol/source/osmsource.js | 4 +--- src/ol/source/xyzsource.js | 4 +++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 5d5f2e11eb..47e3fd108e 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -613,7 +613,8 @@ * @property {ol.Extent|undefined} extent Extent. * @property {string|undefined} logo Logo. * @property {ol.ProjectionLike} projection Projection. - * @property {number} maxZoom Max zoom. + * @property {number|undefined} maxZoom Optional max zoom level. The default is + * 18. * @property {number|undefined} minZoom Unsupported (TODO: remove this). * @property {ol.TileUrlFunctionType|undefined} tileUrlFunction Optional * function to get tile URL given a tile coordinate and the projection. diff --git a/src/ol/source/osmsource.js b/src/ol/source/osmsource.js index cc759a3653..cab05acca9 100644 --- a/src/ol/source/osmsource.js +++ b/src/ol/source/osmsource.js @@ -23,8 +23,6 @@ ol.source.OSM = function(opt_options) { attributions = ol.source.OSM.ATTRIBUTIONS; } - var maxZoom = goog.isDef(options.maxZoom) ? options.maxZoom : 18; - var url = goog.isDef(options.url) ? options.url : 'http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'; @@ -32,7 +30,7 @@ ol.source.OSM = function(opt_options) { attributions: attributions, crossOrigin: 'anonymous', opaque: true, - maxZoom: maxZoom, + maxZoom: options.maxZoom, url: url }); diff --git a/src/ol/source/xyzsource.js b/src/ol/source/xyzsource.js index c40d20865e..885964eab2 100644 --- a/src/ol/source/xyzsource.js +++ b/src/ol/source/xyzsource.js @@ -33,8 +33,10 @@ ol.source.XYZ = function(options) { ol.TileUrlFunction.expandUrl(options.url)); } + var maxZoom = goog.isDef(options.maxZoom) ? options.maxZoom : 18; + var tileGrid = new ol.tilegrid.XYZ({ - maxZoom: options.maxZoom + maxZoom: maxZoom }); var tileCoordTransform = tileGrid.createTileCoordTransform({