Use ol.Projection#.getMetersPerUnit()
As a follow-up to #815, this change makes ol.tilegrid.createForProjection work in cases where a Proj4 projection does not have units set. For better code readability, a new variable is used when calculating the resolution.
This commit is contained in:
@@ -413,7 +413,7 @@ ol.tilegrid.createForProjection =
|
||||
var projectionExtent = projection.getExtent();
|
||||
var size = goog.isNull(projectionExtent) ?
|
||||
360 * ol.METERS_PER_UNIT[ol.ProjectionUnits.DEGREES] /
|
||||
ol.METERS_PER_UNIT[projection.getUnits()] :
|
||||
projection.getMetersPerUnit() :
|
||||
Math.max(projectionExtent[1] - projectionExtent[0],
|
||||
projectionExtent[3] - projectionExtent[2]);
|
||||
var maxZoom = goog.isDef(opt_maxZoom) ?
|
||||
@@ -421,9 +421,9 @@ ol.tilegrid.createForProjection =
|
||||
var tileSize = goog.isDef(opt_tileSize) ?
|
||||
opt_tileSize : [ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE];
|
||||
var resolutions = new Array(maxZoom + 1);
|
||||
size = size / Math.max(tileSize[0], tileSize[1]);
|
||||
var maxResolution = size / Math.max(tileSize[0], tileSize[1]);
|
||||
for (var z = 0, zz = resolutions.length; z < zz; ++z) {
|
||||
resolutions[z] = size / Math.pow(2, z);
|
||||
resolutions[z] = maxResolution / Math.pow(2, z);
|
||||
}
|
||||
return new ol.tilegrid.TileGrid({
|
||||
origin: goog.isNull(projectionExtent) ? [0, 0] :
|
||||
|
||||
Reference in New Issue
Block a user