remove map.getSize call to avoid creating new instances
This commit is contained in:
+13
-15
@@ -1469,15 +1469,13 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((center != null) && (resolution != null)) {
|
if ((center != null) && (resolution != null)) {
|
||||||
|
var half_w_deg = (this.size.w * resolution) / 2;
|
||||||
var size = this.getSize();
|
var half_h_deg = (this.size.h * resolution) / 2;
|
||||||
var w_deg = size.w * resolution;
|
|
||||||
var h_deg = size.h * resolution;
|
|
||||||
|
|
||||||
extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
|
extent = new OpenLayers.Bounds(center.lon - half_w_deg,
|
||||||
center.lat - h_deg / 2,
|
center.lat - half_h_deg,
|
||||||
center.lon + w_deg / 2,
|
center.lon + half_w_deg,
|
||||||
center.lat + h_deg / 2);
|
center.lat + half_h_deg);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2318,15 +2316,15 @@ OpenLayers.Map = OpenLayers.Class({
|
|||||||
zoomToScale: function(scale, closest) {
|
zoomToScale: function(scale, closest) {
|
||||||
var res = OpenLayers.Util.getResolutionFromScale(scale,
|
var res = OpenLayers.Util.getResolutionFromScale(scale,
|
||||||
this.baseLayer.units);
|
this.baseLayer.units);
|
||||||
var size = this.getSize();
|
|
||||||
var w_deg = size.w * res;
|
var half_w_deg = (this.size.w * res) / 2;
|
||||||
var h_deg = size.h * res;
|
var half_h_deg = (this.size.h * res) / 2;
|
||||||
var center = this.getCachedCenter();
|
var center = this.getCachedCenter();
|
||||||
|
|
||||||
var extent = new OpenLayers.Bounds(center.lon - w_deg / 2,
|
var extent = new OpenLayers.Bounds(center.lon - half_w_deg,
|
||||||
center.lat - h_deg / 2,
|
center.lat - half_h_deg,
|
||||||
center.lon + w_deg / 2,
|
center.lon + half_w_deg,
|
||||||
center.lat + h_deg / 2);
|
center.lat + half_h_deg);
|
||||||
this.zoomToExtent(extent, closest);
|
this.zoomToExtent(extent, closest);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1406,6 +1406,7 @@
|
|||||||
|
|
||||||
var m = {
|
var m = {
|
||||||
'baseLayer': { 'units': {} },
|
'baseLayer': { 'units': {} },
|
||||||
|
'size': {'w': 10, 'h': 15},
|
||||||
'getSize': function() { return {'w': 10, 'h': 15}; },
|
'getSize': function() { return {'w': 10, 'h': 15}; },
|
||||||
'getCachedCenter': function() { return {'lon': -5, 'lat': -25}; },
|
'getCachedCenter': function() { return {'lon': -5, 'lat': -25}; },
|
||||||
'zoomToExtent': function(extent, closest) {
|
'zoomToExtent': function(extent, closest) {
|
||||||
|
|||||||
Reference in New Issue
Block a user