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?