I can succesfully do:
point.transform(new OpenLayers.Projection("EPSG:900913"), new OpenLayers.Projection("EPSG:4326"));
To a point that is in the google format (in meters), but when I want to do the reverse:
point.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
to a point that is in 4326 (regular lat/lon format), I am having some issues.
Any negative value seems to become NaN (not a number) when I do the transformation. Is there something about the transformation in reverse that I don't understand?
Edit: Even worse, when I have no negative values, the coordinates seem off. I am getting the coordinates by drawing a square on the screen, then saving those coordinates to a database and loading them later. I can draw a square near the tip of africa (positive coordinates), and then when it loads it's near the top of africa, in the atlantic ocean. I'm definitely doing something wrong....
Edit: Here's my code: http://pastie.org/911524
Specifically: this is how I initialize my map:
var navControl = new OpenLayers.Control.Navigation();
map = new OpenLayers.Map('map', {
// restrictedExtent: bounds.clone(),
});
//actually draws the map
layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
displayOutsideMaxExtent: false,
wrapDateLine: true
//numZoomLevels: 10
});