2

Community,

I'm currelty capturing my mouse click event and trying to transform the coordinates into Long Lat. I need to get at the Long Lat as strings so I can build a url and throw it at Google Street view. Current transform code only prints the BNG coords.

lonlat = map.getLonLatFromPixel(e.xy);

brit = new OpenLayers.Projection("EPSG:27700");
google = new OpenLayers.Projection("EPSG:900913");

lonlatclone = lonlat.clone()
lonlatclone.transform(brit, google)
//alert("You clicked near " + lonlatclone.lat + "N," + +lonlatclone.lon + "E");

Thanks!

3

Did you import the proj4js definitions for EPSG:27700? http://spatialreference.org/ref/epsg/27700/proj4js/

27700 is not included by default.

3

For any projection different than EPSG:4326 and EPSG:900913 you need to attach the proj4js project with projection definitions

2

EPSG:900913 (which is deprecated, you should really be using its modern synonym EPSG:3857) is a projected CRS, not lon/lat. So if you want a spherical mercator result, you'll need to transform from lon/lat to EPSG:3857, skipping EPSG:27700 completely.

Or if your getLonLatFromPixel() results are in EPSG:27700, you'll need to use EPSG:4326 as your destination.

1

Have you tried this?

var newLonLat = lonlatclone.transform(brit, google);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.