[OpenLayers-Commits] r11961 - in trunk/openlayers: lib/OpenLayers/Control tests/Control

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Mon May 9 04:28:38 EDT 2011


Author: erilem
Date: 2011-05-09 01:28:35 -0700 (Mon, 09 May 2011)
New Revision: 11961

Modified:
   trunk/openlayers/lib/OpenLayers/Control/Navigation.js
   trunk/openlayers/tests/Control/Navigation.html
Log:
make the Navigation control support pinch-zoom, r=bbinet (closes #3273)

Modified: trunk/openlayers/lib/OpenLayers/Control/Navigation.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/Navigation.js	2011-05-09 08:07:52 UTC (rev 11960)
+++ trunk/openlayers/lib/OpenLayers/Control/Navigation.js	2011-05-09 08:28:35 UTC (rev 11961)
@@ -38,6 +38,18 @@
     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.
      *     Default is false.
@@ -124,6 +136,12 @@
             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 @@
         if (this.zoomBoxEnabled) {
             this.zoomBox.activate();
         }
+        if (this.pinchZoom) {
+            this.pinchZoom.activate();
+        }
         return OpenLayers.Control.prototype.activate.apply(this,arguments);
     },
 
@@ -146,6 +167,9 @@
      * Method: deactivate
      */
     deactivate: function() {
+        if (this.pinchZoom) {
+            this.pinchZoom.deactivate();
+        }
         this.zoomBox.deactivate();
         this.dragPan.deactivate();
         this.handlers.click.deactivate();
@@ -188,6 +212,11 @@
                                     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));
+        }
     },
 
     /**

Modified: trunk/openlayers/tests/Control/Navigation.html
===================================================================
--- trunk/openlayers/tests/Control/Navigation.html	2011-05-09 08:07:52 UTC (rev 11960)
+++ trunk/openlayers/tests/Control/Navigation.html	2011-05-09 08:28:35 UTC (rev 11961)
@@ -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;



More information about the Commits mailing list