@@ -14,6 +14,12 @@ goog.require('ol.TileRange');
|
|||||||
goog.require('ol.array');
|
goog.require('ol.array');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @define {number} Default tile size.
|
||||||
|
*/
|
||||||
|
ol.DEFAULT_TILE_SIZE = 256;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{extent: (ol.Extent|undefined),
|
* @typedef {{extent: (ol.Extent|undefined),
|
||||||
* origin: (ol.Coordinate|undefined),
|
* origin: (ol.Coordinate|undefined),
|
||||||
@@ -75,7 +81,8 @@ ol.tilegrid.TileGrid = function(tileGridOptions) {
|
|||||||
* @type {ol.Size}
|
* @type {ol.Size}
|
||||||
*/
|
*/
|
||||||
this.tileSize_ = goog.isDef(tileGridOptions.tileSize) ?
|
this.tileSize_ = goog.isDef(tileGridOptions.tileSize) ?
|
||||||
tileGridOptions.tileSize : new ol.Size(256, 256);
|
tileGridOptions.tileSize :
|
||||||
|
new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -321,21 +328,27 @@ ol.tilegrid.TileGrid.prototype.getZForResolution = function(resolution) {
|
|||||||
/**
|
/**
|
||||||
* @param {ol.Projection} projection Projection.
|
* @param {ol.Projection} projection Projection.
|
||||||
* @param {number=} opt_maxZoom Maximum zoom level (optional). Default is 18.
|
* @param {number=} opt_maxZoom Maximum zoom level (optional). Default is 18.
|
||||||
|
* @param {ol.Size=} opt_tileSize Tile size.
|
||||||
* @return {ol.tilegrid.TileGrid} TileGrid instance.
|
* @return {ol.tilegrid.TileGrid} TileGrid instance.
|
||||||
*/
|
*/
|
||||||
ol.tilegrid.createForProjection = function(projection, opt_maxZoom) {
|
ol.tilegrid.createForProjection =
|
||||||
|
function(projection, opt_maxZoom, opt_tileSize) {
|
||||||
var projectionExtent = projection.getExtent();
|
var projectionExtent = projection.getExtent();
|
||||||
var size = Math.max(
|
var size = Math.max(
|
||||||
projectionExtent.maxX - projectionExtent.minX,
|
projectionExtent.maxX - projectionExtent.minX,
|
||||||
projectionExtent.maxY - projectionExtent.minY);
|
projectionExtent.maxY - projectionExtent.minY);
|
||||||
var maxZoom = goog.isDef(opt_maxZoom) ?
|
var maxZoom = goog.isDef(opt_maxZoom) ?
|
||||||
opt_maxZoom : 18;
|
opt_maxZoom : 18;
|
||||||
|
var tileSize = goog.isDef(opt_tileSize) ?
|
||||||
|
opt_tileSize : new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE);
|
||||||
var resolutions = new Array(maxZoom + 1);
|
var resolutions = new Array(maxZoom + 1);
|
||||||
|
goog.asserts.assert(tileSize.width == tileSize.height);
|
||||||
for (var z = 0, zz = resolutions.length; z < zz; ++z) {
|
for (var z = 0, zz = resolutions.length; z < zz; ++z) {
|
||||||
resolutions[z] = size / (256 << z);
|
resolutions[z] = size / (tileSize.width << z);
|
||||||
}
|
}
|
||||||
return new ol.tilegrid.TileGrid({
|
return new ol.tilegrid.TileGrid({
|
||||||
origin: projectionExtent.getTopLeft(),
|
origin: projectionExtent.getTopLeft(),
|
||||||
resolutions: resolutions
|
resolutions: resolutions,
|
||||||
|
tileSize: tileSize
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ ol.tilegrid.XYZ = function(xyzOptions) {
|
|||||||
var resolutions = new Array(xyzOptions.maxZoom + 1);
|
var resolutions = new Array(xyzOptions.maxZoom + 1);
|
||||||
var z;
|
var z;
|
||||||
for (z = 0; z <= xyzOptions.maxZoom; ++z) {
|
for (z = 0; z <= xyzOptions.maxZoom; ++z) {
|
||||||
resolutions[z] = ol.Projection.EPSG_3857_HALF_SIZE / (128 << z);
|
resolutions[z] =
|
||||||
|
2 * ol.Projection.EPSG_3857_HALF_SIZE / (ol.DEFAULT_TILE_SIZE << z);
|
||||||
}
|
}
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
@@ -33,7 +34,7 @@ ol.tilegrid.XYZ = function(xyzOptions) {
|
|||||||
origin: new ol.Coordinate(-ol.Projection.EPSG_3857_HALF_SIZE,
|
origin: new ol.Coordinate(-ol.Projection.EPSG_3857_HALF_SIZE,
|
||||||
ol.Projection.EPSG_3857_HALF_SIZE),
|
ol.Projection.EPSG_3857_HALF_SIZE),
|
||||||
resolutions: resolutions,
|
resolutions: resolutions,
|
||||||
tileSize: new ol.Size(256, 256)
|
tileSize: new ol.Size(ol.DEFAULT_TILE_SIZE, ol.DEFAULT_TILE_SIZE)
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-2
@@ -52,7 +52,8 @@ ol.View2D = function(opt_view2DOptions) {
|
|||||||
var size = Math.max(
|
var size = Math.max(
|
||||||
projectionExtent.maxX - projectionExtent.minX,
|
projectionExtent.maxX - projectionExtent.minX,
|
||||||
projectionExtent.maxY - projectionExtent.minY);
|
projectionExtent.maxY - projectionExtent.minY);
|
||||||
values[ol.View2DProperty.RESOLUTION] = size / (256 << view2DOptions.zoom);
|
values[ol.View2DProperty.RESOLUTION] =
|
||||||
|
size / (ol.DEFAULT_TILE_SIZE << view2DOptions.zoom);
|
||||||
}
|
}
|
||||||
values[ol.View2DProperty.ROTATION] = view2DOptions.rotation;
|
values[ol.View2DProperty.ROTATION] = view2DOptions.rotation;
|
||||||
this.setValues(values);
|
this.setValues(values);
|
||||||
@@ -329,7 +330,7 @@ ol.View2D.createConstraints_ = function(view2DOptions) {
|
|||||||
view2DOptions.projection, 'EPSG:3857').getExtent();
|
view2DOptions.projection, 'EPSG:3857').getExtent();
|
||||||
maxResolution = Math.max(
|
maxResolution = Math.max(
|
||||||
projectionExtent.maxX - projectionExtent.minX,
|
projectionExtent.maxX - projectionExtent.minX,
|
||||||
projectionExtent.maxY - projectionExtent.minY) / 256;
|
projectionExtent.maxY - projectionExtent.minY) / ol.DEFAULT_TILE_SIZE;
|
||||||
// number of steps we want between two data resolutions
|
// number of steps we want between two data resolutions
|
||||||
var numSteps = 4;
|
var numSteps = 4;
|
||||||
numZoomLevels = 29 * numSteps;
|
numZoomLevels = 29 * numSteps;
|
||||||
|
|||||||
Reference in New Issue
Block a user