Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am having trouble converting a projected coordinate EPSG:28355 to WGS84 EPSG:4326 using Proj4js. I know by default Proj4 will not convert to EPSG:28355 so I went to spatialreference.org and got the proj4js format and placed it in my defs.

Now I know it can work because when I have the code below:

    var gridCoordinate = new Proj4js.Point(easting,northing);

alert(gridCoordinate);

var wgsPoint = new Proj4js.transform(theZone, wgs84, gridCoordinate);

alert(wgsPoint);

I get these results - same order as the alerts called above.

enter image description here

enter image description here

To me that looks like it has worked.

Then for some reason when I was done checking that it worked I removed the alerts so that my code looked like this

var gridCoordinate = new Proj4js.Point(easting,northing);
//alert(gridCoordinate);
var wgsPoint = Proj4js.transform(theZone, wgs84, gridCoordinate);
//alert(wgsPoint);

The thing stops working and gives me a projected coordinate on the WGS84 basemap which blows me off the edge of the earth.

So I kept playing around and put in one alert to see what the final coordinate looked liek (code below)

var gridCoordinate = new Proj4js.Point(easting,northing);
//alert(gridCoordinate);
var wgsPoint = Proj4js.transform(theZone, wgs84, gridCoordinate);
alert(wgsPoint);

And I got the following result

enter image description here

Same as the starting coordinate it looks like the conversion has not worked at all. Why on earth would an alert call be affecting the output of this conversion? Have I declared or am I setting my variables incorrectly?

Thanks

Ando

share|improve this question
add comment

1 Answer

This may be an issue of loading time (if you are using proj4js.js). Through the alerts there is enough time for loading the complete script. You could try to use proj4js-compressed.js instead.

share|improve this answer
    
Unfortunately I am already using the proj4js-compressed.js - This has stumped me big time! –  Ando May 17 '12 at 4:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.