diff --git a/lib/OpenLayers/Layer/XYZ.js b/lib/OpenLayers/Layer/XYZ.js index 7977a3255f..43535dff79 100644 --- a/lib/OpenLayers/Layer/XYZ.js +++ b/lib/OpenLayers/Layer/XYZ.js @@ -70,24 +70,14 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, { * options - {Object} Hashtable of extra options to tag onto the layer */ initialize: function(name, url, options) { - if (options && options.sphericalMercator || this.sphericalMercator) { - options = OpenLayers.Util.extend({ - maxExtent: new OpenLayers.Bounds( - -128 * 156543.03390625, - -128 * 156543.03390625, - 128 * 156543.03390625, - 128 * 156543.03390625 - ), - maxResolution: 156543.03390625, - numZoomLevels: 19, - units: "m", - projection: "EPSG:900913" - }, options); + options = options || {}; + if (options.sphericalMercator || this.sphericalMercator) { + options.projection = new OpenLayers.Projection('EPSG:900913'); + options.numZoomLevels = 19; } - url = url || this.url; - name = name || this.name; - var newArguments = [name, url, {}, options]; - OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments); + OpenLayers.Layer.Grid.prototype.initialize.apply(this, [ + name || this.name, url || this.url, {}, options + ]); }, /** @@ -157,10 +147,9 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, { OpenLayers.Util.indexOf(resolutions, res) : this.getServerZoom() + this.zoomOffset; - var limit = Math.pow(2, z); - if (this.wrapDateLine) - { - x = ((x % limit) + limit) % limit; + if (this.wrapDateLine) { + var limit = Math.pow(2, z); + x = ((x % limit) + limit) % limit; } return {'x': x, 'y': y, 'z': z};