make the Navigation control support pinch-zoom, r=bbinet (closes #3273)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11961 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -37,6 +37,18 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
dragPanOptions: null,
|
||||
|
||||
/**
|
||||
* Property: pinchZoom
|
||||
* {<OpenLayers.Control.PinchZoom>}
|
||||
*/
|
||||
pinchZoom: null,
|
||||
|
||||
/**
|
||||
* APIProperty: pinchZoomOptions
|
||||
* {Object} Options passed to the PinchZoom control.
|
||||
*/
|
||||
pinchZoomOptions: null,
|
||||
|
||||
/**
|
||||
* APIProperty: documentDrag
|
||||
* {Boolean} Allow panning of the map by dragging outside map viewport.
|
||||
@@ -124,6 +136,12 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.zoomBox.destroy();
|
||||
}
|
||||
this.zoomBox = null;
|
||||
|
||||
if (this.pinchZoom) {
|
||||
this.pinchZoom.destroy();
|
||||
}
|
||||
this.pinchZoom = null;
|
||||
|
||||
OpenLayers.Control.prototype.destroy.apply(this,arguments);
|
||||
},
|
||||
|
||||
@@ -139,6 +157,9 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
if (this.zoomBoxEnabled) {
|
||||
this.zoomBox.activate();
|
||||
}
|
||||
if (this.pinchZoom) {
|
||||
this.pinchZoom.activate();
|
||||
}
|
||||
return OpenLayers.Control.prototype.activate.apply(this,arguments);
|
||||
},
|
||||
|
||||
@@ -146,6 +167,9 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
* Method: deactivate
|
||||
*/
|
||||
deactivate: function() {
|
||||
if (this.pinchZoom) {
|
||||
this.pinchZoom.deactivate();
|
||||
}
|
||||
this.zoomBox.deactivate();
|
||||
this.dragPan.deactivate();
|
||||
this.handlers.click.deactivate();
|
||||
@@ -188,6 +212,11 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
||||
this, {"up" : this.wheelUp,
|
||||
"down": this.wheelDown},
|
||||
this.mouseWheelOptions );
|
||||
if (OpenLayers.Control.PinchZoom) {
|
||||
this.pinchZoom = new OpenLayers.Control.PinchZoom(
|
||||
OpenLayers.Util.extend(
|
||||
{map: this.map}, this.pinchZoomOptions));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,8 +18,26 @@
|
||||
OpenLayers.Control.prototype.initialize = temp;
|
||||
}
|
||||
|
||||
function test_draw(t) {
|
||||
t.plan(5);
|
||||
var map = new OpenLayers.Map({div: 'map', controls: []});
|
||||
var control = new OpenLayers.Control.Navigation();
|
||||
map.addControl(control);
|
||||
t.ok(control.handlers.click instanceof OpenLayers.Handler.Click,
|
||||
"click handler set in instance");
|
||||
t.ok(control.dragPan instanceof OpenLayers.Control.DragPan,
|
||||
"drag pan control set in instance");
|
||||
t.ok(control.zoomBox instanceof OpenLayers.Control.ZoomBox,
|
||||
"zoom box control set in instance");
|
||||
t.ok(control.handlers.wheel instanceof OpenLayers.Handler.MouseWheel,
|
||||
"mousewheel handler set in instance");
|
||||
t.ok(control.pinchZoom instanceof OpenLayers.Control.PinchZoom,
|
||||
"pinch zoom control set in instance");
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_Control_Navigation_destroy (t) {
|
||||
t.plan(10);
|
||||
t.plan(12);
|
||||
|
||||
var temp = OpenLayers.Control.prototype.destroy;
|
||||
OpenLayers.Control.prototype.destroy = function() {
|
||||
@@ -46,6 +64,11 @@
|
||||
t.ok(true, "zoomBox destroyed");
|
||||
}
|
||||
},
|
||||
'pinchZoom': {
|
||||
'destroy': function() {
|
||||
t.ok(true, "pinchZoom destroyed");
|
||||
}
|
||||
},
|
||||
handlers: {
|
||||
'wheel': {
|
||||
'destroy': function() {
|
||||
@@ -66,6 +89,7 @@
|
||||
|
||||
t.eq(control.dragPan, null, "'dragPan' set to null");
|
||||
t.eq(control.zoomBox, null, "'zoomBox' set to null");
|
||||
t.eq(control.pinchZoom, null, "'pinchZoom' set to null");
|
||||
t.eq(control.handlers, null, "handlers set to null");
|
||||
|
||||
OpenLayers.Control.prototype.destroy = temp;
|
||||
|
||||
Reference in New Issue
Block a user