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");

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


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");

See also:

| improve this answer | |

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.