[OpenLayers-Users] Adjust sensitivity of keyboard control and mouse wheel

Andreas Hocevar ahocevar at opengeo.org
Wed Jun 24 15:20:56 EDT 2009


Hi,

On Wed, Jun 24, 2009 at 6:27 PM, soatley<shawn at niagarafalls.ca> wrote:
> Is there anyway to adjust the sensitivity of the keyboard controls (panning)
> and the mouse wheel (zooming)?  It would be nice if panning would pan a
> little more for each key press and the zoom wheel would be a little less
> sensitive.

Assuming you want this application-wide, the tweaks below have to be
done before creating the map object:

// drag movement in pixels, default is 75
OpenLayers.Control.KeyboardDefaults.prototype.slideFactor = 200; //
default is 50

For the mousewheel, a bit more customisation is required: if you want
to spin the wheel more before zooming occurs, you need a counter for
the wheelUp and wheelDown handlers:

OpenLayers.Control.Navigation.prototype.counter = 0;
OpenLayers.Control.Navigation.prototype.wheelUp = function(evt) {
    this.counter++;
    if(this.counter > 2) {
        this.counter = 0;
        this.wheelChange(evt, 1);
    }
};
OpenLayers.Control.Navigation.prototype.wheelDown = function(evt) {
    this.counter--;
    if(this.counter < -2) {
        this.counter = 0;
        this.wheelChange(evt, -1);
    }
};

In the above setup, you need to spin the wheel three times as far as
with the default config for the zoom to happen. If you want to make it
even less sensitive, replace the 2 (and -2 respectively) with a higher
number.

Regards,
Andreas.

>
> Shawn
> --
> View this message in context: http://n2.nabble.com/Adjust-sensitivity-of-keyboard-control-and-mouse-wheel-tp3149822p3149822.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list