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
|
* APIProperty: maxResolution
|
||||||
* {Float} Default max is 360 deg / 256 px, which corresponds to
|
* {Float} Default max is 360 deg / 256 px, which corresponds to
|
||||||
* zoom level 0 on gmaps. Specify a different value in the layer
|
* zoom level 0 on gmaps. Specify a different value in the layer
|
||||||
* options if you are not using a geographic projection and
|
* options if you are not using the default <OpenLayers.Map.tileSize>
|
||||||
* displaying the whole world.
|
* and displaying the whole world.
|
||||||
*/
|
*/
|
||||||
maxResolution: null,
|
maxResolution: null,
|
||||||
|
|
||||||
@@ -638,12 +638,6 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
this.units || this.map.units;
|
this.units || this.map.units;
|
||||||
|
|
||||||
this.initResolutions();
|
this.initResolutions();
|
||||||
if (!this.resolutions) {
|
|
||||||
throw(
|
|
||||||
"Could not calculate resolutions for layer " + this.name +
|
|
||||||
". Configure maxResolution or resolutions or scales."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.isBaseLayer) {
|
if (!this.isBaseLayer) {
|
||||||
this.inRange = this.calculateInRange();
|
this.inRange = this.calculateInRange();
|
||||||
@@ -896,6 +890,16 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
props.resolutions = this.resolutionsFromScales(props.scales);
|
props.resolutions = this.resolutionsFromScales(props.scales);
|
||||||
}
|
}
|
||||||
if(props.resolutions == null) {
|
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);
|
props.resolutions = this.calculateResolutions(props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,8 +274,8 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: maxResolution
|
* APIProperty: maxResolution
|
||||||
* {Float} Specify if you are not using a geographic projection or Web
|
* {Float} Required if you are not displaying the whole world on a tile
|
||||||
* Mercator and displaying the whole world.
|
* with the size specified in <tileSize>.
|
||||||
*/
|
*/
|
||||||
maxResolution: null,
|
maxResolution: null,
|
||||||
|
|
||||||
|
|||||||
@@ -167,26 +167,22 @@ OpenLayers.Projection.transforms = {};
|
|||||||
* {Object} Defaults for the SRS codes known to OpenLayers (currently
|
* {Object} Defaults for the SRS codes known to OpenLayers (currently
|
||||||
* EPSG:4326, CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:900913, EPSG:3857,
|
* EPSG:4326, CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:900913, EPSG:3857,
|
||||||
* EPSG:102113 and EPSG:102100). Keys are the SRS code, values are units,
|
* EPSG:102113 and EPSG:102100). Keys are the SRS code, values are units,
|
||||||
* maxExtent (the validity extent for the SRS), maxResolution (the maximum
|
* maxExtent (the validity extent for the SRS) and yx (true if this SRS is
|
||||||
* resolution commonly used in grid sets for this SRS) and yx (true if this
|
* known to have a reverse axis order).
|
||||||
* SRS is known to have a reverse axis order).
|
|
||||||
*/
|
*/
|
||||||
OpenLayers.Projection.defaults = {
|
OpenLayers.Projection.defaults = {
|
||||||
"EPSG:4326": {
|
"EPSG:4326": {
|
||||||
units: "degrees",
|
units: "degrees",
|
||||||
maxExtent: [-180, -90, 180, 90],
|
maxExtent: [-180, -90, 180, 90],
|
||||||
maxResolution: 1.40625,
|
|
||||||
yx: true
|
yx: true
|
||||||
},
|
},
|
||||||
"CRS:84": {
|
"CRS:84": {
|
||||||
units: "degrees",
|
units: "degrees",
|
||||||
maxExtent: [-180, -90, 180, 90],
|
maxExtent: [-180, -90, 180, 90]
|
||||||
maxResolution: 1.40625
|
|
||||||
},
|
},
|
||||||
"EPSG:900913": {
|
"EPSG:900913": {
|
||||||
units: "m",
|
units: "m",
|
||||||
maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34],
|
maxExtent: [-20037508.34, -20037508.34, 20037508.34, 20037508.34]
|
||||||
maxResolution: 156543.03390625
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -388,6 +388,7 @@
|
|||||||
var map = new OpenLayers.Map({
|
var map = new OpenLayers.Map({
|
||||||
div: "map",
|
div: "map",
|
||||||
maxExtent: new OpenLayers.Bounds(-185, -95, 185, 95),
|
maxExtent: new OpenLayers.Bounds(-185, -95, 185, 95),
|
||||||
|
maxResolution: 1.40625,
|
||||||
layers: [dummy, unconstrained, constrained],
|
layers: [dummy, unconstrained, constrained],
|
||||||
center: new OpenLayers.LonLat(0, 0),
|
center: new OpenLayers.LonLat(0, 0),
|
||||||
zoom: 1
|
zoom: 1
|
||||||
|
|||||||
@@ -136,7 +136,8 @@
|
|||||||
layer: "world",
|
layer: "world",
|
||||||
style: "blue_marble",
|
style: "blue_marble",
|
||||||
matrixSet: "arcgis_online",
|
matrixSet: "arcgis_online",
|
||||||
tileSize: new OpenLayers.Size(512, 512),
|
tileSize: new OpenLayers.Size(512, 512),
|
||||||
|
maxResolution: 1.40625,
|
||||||
requestEncoding: "REST"
|
requestEncoding: "REST"
|
||||||
});
|
});
|
||||||
map.addLayer(layer1);
|
map.addLayer(layer1);
|
||||||
@@ -156,7 +157,8 @@
|
|||||||
layer: "world",
|
layer: "world",
|
||||||
style: "blue_marble",
|
style: "blue_marble",
|
||||||
matrixSet: "arcgis_online",
|
matrixSet: "arcgis_online",
|
||||||
tileSize: new OpenLayers.Size(512, 512),
|
tileSize: new OpenLayers.Size(512, 512),
|
||||||
|
maxResolution: 1.40625,
|
||||||
requestEncoding: "REST"
|
requestEncoding: "REST"
|
||||||
});
|
});
|
||||||
map.addLayer(layer1);
|
map.addLayer(layer1);
|
||||||
|
|||||||
@@ -195,7 +195,7 @@
|
|||||||
|
|
||||||
var map = new OpenLayers.Map({
|
var map = new OpenLayers.Map({
|
||||||
div: "map",
|
div: "map",
|
||||||
maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
|
maxResolution: 1.40625 / Math.pow(2, offset)
|
||||||
});
|
});
|
||||||
var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset});
|
var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset});
|
||||||
map.addLayer(layer);
|
map.addLayer(layer);
|
||||||
@@ -211,7 +211,7 @@
|
|||||||
|
|
||||||
var map = new OpenLayers.Map({
|
var map = new OpenLayers.Map({
|
||||||
div: "map",
|
div: "map",
|
||||||
maxResolution: OpenLayers.Projection.defaults["EPSG:4326"].maxResolution / Math.pow(2, offset)
|
maxResolution: 1.40625 / Math.pow(2, offset)
|
||||||
});
|
});
|
||||||
var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset});
|
var layer = new OpenLayers.Layer.XYZ(name, url, {zoomOffset: offset});
|
||||||
map.addLayer(layer);
|
map.addLayer(layer);
|
||||||
|
|||||||
Reference in New Issue
Block a user