R: Re: [OpenLayers-Users] Change mouseWheel behavior only in down
event
francescoboccacci at libero.it
francescoboccacci at libero.it
Fri May 4 09:35:14 EDT 2012
hi,
the problem is if i deactive a zoomWheel at certain zoom level i can't zoom
into map (zoom up event) and the zoom level it doesn't change anymore and so
all it stopped.
Maybe i found a solution:
map.controls[1].disableZoomWheel(); // disable the original behavior of
mousewheel
//create a new control//
var mousewheel = new OpenLayers.Control();
OpenLayers.Util.extend(mousewheel, {
// The draw method is called when the control is initialized
draw: function () {
this.mouse= new OpenLayers.Handler.MouseWheel(mousewheel, {"up":
mouseUp, "down": mouseDown});
this.mouse.activate();
}});
//add new control
map.addControl(mousewheel);
// change behavior of mouse wheel functions
function mouseUp(){map.zoomTo(map.zoom+1);}
function mouseDown(){
if (map.zoom > 10){
map.zoomTo(map.zoom-1);
} }
It seems it works.I have to test more in deep
Thanks
Francesco
>----Messaggio originale----
>Da: francesco.dalesio at r3-gis.com
>Data: 04/05/2012 15.23
>A: "francescoboccacci at libero.it"<francescoboccacci at libero.it>
>Cc: <openlayers-users at lists.osgeo.org>
>Ogg: Re: [OpenLayers-Users] Change mouseWheel behavior only in down event
>
>Hi Francesco,
>you can listen to the map zoomend event, then you can get the current
>zoom level with map.getZoom() and de/activate the zoomWheel consequently.
>
>Hope this helps
>
>
>Francesco
>
>
>Il 04/05/2012 14:39, francescoboccacci at libero.it ha scritto:
>> Hi all,
>> i have a question about mouseWheel event.
>> I would like to change the behavior of mouse wheel event. I would like to
>> disable mousewheel "down" event if the map.zoom = 10 and active it if it is
>> great than 10.
>> How is possible to do that?
>> I find just this example but it disable mouseWheel behavior in general:
>>
>> map.controls[1].disableZoomWheel()
>>
>> Thanks
>>
>> Francesco
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
>--
>
>
More information about the Users
mailing list