[GIS] Convert point to lon lat openlayers 2

openlayers-2

I'm trying to make an alert window show the current mouse coordinates in openlayers 2 using the google maps projection EPSG:4326. Essentially like this post but in openlayers2.

But its not working out like that. I get . . .

I get . . .

Heres the code inside the click event.

var point = map.getLonLatFromPixel(e.xy);
                    myXY = new OpenLayers.LonLat(point.lon,point.lat).transform('EPSG:4326', 'EPSG:102113');
                    alert(myXY);

Best Answer

This does it for those of you who are having this issue

    //inside click event
    var lonlat = map.getLonLatFromPixel(e.xy);
    var converted = lonlat.transform(map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
    alert(converted);