OpenLayers OpenLayers

Ticket #1339: zoomwheel.patch

File zoomwheel.patch, 3.3 kB (added by crschmidt, 10 months ago)
  • lib/OpenLayers/Control/Navigation.js

    old new  
    3737    zoomBox: null, 
    3838 
    3939    /** 
     40     * APIProperty: zoomWheelEnabled 
     41     * {Boolean} Whether the mousewheel should zoom the map 
     42     */ 
     43    zoomWheelEnabled: true,  
     44 
     45    /** 
    4046     * Constructor: OpenLayers.Control.Navigation 
    4147     * Create a new navigation control 
    4248     *  
     
    7581     */ 
    7682    activate: function() { 
    7783        this.dragPan.activate(); 
    78         this.handlers.wheel.activate(); 
     84        if (this.zoomWheelEnabled) { 
     85            this.handlers.wheel.activate(); 
     86        }     
    7987        this.handlers.click.activate(); 
    8088        this.zoomBox.activate(); 
    8189        return OpenLayers.Control.prototype.activate.apply(this,arguments); 
     
    168176    wheelDown: function(evt) { 
    169177        this.wheelChange(evt, -1); 
    170178    }, 
     179     
     180    /** 
     181     * Method: disableZoomWheel 
     182     */ 
     183     
     184    disableZoomWheel : function() { 
     185        this.zoomWheelEnabled = false; 
     186        this.handlers.wheel.deactivate();        
     187    }, 
     188     
     189    /** 
     190     * Method: enableZoomWheel 
     191     */ 
     192     
     193    enableZoomWheel : function() { 
     194        this.zoomWheelEnabled = true; 
     195        if (this.active) { 
     196            this.handlers.wheel.activate(); 
     197        }     
     198    }, 
    171199 
    172200    CLASS_NAME: "OpenLayers.Control.Navigation" 
    173201}); 
  • examples/navigation-control.html

    old new  
     1<html xmlns="http://www.w3.org/1999/xhtml"> 
     2  <head> 
     3    <title>OpenLayers Navigation Control</title> 
     4    <link rel="stylesheet" href="../theme/default/style.css" type="text/css" /> 
     5    <style type="text/css"> 
     6        #map { 
     7            width: 512px; 
     8            height: 512px; 
     9            border: 1px solid black; 
     10        } 
     11    </style> 
     12    <script src="../lib/OpenLayers.js"></script> 
     13    <script type="text/javascript"> 
     14        var map, layer; 
     15        function init(){ 
     16            map = new OpenLayers.Map( 'map', { controls: [] }); 
     17            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
     18                    "http://labs.metacarta.com/wms/vmap0", 
     19                    {layers: 'basic'} ); 
     20            map.addLayer(layer); 
     21            nav = new OpenLayers.Control.Navigation({'zoomWheelEnabled': false}); 
     22            map.addControl(nav); 
     23            map.zoomToMaxExtent(); 
     24        } 
     25    </script> 
     26  </head> 
     27  <body onload="init()"> 
     28    <h1 id="title">Navigation Control</h1> 
     29 
     30    <div id="tags"></div> 
     31 
     32    <div id="shortdesc">Demonstrate Navigation Control features</div> 
     33 
     34    <div id="map"></div> 
     35    <a href="#" onclick="nav.enableZoomWheel();return false">Turn on Wheel Zoom</a> | <a href="#" onclick="nav.disableZoomWheel(); return false;">Turn off Wheel Zoom</a> 
     36    <div id="docs"> 
     37        This example demonstrates a couple features of the Navigation control. The Navigation control controls most map dragging, movement, zooming, etc. In this case, we have a demonstration of how to create a navigation control with no zoom wheel action, which can then be enabled or disabled by the user. 
     38    </div> 
     39  </body> 
     40</html>