Calculating maxResolution instead of having it in defaults.
This commit is contained in:
+12
-8
@@ -255,8 +255,8 @@ OpenLayers.Layer = OpenLayers.Class({
|
||||
* APIProperty: maxResolution
|
||||
* {Float} Default max is 360 deg / 256 px, which corresponds to
|
||||
* zoom level 0 on gmaps. Specify a different value in the layer
|
||||
* options if you are not using a geographic projection and
|
||||
* displaying the whole world.
|
||||
* options if you are not using the default <OpenLayers.Map.tileSize>
|
||||
* and displaying the whole world.
|
||||
*/
|
||||
maxResolution: null,
|
||||
|
||||
@@ -638,12 +638,6 @@ OpenLayers.Layer = OpenLayers.Class({
|
||||
this.units || this.map.units;
|
||||
|
||||
this.initResolutions();
|
||||
if (!this.resolutions) {
|
||||
throw(
|
||||
"Could not calculate resolutions for layer " + this.name +
|
||||
". Configure maxResolution or resolutions or scales."
|
||||
);
|
||||
}
|
||||
|
||||
if (!this.isBaseLayer) {
|
||||
this.inRange = this.calculateInRange();
|
||||
@@ -896,6 +890,16 @@ OpenLayers.Layer = OpenLayers.Class({
|
||||
props.resolutions = this.resolutionsFromScales(props.scales);
|
||||
}
|
||||
if(props.resolutions == null) {
|
||||
var maxExtent = this.maxExtent;
|
||||
if (!props.maxResolution && maxExtent) {
|
||||
// maxResolution for default grid sets assumes that at zoom
|
||||
// level zero, the whole world fits on one tile.
|
||||
var tileSize = this.tileSize || this.map.getTileSize();
|
||||
props.maxResolution = Math.max(
|
||||
maxExtent.getWidth() / tileSize.w,
|
||||
maxExtent.getHeight() / tileSize.h
|
||||
);
|
||||
}
|
||||
props.resolutions = this.calculateResolutions(props);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user