1

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?

5

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:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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