Merge pull request #882 from tschaub/zoom-box

Restored zoom box behavior (thanks @ahocevar for the review).
This commit is contained in:
Tim Schaub
2013-02-14 14:48:27 -08:00

View File

@@ -83,8 +83,8 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,
maxXY.lon, maxXY.lat);
} else {
var pixWidth = Math.abs(position.right-position.left);
var pixHeight = Math.abs(position.top-position.bottom);
var pixWidth = position.right - position.left;
var pixHeight = position.bottom - position.top;
var zoomFactor = Math.min((this.map.size.h / pixHeight),
(this.map.size.w / pixWidth));
var extent = this.map.getExtent();
@@ -103,10 +103,10 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
oldRes = this.map.getResolution(),
newRes = this.map.getResolutionForZoom(zoom),
zoomOriginPx = {
x: targetCenterPx.x +
(targetCenterPx.x - centerPx.x) * newRes / oldRes,
y: targetCenterPx.y +
(targetCenterPx.y - centerPx.y) * newRes / oldRes
x: (oldRes * targetCenterPx.x - newRes * centerPx.x) /
(oldRes - newRes),
y: (oldRes * targetCenterPx.y - newRes * centerPx.y) /
(oldRes - newRes)
};
this.map.zoomTo(zoom, zoomOriginPx);
if (lastZoom == this.map.getZoom() && this.alwaysZoom == true){