New OpenLayers.Projection.defaults property.
This allows us to simplify the map and layer configuration, because now the projection also defines defaults for maxExtent, maxResolution and units. This change also adds transforms for SRS aliases for EPSG:4326 and centralizes axis order information in OpenLayers.Projection.defaults.
This commit is contained in:
@@ -473,8 +473,18 @@ OpenLayers.Layer = OpenLayers.Class({
|
||||
this.options = {};
|
||||
}
|
||||
|
||||
// allow array for extents
|
||||
if (newOptions) {
|
||||
// make sure this.projection references a projection object
|
||||
if(typeof newOptions.projection == "string") {
|
||||
newOptions.projection = new OpenLayers.Projection(newOptions.projection);
|
||||
}
|
||||
if (newOptions.projection) {
|
||||
// get maxResolution, units and maxExtent from projection defaults if
|
||||
// they are not defined already
|
||||
OpenLayers.Util.applyDefaults(newOptions,
|
||||
OpenLayers.Projection.defaults[newOptions.projection.getCode()]);
|
||||
}
|
||||
// allow array for extents
|
||||
if (newOptions.maxExtent && !(newOptions.maxExtent instanceof OpenLayers.Bounds)) {
|
||||
newOptions.maxExtent = new OpenLayers.Bounds(newOptions.maxExtent);
|
||||
}
|
||||
@@ -488,12 +498,7 @@ OpenLayers.Layer = OpenLayers.Class({
|
||||
|
||||
// add new options to this
|
||||
OpenLayers.Util.extend(this, newOptions);
|
||||
|
||||
// make sure this.projection references a projection object
|
||||
if(typeof this.projection == "string") {
|
||||
this.projection = new OpenLayers.Projection(this.projection);
|
||||
}
|
||||
|
||||
|
||||
// get the units from the projection, if we have a projection
|
||||
// and it it has units
|
||||
if(this.projection && this.projection.getUnits()) {
|
||||
@@ -633,6 +638,12 @@ 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();
|
||||
|
||||
Reference in New Issue
Block a user