"Always zoom in/out while drawing the zoom box." Patch from jachym, tested

and example added by vdeparday. r=me. (Closes #1771)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@8977 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2009-03-10 03:50:01 +00:00
parent 1ed1584320
commit 676475d902
2 changed files with 89 additions and 0 deletions

View File

@@ -29,6 +29,12 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
*/
out: false,
/**
* Property: alwaysZoom
* {Boolean} Always zoom in/out, when box drawed
*/
alwaysZoom: false,
/**
* Method: draw
*/
@@ -66,7 +72,12 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, {
var ymax = center.lat + (extent.getHeight()/2)*zoomFactor;
var bounds = new OpenLayers.Bounds(xmin, ymin, xmax, ymax);
}
// always zoom in/out
var lastZoom = this.map.getZoom();
this.map.zoomToExtent(bounds);
if (lastZoom == this.map.getZoom() && this.alwaysZoom == true){
this.map.zoomTo(lastZoom + (this.out ? -1 : 1));
}
} else { // it's a pixel
if (!this.out) {
this.map.setCenter(this.map.getLonLatFromPixel(position),