Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am starting with maps but im a beginner. The answer is probably easy, but i could not find it anywhere. 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. Can you please somebody please explain it to me, thank you.

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]);
share|improve this question
    
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 –  user1702401 Nov 1 '13 at 10:08

1 Answer 1

up vote 2 down vote accepted

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)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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