From a40ae7ef11a4690085082ec9a2e300b9edd98c8d Mon Sep 17 00:00:00 2001 From: fredj Date: Wed, 15 Feb 2012 12:30:05 +0100 Subject: [PATCH 1/3] If sphericalMercator, use default values from Projection.defaults --- lib/OpenLayers/Layer/XYZ.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/OpenLayers/Layer/XYZ.js b/lib/OpenLayers/Layer/XYZ.js index 7977a3255f..4c2bfc051d 100644 --- a/lib/OpenLayers/Layer/XYZ.js +++ b/lib/OpenLayers/Layer/XYZ.js @@ -70,19 +70,10 @@ 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; From cd3ffa205841e329b2d92196c151bed65f2ae1f7 Mon Sep 17 00:00:00 2001 From: fredj Date: Wed, 15 Feb 2012 12:32:25 +0100 Subject: [PATCH 2/3] Simplify parent call (don't use intermediate array) --- lib/OpenLayers/Layer/XYZ.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/XYZ.js b/lib/OpenLayers/Layer/XYZ.js index 4c2bfc051d..cc52d97fc6 100644 --- a/lib/OpenLayers/Layer/XYZ.js +++ b/lib/OpenLayers/Layer/XYZ.js @@ -75,10 +75,9 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, { 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 + ]); }, /** From 147b32b7e34f18996f79437f7b80f512aba46515 Mon Sep 17 00:00:00 2001 From: fredj Date: Wed, 15 Feb 2012 12:33:14 +0100 Subject: [PATCH 3/3] Don't compute limit if it's not needed --- lib/OpenLayers/Layer/XYZ.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/OpenLayers/Layer/XYZ.js b/lib/OpenLayers/Layer/XYZ.js index cc52d97fc6..43535dff79 100644 --- a/lib/OpenLayers/Layer/XYZ.js +++ b/lib/OpenLayers/Layer/XYZ.js @@ -147,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};