I am starting with maps but I am a beginner.

I cannot figure out why to use maxExtent. If I delete it from my application, its behavior doesn't change or I do not notice.

So why should I use it?

I understand purpose of restrictedExtent but not of maxExtent.

var extent = new OpenLayers.Bounds(-2003750.34, -2003750.34, 2003750.34, 2003750.34);
map = new OpenLayers.Map("map", {
        controls: [
                        new OpenLayers.Control.Navigation(),
                        new OpenLayers.Control.PanZoomBar(),
                        new OpenLayers.Control.ScaleLine(),
                        new OpenLayers.Control.Attribution(),
                        new OpenLayers.Control.LayerSwitcher()],
        maxExtent: extent,
        //restrictedExtent: extent,
        maxResolution: 156543.0399,
        numZoomLevels: 19,
        units: 'm',
        projection: new OpenLayers.Projection("EPSG:900913"),
        displayProjection: new OpenLayers.Projection("EPSG:4326")

var osm = new OpenLayers.Layer.OSM.Mapnik("Mapnik", { 'attribution': 'Provided by blop' });
var gmap = new OpenLayers.Layer.Google("Google Streets", { visibility: false });
map.addLayers([osm, gmap]);
  • I'd like to just point out, that there are incorrect bounds in your example - those are 10x smaller than should, check CaptDragon's answer for correct bounds for Google projection Commented Nov 1, 2013 at 10:08

1 Answer 1


maxExtent is used for other projections.

For instance by default it's the whole world in decimal degrees (-180, -90, 180, 90)

But if you are using a different projection such as EPSG:3857 You will need to modify the maxExtent. One that is valid for that projection. Which in the case of EPSG:3857 could be (-20037508.34, -20037508.34, 20037508.34, 20037508.34)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.