New zoomOnClick option for ZoomBox control.

This change also finally adds tests for the ZoomBox control.
This commit is contained in:
ahocevar
2012-06-11 19:07:17 +02:00
parent 96359fbc99
commit 958544f2a7
3 changed files with 62 additions and 2 deletions

View File

@@ -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);