What is OpenLayers?

OpenLayers is a open source JavaScript library, which helps for the usage and development of web based map applications. Usually when you use something like http://openstreetmap.org you’ve a tile server, which contains, or dynamically, renders tiles on a specific coordinates and zoom level. Such application in basic are most of the map servers you may know, as Google, Yahoo and Live (now Bing). Than you need a layer above that, that must generate the correct HTTP queries to the server and after receiving the tiles to position them correctly. Of course a open library like OpenLayers do much more. In fact this is complex JavaScript application that gives enough flexability to manipulate rich map applications.

How to disable the zoom with the mouse wheel

Very common problem (if we can say so) in map sites is the scroll, cause sometimes the user wants to scroll the page, and sometimes to scroll the map, which action results in zooming the map. Yes, there are so many solutions as many are the combinations of those scenarios. But the case here was how to disable the mouse wheel on OpenLayers.

Why it’s not working

Described in the documentation as a simple task, it appears to be not so much! Following the official instructions, you must add those lines of code:

var movemap = new OpenLayers.Control.Navigation({
> 'zoomWheelEnabled': false});

movemap.disableZoomWheel();

… but that’s not working.

How to make it really work

Actually something’s blocking the effect of disableZoomWheel in the chain of the Control class, so the solution is as simple as it’s:

controls = map.getControlsByClass('
     >OpenLayers.Control.Navigation');

for(var I = 0; i<controls.length; ++i)
     controls.disableZoomWheel();

Related posts:

  1. OpenLayers disable dragging
  2. JavaScript disable mouse wheel
  3. Optimizing OpenLayers. Make it smaller and faster!
  4. Change the sea/ocean color of OpenLayers (OSM) map
  5. OpenLayers extreme optimization. Cut, compress and deploy!
  6. OpenLayers vectors IE bug!
  7. Optimizing OpenLayers. Speed up markers load time!
  8. Zend Framework – Disable Zend Layout
  9. Scroll the page with JavaScript
  10. jQuery: the difference between mouseout and mouseleave