Sal_Joensen

Attempting to implement Proj4js

Discussion created by Sal_Joensen on Apr 10, 2012
Latest reply on Apr 11, 2012 by Sal_Joensen
I'm trying to implement the Proj4js to convert geographic points from EPSG:32629 to EPSG:4326, instead of using geometry service, because it is easier on the server to do the conversion client-side.

I've followed the guide here:
http://www.polygongis.com/index.php/2011/05/02/proj4js-client-side-coordinate-conversion/

But the converted points are incorrect, compared to the geometry service that we have running.

The webpage we have it running on is: http://www.munin.fo/fiskikort.html (might not be available in the future)

but the relevant code is:
    <script type="text/javascript" src="proj4js/lib/proj4js-combined.js"></script>


 Proj4js.defs["EPSG:4326"] = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
 Proj4js.defs["EPSG:32629"] = "+proj=utm +zone=29 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
 
 var src = new Proj4js.Proj("EPSG:32629");
 var dst = new Proj4js.Proj("EPSG:4326");

/* ... */

 function projektión(evt) {
  // get mapPoint from event and display the mouse coordinates
  
  var point = new Proj4js.Point(evt.x, evt.y);
  var outpt = Proj4js.transform(src, dst, point);
  console.log("x: " + outpt.x + " y: " + outpt.y);
 }


I must be doing something wrong because the examples I've seen show that Proj4js works instead of a geometry service.

Outcomes