I'm using the proj4s javascript library (based on advice from this question I asked previously) to convert lat/long values on my webpage. This page receives the lat/long values from google maps and converts them to the British National Grid (ORD SURV GB), which wikipedia tells me has the following code: EPSG:27700. I want to calculate the maximum and minimum values of both the latitude and longitude, so I can query a database.
My code is as follows:
var source = new Proj4js.Proj('WGS84');
var dest = new Proj4js.Proj('EPSG:27700');
bounds = map.getBounds() // Get bounds of map after user pans around
zoom = map.getZoom() // Get zoom level
xMax = bounds.getNorthEast().lat() //get max and min values for lat/long
yMax = bounds.getNorthEast().lng()
xMin = bounds.getSouthWest().lat()
yMin = bounds.getSouthWest().lng()
alert('xMin: ' + xMin + '\nxMax: ' + xMax)
alert('yMin: ' + yMin + '\nyMax: ' + yMax)
// transforming point coordinates
var latXNew = new Proj4js.Point( xMin, xMax );
var latYNew = new Proj4js.Point( yMin, yMax );
Proj4js.transform(source, dest, latXNew);
Proj4js.transform(source, dest, latYNew);
However, I'm not getting the correct results from my webpage. I've loaded in a kml file that has a rectangle with boundaries that I know, and the values don't match up. They appear to be off by at least a factor of approximately 8.
NE Lat: 52.25635981528854
NE Lng: 1.3534606328125243
Expected Lat: 500000.0
Expected Lng: 150000.0
Returned Lat: -5527596.989640327 (incorrect)
Returned Lng: 622727.1071581601 (incorrect)
What am I doing incorrectly?