Disable zoom with Openlayers

GeoffreyB picture GeoffreyB · Sep 11, 2012 · Viewed 12.4k times · Source

i'm using OpenLayers to display custom OSM maps on my website.

I've some points to respect: the map have to be fix (meaning that we can't drag it or zoom it).

I have a problem with the zoom, i can't manage to disable zoom with the mouse. Does anyone has a tip?

map = new OpenLayers.Map('map');
map.events.remove("move");
map.events.remove("movestart");
map.events.remove("moveend");
map.events.remove("zoomend");
map.events.remove("mouseover");
map.events.remove("mouseout");
map.events.remove("mousemove");
map.events.remove("zoomstart");
var nav = new OpenLayers.Control.Navigation({
  defaultDblClick: function(event) { return ; }
});
map[index].addControl(nav);

Also, if someone has a tip to remove all Navigation events easier than that, it would be greatly appreciated.

Answer

tonio picture tonio · Sep 11, 2012

Disable the default controls on your map by passing an empty array:

var map = new OpenLayers.Map('map', { controls: [] });