[Proj] [proj4js] problem converting from openlayers lon/lat values

piko piklas at gmail.com
Wed Sep 2 23:12:26 EST 2009

Hi list
I'm new to this list and hope that some one can help me solve the following

In a OpenLayers code, i developed a specific control to draw 2 points, get
lon/lat values from these points and then send them to different input forms
as EPSG:4326 values.

Then, for another need i have to convert those values into metric values
using proj4js.js and EPSG27563.js.

It works well but the problem is that on the first created point i only get
4326 values, and then 27563 values for the second point. It seems very
strange to me and i cannot solve as my javascript skills are quiet limited.

Many thanks by advance for any hits on this problem

Nick bozon


var onTrigPt = function() {
  if (!this.control) {
              var geometry = evt.feature.geometry;
		var lonlat = map.getLonLatFromViewPortPx(geometry);
		var arrondzXPt = Math.round(lonlat.lon*1000) / 1000; 
		var arrondzYPt = Math.round(lonlat.lat*1000) / 1000; 
		var point = new Proj4js.Point(arrondzXPt,arrondzYPt);
		var source = new Proj4js.Proj('EPSG:4236');    
		var dest = new Proj4js.Proj('EPSG:27563'); 
		var lambv= Proj4js.transform(source, dest, point);  		
		if (evt.feature.attributes._index == 1) {
		document.forms["defineParams"].Pt1X.value = arrondzXPt;
		document.forms["defineParams"].Pt1Y.value = arrondzYPt;    
// here i get the not expected EPSG:4326 values in my alert

		document.forms["defineParams"].Pt2X.value = arrondzXPt;
		document.forms["defineParams"].Pt2Y.value = arrondzYPt; 

//here i get the right EPSG:27563 values
View this message in context: http://n2.nabble.com/proj4js-problem-converting-from-openlayers-lon-lat-values-tp3571188p3571188.html
Sent from the PROJ.4 mailing list archive at Nabble.com.

More information about the Proj mailing list