Merge pull request #882 from tschaub/zoom-box
Restored zoom box behavior (thanks @ahocevar for the review).
This commit is contained in:
@@ -83,8 +83,8 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,
|
bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,
|
||||||
maxXY.lon, maxXY.lat);
|
maxXY.lon, maxXY.lat);
|
||||||
} else {
|
} else {
|
||||||
var pixWidth = Math.abs(position.right-position.left);
|
var pixWidth = position.right - position.left;
|
||||||
var pixHeight = Math.abs(position.top-position.bottom);
|
var pixHeight = position.bottom - position.top;
|
||||||
var zoomFactor = Math.min((this.map.size.h / pixHeight),
|
var zoomFactor = Math.min((this.map.size.h / pixHeight),
|
||||||
(this.map.size.w / pixWidth));
|
(this.map.size.w / pixWidth));
|
||||||
var extent = this.map.getExtent();
|
var extent = this.map.getExtent();
|
||||||
@@ -103,10 +103,10 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
oldRes = this.map.getResolution(),
|
oldRes = this.map.getResolution(),
|
||||||
newRes = this.map.getResolutionForZoom(zoom),
|
newRes = this.map.getResolutionForZoom(zoom),
|
||||||
zoomOriginPx = {
|
zoomOriginPx = {
|
||||||
x: targetCenterPx.x +
|
x: (oldRes * targetCenterPx.x - newRes * centerPx.x) /
|
||||||
(targetCenterPx.x - centerPx.x) * newRes / oldRes,
|
(oldRes - newRes),
|
||||||
y: targetCenterPx.y +
|
y: (oldRes * targetCenterPx.y - newRes * centerPx.y) /
|
||||||
(targetCenterPx.y - centerPx.y) * newRes / oldRes
|
(oldRes - newRes)
|
||||||
};
|
};
|
||||||
this.map.zoomTo(zoom, zoomOriginPx);
|
this.map.zoomTo(zoom, zoomOriginPx);
|
||||||
if (lastZoom == this.map.getZoom() && this.alwaysZoom == true){
|
if (lastZoom == this.map.getZoom() && this.alwaysZoom == true){
|
||||||
|
|||||||
Reference in New Issue
Block a user