diff --git a/examples/navtoolbar-alwaysZoom.html b/examples/navtoolbar-alwaysZoom.html
new file mode 100644
index 0000000000..ec9309c1a9
--- /dev/null
+++ b/examples/navtoolbar-alwaysZoom.html
@@ -0,0 +1,78 @@
+
+
+ A navToolbar with an alwaysZoom ZoomBox
+
+
+
+
+
+
+
+
+ A navToolbar with an alwaysZoom ZoomBox
+
+ Demo of a custom NavToolbar which uses a zoomBox tool that always zoom in even when the zoom box is too big.
+
+
+
+
diff --git a/lib/OpenLayers/Control/ZoomBox.js b/lib/OpenLayers/Control/ZoomBox.js
index 7a45ff6980..461ece4086 100644
--- a/lib/OpenLayers/Control/ZoomBox.js
+++ b/lib/OpenLayers/Control/ZoomBox.js
@@ -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),