[OpenLayers-Users] getCenter + reprojection

Volodymer Grigorenko wolgri at googlemail.com
Thu Oct 16 04:36:24 EDT 2008


Hi all
i`ve have a problem with get center and in prop projection
the situation is so function  below works fine but when browser window
changes size it centers extend on 0lat 0lon

ant suggestions

var options = { controls: [],
 projection: new OpenLayers.Projection("EPSG:900913"),
 displayProjection: new OpenLayers.Projection("EPSG:4326"),
 units: "dd",
 maxResolution: 156543.0339,
 maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
20037508.34, 20037508.34)
};
map.events.register('moveend', map, function(){prncenter();});



function prncenter() {

    b=map.getCenter();
    a=b.transform( map.getProjectionObject(),map.displayProjection);
    lat = formatDegrees(a.lat)
    lon = formatDegrees(a.lon)
    zproj = map.getProjectionObject();
    kproj = map.displayProjection;

    html= lat+"<br>"+lon+"<br>"+zproj+"<br>"+kproj
    document.getElementById('center').innerHTML = html
 };



More information about the Users mailing list