[OpenLayers-Commits] r11517 - trunk/openlayers/lib/OpenLayers

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Fri Feb 25 10:52:49 EST 2011


Author: erilem
Date: 2011-02-25 07:52:48 -0800 (Fri, 25 Feb 2011)
New Revision: 11517

Modified:
   trunk/openlayers/lib/OpenLayers/Layer.js
Log:
do no declare vars multiple times in functions, no functional change

Modified: trunk/openlayers/lib/OpenLayers/Layer.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Layer.js	2011-02-25 15:52:42 UTC (rev 11516)
+++ trunk/openlayers/lib/OpenLayers/Layer.js	2011-02-25 15:52:48 UTC (rev 11517)
@@ -815,13 +815,13 @@
         //    map
         // 7. hope for the best!
 
-        var i, len;
+        var i, len, p;
         var props = {}, alwaysInRange = true;
 
         // get resolution data from layer config
         // (we also set alwaysInRange in the layer as appropriate)
         for(i=0, len=this.RESOLUTION_PROPERTIES.length; i<len; i++) {
-            var p = this.RESOLUTION_PROPERTIES[i];
+            p = this.RESOLUTION_PROPERTIES[i];
             props[p] = this.options[p];
             if(alwaysInRange && this.options[p]) {
                 alwaysInRange = false;
@@ -845,7 +845,7 @@
         // in the map
         if(props.resolutions == null) {
             for(i=0, len=this.RESOLUTION_PROPERTIES.length; i<len; i++) {
-                var p = this.RESOLUTION_PROPERTIES[i];
+                p = this.RESOLUTION_PROPERTIES[i];
                 props[p] = this.options[p] != null ?
                     this.options[p] : this.map[p];
             }
@@ -960,6 +960,8 @@
      */
     calculateResolutions: function(props) {
 
+        var viewSize, wRes, hRes;
+
         // determine maxResolution
         var maxResolution = props.maxResolution;
         if(props.minScale != null) {
@@ -967,9 +969,9 @@
                 OpenLayers.Util.getResolutionFromScale(props.minScale,
                                                        this.units);
         } else if(maxResolution == "auto" && this.maxExtent != null) {
-            var viewSize = this.map.getSize();
-            var wRes = this.maxExtent.getWidth() / viewSize.w;
-            var hRes = this.maxExtent.getHeight() / viewSize.h;
+            viewSize = this.map.getSize();
+            wRes = this.maxExtent.getWidth() / viewSize.w;
+            hRes = this.maxExtent.getHeight() / viewSize.h;
             maxResolution = Math.max(wRes, hRes);
         }
 
@@ -980,9 +982,9 @@
                 OpenLayers.Util.getResolutionFromScale(props.maxScale,
                                                        this.units);
         } else if(props.minResolution == "auto" && this.minExtent != null) {
-            var viewSize = this.map.getSize();
-            var wRes = this.minExtent.getWidth() / viewSize.w;
-            var hRes = this.minExtent.getHeight()/ viewSize.h;
+            viewSize = this.map.getSize();
+            wRes = this.minExtent.getWidth() / viewSize.w;
+            hRes = this.minExtent.getHeight()/ viewSize.h;
             minResolution = Math.max(wRes, hRes);
         }
 
@@ -1141,14 +1143,14 @@
      *     value and the 'closest' specification.
      */
     getZoomForResolution: function(resolution, closest) {
-        var zoom;
+        var zoom, i, len;
         if(this.map.fractionalZoom) {
             var lowZoom = 0;
             var highZoom = this.resolutions.length - 1;
             var highRes = this.resolutions[lowZoom];
             var lowRes = this.resolutions[highZoom];
             var res;
-            for(var i=0, len=this.resolutions.length; i<len; ++i) {
+            for(i=0, len=this.resolutions.length; i<len; ++i) {
                 res = this.resolutions[i];
                 if(res >= resolution) {
                     highRes = res;
@@ -1169,7 +1171,7 @@
         } else {
             var diff;
             var minDiff = Number.POSITIVE_INFINITY;
-            for(var i=0, len=this.resolutions.length; i<len; i++) {            
+            for(i=0, len=this.resolutions.length; i<len; i++) {            
                 if (closest) {
                     diff = Math.abs(this.resolutions[i] - resolution);
                     if (diff > minDiff) {



More information about the Commits mailing list