[GIS] Restrict extent and Zoom in OpenLayers

extentsgeoextopenlayers-2zoom

There are too many question on this issue, but unfortunately I couldn't get the solution. I have the following settings,

var geographic = new OpenLayers.Projection("EPSG:4326"); // WGS 1984
var mercator = new OpenLayers.Projection("EPSG:900913"); // Spherical Mercator Projection
var myExtent = new OpenLayers.Bounds(60, 23, 79, 37).transform(geographic, mercator);

map : {
        title : "Map",
        projection : mercator,
        displayProjection: geographic,
        extent: myExtent,
        restrictedExtent: myExtent,
        }

The problem is that it zooms to the wrong location, secondly the pan is also not available.

Best Answer

Use this map, perhaps resolve your problem:

    map = new OpenLayers.Map({div:'map', allOverlays:true,
    projection: "EPSG:900913",
    maxExtent:new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
    maxResolution:156543.033928,
    minResolution:0.018661383858680724,
    displayProjection:new OpenLayers.Projection("EPSG:4326"),
    units: "m",
    numZoomLevels: 24,'sphericalMercator': true
});
// for panning and zooming:
nav=OpenLayers.Control.Navigation();
pan=new OpenLayers.Control.PanZoom();

map.addControls([nav,pan]);

nav.activate();
pan.activate();

If the problem is not resolved, We must use another method.