Hello I am having an issue using the proj4js library. Here is my source:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="lib/proj4js-combined.js"></script>
</head>
<script type="text/javascript">
function go()
{
var lon = document.getElementById("xOrg").value;
var lat = document.getElementById("yOrg").value;
var reprojected = reproject(Number(lon),Number(lat));
document.getElementById("xNew").value = reprojected.x;
document.getElementById("yNew").value = reprojected.y;
}
function reproject(lon,lat)
{
var sourceSys = new Proj4js.Proj('WGS84');
var destSys = new Proj4js.Proj('EPSG:32187');
var pointSource = new Proj4js.Point(lon,lat);
var pointDest = Proj4js.transform(sourceSys, destSys, pointSource);
return pointDest;
}
</script>
<body>
<div>
<input id="xOrg" type="text" value="-73.56"/>
<input id="yOrg" type="text" value="45.49"/>
</div>
<div>
<input id="xNew" type="text" value=""/>
<input id="yNew" type="text" value=""/>
</div>
<div>
<input type="button" value="go" onclick="go()"/>
</div>
</body>
</html>
I don't understand why the reprojection only works when I click the button twice, when I click on it the first time, the same values are returned. It seems to only work when I click the button twice or more. Here is this page online: click