I have a OpenLayers vector with a single feature [0]. It's coordinates are in the map projection (EPSG:3413) and I want them in WGS84 (EPSG:4326) decimal degrees. I have the following code which executes with no errors.
// Transform the polygon to WGS84 (EPSG:4326)
polybound.features[0].geometry.transform(new OpenLayers.Projection("EPSG:3413"),new OpenLayers.Projection("EPSG:4326"));
// Get the extent/vertices of the polygon drawn
var polyBounds = polybound.features[0].geometry.getVertices(); alert(polyBounds);
var polyExt = polybound.features[0].geometry.getBounds(); alert(polyExt);
However both the alerts show the untransformed coordinates.
Eg:
alert(polyBounds);
POINT(-2486558.28125 -1947299.71875),POINT(-4121511.40625 -1737690.34375),POINT(-3555566.09375 -2722854.40625)
alert(polyExt);
-4121511.40625,-2722854.40625,-2486558.28125,-1737690.34375
How do I get the vector feature coordinates to transform correctly?
Best Answer
Please refer to the OpenLayer Docs for OpenLayers.Projection. The docs state the following:
So you need to refer to the Proj4JS library and have your projection file for EPSG:3413.
You should read this User Guide. You can download the library from here: Downloads. You will also need the file for your projection in Proj4 format. You can download that from here: Spatial reference.org