diff --git a/lib/OpenLayers/Control/ZoomBox.js b/lib/OpenLayers/Control/ZoomBox.js index 8f407adb25..58da952c9d 100644 --- a/lib/OpenLayers/Control/ZoomBox.js +++ b/lib/OpenLayers/Control/ZoomBox.js @@ -41,9 +41,17 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, { /** * APIProperty: alwaysZoom - * {Boolean} Always zoom in/out, when box drawed + * {Boolean} Always zoom in/out when box drawn, even if the zoom level does + * not change. */ alwaysZoom: false, + + /** + * APIProperty: zoomOnClick + * {Boolean} Should we zoom when no box was dragged, i.e. the user only + * clicked? Default is true. + */ + zoomOnClick: true, /** * Method: draw @@ -93,7 +101,7 @@ OpenLayers.Control.ZoomBox = OpenLayers.Class(OpenLayers.Control, { if (lastZoom == this.map.getZoom() && this.alwaysZoom == true){ this.map.zoomTo(lastZoom + (this.out ? -1 : 1)); } - } else { // it's a pixel + } else if (this.zoomOnClick) { // it's a pixel if (!this.out) { this.map.setCenter(this.map.getLonLatFromPixel(position), this.map.getZoom() + 1); diff --git a/tests/Control/ZoomBox.html b/tests/Control/ZoomBox.html new file mode 100644 index 0000000000..9ee3fde886 --- /dev/null +++ b/tests/Control/ZoomBox.html @@ -0,0 +1,51 @@ + + + + + + + +
+
in
out + + diff --git a/tests/list-tests.html b/tests/list-tests.html index 14ccf78ed0..c883ed34d7 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -49,6 +49,7 @@
  • Control/PanPanel.html
  • Control/SLDSelect.html
  • Control/Zoom.html
  • +
  • Control/ZoomBox.html
  • Events.html
  • Events/buttonclick.html
  • Extras.html