From 433b12c39ab51bac3b90d5a615396b55ae6f2e54 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 26 Oct 2012 22:51:30 +0200 Subject: [PATCH] Using the projection's extent for resolutions math by default This ensures that maps with WMS layers with different extents do not scale the tiles differently for each layer when the default tileGrid is used. Note that it is always possible to configure WMS sources with a custom tileGrid. --- src/ol/source/tiledwmssource.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ol/source/tiledwmssource.js b/src/ol/source/tiledwmssource.js index efbfe447df..8ad8e4be12 100644 --- a/src/ol/source/tiledwmssource.js +++ b/src/ol/source/tiledwmssource.js @@ -39,6 +39,7 @@ ol.source.TiledWMS = function(tiledWMSOptions) { var projection = goog.isDef(tiledWMSOptions.projection) ? tiledWMSOptions.projection : ol.Projection.getFromCode('EPSG:3857'); + var projectionExtent = projection.getExtent(); var extent = goog.isDef(tiledWMSOptions.extent) ? tiledWMSOptions.extent : projection.getExtent(); @@ -49,7 +50,9 @@ ol.source.TiledWMS = function(tiledWMSOptions) { var tileGrid = tiledWMSOptions.tileGrid; if (!goog.isDef(tileGrid)) { // FIXME Factor this out to a more central/generic place. - var size = Math.max(extent.maxX - extent.minX, extent.maxY - extent.minY); + var size = Math.max( + projectionExtent.maxX - projectionExtent.minX, + projectionExtent.maxY - projectionExtent.minY); var maxZoom = goog.isDef(tiledWMSOptions.maxZoom) ? tiledWMSOptions.maxZoom : 18; var resolutions = new Array(maxZoom + 1); @@ -100,7 +103,6 @@ ol.source.TiledWMS = function(tiledWMSOptions) { return null; } var x = tileCoord.x; - var projectionExtent = projection.getExtent(); // FIXME do we want a wrapDateLine param? The code below will break maps // with projections that do not span the whole world width. if (extent.minX === projectionExtent.minX &&