Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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!

share|improve this question

4 Answers 4

up vote 3 down vote accepted

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

27700 is not included by default.

share|improve this answer

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

share|improve this answer

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.

share|improve this answer
    
thanks for the info. Now using 4326 –  geo_james Feb 22 '12 at 13:07

Have you tried this?

var newLonLat = lonlatclone.transform(brit, google);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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