Setting default zoom level in OpenLayers

The second argument to map.setCenter is a zoom.

  var map = new OpenLayers.Map("mapdiv");
  // add layers here
  map.setCenter(new OpenLayers.LonLat(yourlon, yourlat), 5);

If you want something more complex than that, you're probably going to need to share more details about what your map and setup currently look like. (Projection, base layer, etc.)

Exemples are complexes because the way it works is not that simple

Since Zoom level and resolution are linked together, it could be a good start for you to read about it on the wiki page :, then choose the best way to process for the project you're working on.

Another way to set extent like you want

-Zoom to the extent you desired

-Get your current bbox

currentBbox = map.getExtent().left + ","+ map.getExtent().bottom + "," + map.getExtent().right + "," + map.getExtent().top;

-Copy result you got from console below


-Reuse the result you got by pasting it in map.zoomToExtent(new OpenLayers.Bounds(stringYouCopy));

So in your case, do in firebug console

map.zoomToExtent(new OpenLayers.Bounds(-1.395751953125, -2.051635742188, 11.787841796875, 10.582641601562));

If it's ok, you can add the code to your Openlayers application

Reusing "Christopher Schmidt" advice with map.setCenter, to get the right informations

-Zoom to the place you want

-To get lon

-To get lat

-To get zoom


It's up to you to complete (easy now)


Openlayers 2