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.
This commit is contained in:
@@ -39,6 +39,7 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
|
|||||||
|
|
||||||
var projection = goog.isDef(tiledWMSOptions.projection) ?
|
var projection = goog.isDef(tiledWMSOptions.projection) ?
|
||||||
tiledWMSOptions.projection : ol.Projection.getFromCode('EPSG:3857');
|
tiledWMSOptions.projection : ol.Projection.getFromCode('EPSG:3857');
|
||||||
|
var projectionExtent = projection.getExtent();
|
||||||
|
|
||||||
var extent = goog.isDef(tiledWMSOptions.extent) ?
|
var extent = goog.isDef(tiledWMSOptions.extent) ?
|
||||||
tiledWMSOptions.extent : projection.getExtent();
|
tiledWMSOptions.extent : projection.getExtent();
|
||||||
@@ -49,7 +50,9 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
|
|||||||
var tileGrid = tiledWMSOptions.tileGrid;
|
var tileGrid = tiledWMSOptions.tileGrid;
|
||||||
if (!goog.isDef(tileGrid)) {
|
if (!goog.isDef(tileGrid)) {
|
||||||
// FIXME Factor this out to a more central/generic place.
|
// 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) ?
|
var maxZoom = goog.isDef(tiledWMSOptions.maxZoom) ?
|
||||||
tiledWMSOptions.maxZoom : 18;
|
tiledWMSOptions.maxZoom : 18;
|
||||||
var resolutions = new Array(maxZoom + 1);
|
var resolutions = new Array(maxZoom + 1);
|
||||||
@@ -100,7 +103,6 @@ ol.source.TiledWMS = function(tiledWMSOptions) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var x = tileCoord.x;
|
var x = tileCoord.x;
|
||||||
var projectionExtent = projection.getExtent();
|
|
||||||
// FIXME do we want a wrapDateLine param? The code below will break maps
|
// FIXME do we want a wrapDateLine param? The code below will break maps
|
||||||
// with projections that do not span the whole world width.
|
// with projections that do not span the whole world width.
|
||||||
if (extent.minX === projectionExtent.minX &&
|
if (extent.minX === projectionExtent.minX &&
|
||||||
|
|||||||
Reference in New Issue
Block a user