adds a zoomBoxEnabled boolean option in Control.Navigation, r=ahocevar, (Closes #2416)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@10067 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -49,6 +49,12 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
*/
|
*/
|
||||||
zoomBox: null,
|
zoomBox: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIProperty: zoomBoxEnabled
|
||||||
|
* {Boolean} Whether the user can draw a box to zoom
|
||||||
|
*/
|
||||||
|
zoomBoxEnabled: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APIProperty: zoomWheelEnabled
|
* APIProperty: zoomWheelEnabled
|
||||||
* {Boolean} Whether the mousewheel should zoom the map
|
* {Boolean} Whether the mousewheel should zoom the map
|
||||||
@@ -129,7 +135,9 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
this.handlers.wheel.activate();
|
this.handlers.wheel.activate();
|
||||||
}
|
}
|
||||||
this.handlers.click.activate();
|
this.handlers.click.activate();
|
||||||
this.zoomBox.activate();
|
if (this.zoomBoxEnabled) {
|
||||||
|
this.zoomBox.activate();
|
||||||
|
}
|
||||||
return OpenLayers.Control.prototype.activate.apply(this,arguments);
|
return OpenLayers.Control.prototype.activate.apply(this,arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -252,6 +260,24 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
this.wheelChange(evt, delta || -1);
|
this.wheelChange(evt, delta || -1);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: disableZoomBox
|
||||||
|
*/
|
||||||
|
disableZoomBox : function() {
|
||||||
|
this.zoomBoxEnabled = false;
|
||||||
|
this.zoomBox.deactivate();
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method: enableZoomBox
|
||||||
|
*/
|
||||||
|
enableZoomBox : function() {
|
||||||
|
this.zoomBoxEnabled = true;
|
||||||
|
if (this.active) {
|
||||||
|
this.zoomBox.activate();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: disableZoomWheel
|
* Method: disableZoomWheel
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -71,6 +71,28 @@
|
|||||||
OpenLayers.Control.prototype.destroy = temp;
|
OpenLayers.Control.prototype.destroy = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function test_Control_Navigation_disableZoomBox(t) {
|
||||||
|
t.plan(2);
|
||||||
|
var nav = new OpenLayers.Control.Navigation();
|
||||||
|
var zb = new OpenLayers.Control.ZoomBox({});
|
||||||
|
nav.zoomBox = zb;
|
||||||
|
zb.activate();
|
||||||
|
nav.disableZoomBox();
|
||||||
|
t.eq(nav.zoomBoxEnabled, false, "zoom box deactivated");
|
||||||
|
t.eq(zb.active, false, "zoom box control deactivated");
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_Control_Navigation_enableZoomBox(t) {
|
||||||
|
t.plan(2);
|
||||||
|
var nav = new OpenLayers.Control.Navigation();
|
||||||
|
var zb = new OpenLayers.Control.ZoomBox({});
|
||||||
|
nav.zoomBox = zb;
|
||||||
|
nav.active = true;
|
||||||
|
nav.enableZoomBox();
|
||||||
|
t.eq(nav.zoomBoxEnabled, true, "zoom box activated");
|
||||||
|
t.eq(zb.active, true, "zoom box control activated");
|
||||||
|
}
|
||||||
|
|
||||||
function test_Control_Navigation_disableZoomWheel(t) {
|
function test_Control_Navigation_disableZoomWheel(t) {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
var nav = new OpenLayers.Control.Navigation();
|
var nav = new OpenLayers.Control.Navigation();
|
||||||
|
|||||||
Reference in New Issue
Block a user