0

My script allows you to drawn shapes on an OpenLayers map, and then to get the WKT information from that shape, except the returned coordinates are in EPSG::900913 and I need them to be in lat/lon.

  • Welcome to GIS Stack Exchange! I'm not sure if you had trouble posting a relevant snippet from your code to indicate where you thought your problem might lie but I think you will need to do so in order to get assistance. – PolyGeo Jun 3 '13 at 10:31
2

You need to project (transform) the shape from EPSG:900913 (actually use the standard EPSG:3857) to EPSG:4326.

You can use the following code:

var gcs=new OpenLayers.Projection("EPSG:4326");
var webMercator=new OpenLayers.Projection("EPSG:3857");

/*I am assuming that you have a polygon in web mercator. You can do this for points and lines as well*/
var polygon_wgs84=poly.transform(webMercator, gcs);

//now you can convert the polygon to wkt
console.log(polygon_wgs84.toString(););

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.