do no declare vars multiple times in functions, no functional change
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11517 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+14
-12
@@ -815,13 +815,13 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
// map
|
// map
|
||||||
// 7. hope for the best!
|
// 7. hope for the best!
|
||||||
|
|
||||||
var i, len;
|
var i, len, p;
|
||||||
var props = {}, alwaysInRange = true;
|
var props = {}, alwaysInRange = true;
|
||||||
|
|
||||||
// get resolution data from layer config
|
// get resolution data from layer config
|
||||||
// (we also set alwaysInRange in the layer as appropriate)
|
// (we also set alwaysInRange in the layer as appropriate)
|
||||||
for(i=0, len=this.RESOLUTION_PROPERTIES.length; i<len; i++) {
|
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];
|
props[p] = this.options[p];
|
||||||
if(alwaysInRange && this.options[p]) {
|
if(alwaysInRange && this.options[p]) {
|
||||||
alwaysInRange = false;
|
alwaysInRange = false;
|
||||||
@@ -845,7 +845,7 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
// in the map
|
// in the map
|
||||||
if(props.resolutions == null) {
|
if(props.resolutions == null) {
|
||||||
for(i=0, len=this.RESOLUTION_PROPERTIES.length; i<len; i++) {
|
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 ?
|
props[p] = this.options[p] != null ?
|
||||||
this.options[p] : this.map[p];
|
this.options[p] : this.map[p];
|
||||||
}
|
}
|
||||||
@@ -960,6 +960,8 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
*/
|
*/
|
||||||
calculateResolutions: function(props) {
|
calculateResolutions: function(props) {
|
||||||
|
|
||||||
|
var viewSize, wRes, hRes;
|
||||||
|
|
||||||
// determine maxResolution
|
// determine maxResolution
|
||||||
var maxResolution = props.maxResolution;
|
var maxResolution = props.maxResolution;
|
||||||
if(props.minScale != null) {
|
if(props.minScale != null) {
|
||||||
@@ -967,9 +969,9 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
OpenLayers.Util.getResolutionFromScale(props.minScale,
|
OpenLayers.Util.getResolutionFromScale(props.minScale,
|
||||||
this.units);
|
this.units);
|
||||||
} else if(maxResolution == "auto" && this.maxExtent != null) {
|
} else if(maxResolution == "auto" && this.maxExtent != null) {
|
||||||
var viewSize = this.map.getSize();
|
viewSize = this.map.getSize();
|
||||||
var wRes = this.maxExtent.getWidth() / viewSize.w;
|
wRes = this.maxExtent.getWidth() / viewSize.w;
|
||||||
var hRes = this.maxExtent.getHeight() / viewSize.h;
|
hRes = this.maxExtent.getHeight() / viewSize.h;
|
||||||
maxResolution = Math.max(wRes, hRes);
|
maxResolution = Math.max(wRes, hRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -980,9 +982,9 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
OpenLayers.Util.getResolutionFromScale(props.maxScale,
|
OpenLayers.Util.getResolutionFromScale(props.maxScale,
|
||||||
this.units);
|
this.units);
|
||||||
} else if(props.minResolution == "auto" && this.minExtent != null) {
|
} else if(props.minResolution == "auto" && this.minExtent != null) {
|
||||||
var viewSize = this.map.getSize();
|
viewSize = this.map.getSize();
|
||||||
var wRes = this.minExtent.getWidth() / viewSize.w;
|
wRes = this.minExtent.getWidth() / viewSize.w;
|
||||||
var hRes = this.minExtent.getHeight()/ viewSize.h;
|
hRes = this.minExtent.getHeight()/ viewSize.h;
|
||||||
minResolution = Math.max(wRes, hRes);
|
minResolution = Math.max(wRes, hRes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1141,14 +1143,14 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
* value and the 'closest' specification.
|
* value and the 'closest' specification.
|
||||||
*/
|
*/
|
||||||
getZoomForResolution: function(resolution, closest) {
|
getZoomForResolution: function(resolution, closest) {
|
||||||
var zoom;
|
var zoom, i, len;
|
||||||
if(this.map.fractionalZoom) {
|
if(this.map.fractionalZoom) {
|
||||||
var lowZoom = 0;
|
var lowZoom = 0;
|
||||||
var highZoom = this.resolutions.length - 1;
|
var highZoom = this.resolutions.length - 1;
|
||||||
var highRes = this.resolutions[lowZoom];
|
var highRes = this.resolutions[lowZoom];
|
||||||
var lowRes = this.resolutions[highZoom];
|
var lowRes = this.resolutions[highZoom];
|
||||||
var res;
|
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];
|
res = this.resolutions[i];
|
||||||
if(res >= resolution) {
|
if(res >= resolution) {
|
||||||
highRes = res;
|
highRes = res;
|
||||||
@@ -1169,7 +1171,7 @@ OpenLayers.Layer = OpenLayers.Class({
|
|||||||
} else {
|
} else {
|
||||||
var diff;
|
var diff;
|
||||||
var minDiff = Number.POSITIVE_INFINITY;
|
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) {
|
if (closest) {
|
||||||
diff = Math.abs(this.resolutions[i] - resolution);
|
diff = Math.abs(this.resolutions[i] - resolution);
|
||||||
if (diff > minDiff) {
|
if (diff > minDiff) {
|
||||||
|
|||||||
Reference in New Issue
Block a user