2

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.

3

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.

  • Thanks for your response, previously var myExtent = new OpenLayers.Bounds(60, 23, 79, 37).transform(geographic, mercator); was returning bounds + center, when I used directly restrictedExtent : [6144368.4360405, 2724576.0254419, 9236093.3556889, 4446549.3984107], my problem was solved. – Mk Swati Sep 29 '15 at 13:09
  • @MkSwati Ok, please tik my answer! – Samane Sep 30 '15 at 11:37

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.