Adding a PinchZoom control for smooth zooming on multi-touch devices. p=bbinet,me r=crschmidt (closes #3105)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11544 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2011-02-26 02:22:45 +00:00
parent 1425c2b0e6
commit f785153bca
7 changed files with 326 additions and 9 deletions

View File

@@ -5,14 +5,15 @@
/**
* @requires OpenLayers/Control/DragPan.js
* @requires OpenLayers/Control/PinchZoom.js
* @requires OpenLayers/Handler/Click.js
*/
/**
* Class: OpenLayers.Control.TouchNavigation
* The navigation control handles map browsing with touch events (dragging,
* double-tapping, and tap with two fingers). Create a new navigation
* control with the <OpenLayers.Control.TouchNavigation> control.
* double-tapping, tap with two fingers, and pinch zoom). Create a new
* control with the <OpenLayers.Control.TouchNavigation> constructor.
*
* Inherits:
* - <OpenLayers.Control>
@@ -31,6 +32,18 @@ OpenLayers.Control.TouchNavigation = OpenLayers.Class(OpenLayers.Control, {
*/
dragPanOptions: null,
/**
* Property: pinchZoom
* {<OpenLayers.Control.PinchZoom>}
*/
pinchZoom: null,
/**
* APIProprety: pinchZoomOptions
* {Object} Options passed to the PinchZoom control.
*/
pinchZoomOptions: null,
/**
* APIProperty: documentDrag
* {Boolean} Allow panning of the map by dragging outside map viewport.
@@ -70,6 +83,10 @@ OpenLayers.Control.TouchNavigation = OpenLayers.Class(OpenLayers.Control, {
this.dragPan.destroy();
}
this.dragPan = null;
if (this.pinchZoom) {
this.pinchZoom.destroy();
delete this.pinchZoom;
}
OpenLayers.Control.prototype.destroy.apply(this,arguments);
},
@@ -80,6 +97,7 @@ OpenLayers.Control.TouchNavigation = OpenLayers.Class(OpenLayers.Control, {
if(OpenLayers.Control.prototype.activate.apply(this,arguments)) {
this.dragPan.activate();
this.handlers.click.activate();
this.pinchZoom.activate();
return true;
}
return false;
@@ -92,11 +110,12 @@ OpenLayers.Control.TouchNavigation = OpenLayers.Class(OpenLayers.Control, {
if(OpenLayers.Control.prototype.deactivate.apply(this,arguments)) {
this.dragPan.deactivate();
this.handlers.click.deactivate();
this.pinchZoom.deactivate();
return true;
}
return false;
},
/**
* Method: draw
*/
@@ -119,6 +138,9 @@ OpenLayers.Control.TouchNavigation = OpenLayers.Class(OpenLayers.Control, {
}, this.dragPanOptions)
);
this.dragPan.draw();
this.pinchZoom = new OpenLayers.Control.PinchZoom(
OpenLayers.Util.extend({map: this.map}, this.pinchZoomOptions)
);
},
/**