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 need to define an layer in OpenLayers just showing world map. The most simpliest variant is to create OSM layer. When I do like this:

var layer = new OpenLayers.Layer.OSM("OSM");
map.addLayer(layer);

How can I define restrictions/bounds to show the world map?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

You can add restrictions to whole map and change its later (if necessary), for example:

var map, layer;
function init() {
    map = new OpenLayers.Map('map', {
        maxExtent: [-18924313.432222, -15538711.094146, 18924313.432222, 15538711.094146],
        restrictedExtent: [-13358338.893333, -9608371.5085962, 13358338.893333, 9608371.5085962],
    });
    layer = new OpenLayers.Layer.OSM("Simple OSM Map");
    map.addLayer(layer);
}

See also:

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.