remove map.getSize call to avoid creating new instances

This commit is contained in:
fredj
2012-01-09 16:14:18 +01:00
committed by Frederic Junod
parent 90452311f3
commit b900144ce3
2 changed files with 14 additions and 15 deletions

View File

@@ -1469,15 +1469,13 @@ OpenLayers.Map = OpenLayers.Class({
}
if ((center != null) && (resolution != null)) {
var half_w_deg = (this.size.w * resolution) / 2;
var half_h_deg = (this.size.h * resolution) / 2;
var size = this.getSize();
var w_deg = size.w * resolution;
var h_deg = size.h * resolution;
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
center.lat - h_deg / 2,
center.lon + w_deg / 2,
center.lat + h_deg / 2);
extent = new OpenLayers.Bounds(center.lon - half_w_deg,
center.lat - half_h_deg,
center.lon + half_w_deg,
center.lat + half_h_deg);
}
@@ -2318,15 +2316,15 @@ OpenLayers.Map = OpenLayers.Class({
zoomToScale: function(scale, closest) {
var res = OpenLayers.Util.getResolutionFromScale(scale,
this.baseLayer.units);
var size = this.getSize();
var w_deg = size.w * res;
var h_deg = size.h * res;
var half_w_deg = (this.size.w * res) / 2;
var half_h_deg = (this.size.h * res) / 2;
var center = this.getCachedCenter();
var extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
center.lat - h_deg / 2,
center.lon + w_deg / 2,
center.lat + h_deg / 2);
var extent = new OpenLayers.Bounds(center.lon - half_w_deg,
center.lat - half_h_deg,
center.lon + half_w_deg,
center.lat + half_h_deg);
this.zoomToExtent(extent, closest);
},

View File

@@ -1406,6 +1406,7 @@
var m = {
'baseLayer': { 'units': {} },
'size': {'w': 10, 'h': 15},
'getSize': function() { return {'w': 10, 'h': 15}; },
'getCachedCenter': function() { return {'lon': -5, 'lat': -25}; },
'zoomToExtent': function(extent, closest) {