I am using Proj4js to transform between WGS84 and a local Swedish grid RT90 (EPSG:2400). It works in FF, but in IE the Proj objects often is not readyToUse when I need them to.

I use this code to initialize the transformation objects (part of a bigger object):


tera.wp = {
reproject: {

    referenceSystem2400: null,
    referenceSystem4326: null,

    initializeReferenceSystems: function() {

        Proj4js.defs["EPSG:2400"] = "+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs";

        var self = this;
        if (self.referenceSystem2400 == null) {
            self.referenceSystem2400 = new Proj4js.Proj("EPSG:2400");
        if (self.referenceSystem4326 == null) {
            self.referenceSystem4326 = new Proj4js.Proj("WGS84");

        var loaded2400 = self.referenceSystem2400.readyToUse;
        var loaded4326 = self.referenceSystem4326.readyToUse;

        alert("init: " + loaded2400 + ", " + loaded4326);


init: function() {
    var self = this;


    // In this call, the transformation is performed
    this.repopulateFromSession(function() {


the web page

<script src="http://maps.google.se/maps/api/js?v=3&sensor=false&language=sv&region=SE" type="text/javascript"></script>
<script src="/scripts/proj4js/lib/proj4js.js" type="text/javascript"></script>
<script src="/scripts/proj4js/lib/defs/EPSG2400.js" type="text/javascript"></script>
<script src="/scripts/wp/wp.js" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function() {

The explicit declaration of the 2400 parameters is to really ensure that the parameters are ok, and does not have to be loaded from anywhere. (I've been at this a while now)

Although, when I load the page and run the initializeReferenceSystems function, the alert shows init: false, true indicating that the 2400 object has not loaded properly.

What can I do to ensure that both my transformation objects are ready to use like this?

  • When using Proj4js' error handling with an alert box, I get "Proj4js initialization for EPSG:4326 not yet complete". Which contradicts the readyToUse flags, which suggested that 2400 was not ready, but the 4326 was... – Niklas Wulff Jul 6 '11 at 10:29
  • The error message in my previous comment is due to a bug in Proj4js. Regardless of which object being not ready, it states that the source object isn't ready. Strange. – Niklas Wulff Jul 6 '11 at 13:06

It turns out to be the underlying tmerc definition that didn't load properly. It's supposed to be loaded dynamically when requesting the 2400 object, since it's based on that projection. But IE must somehow forget to load it, or be too slow or something. My problem disappeared when I included the tmerc file manually in my html file:

<script src="/scripts/proj4js/lib/projCode/tmerc.js" type="text/javascript"></script>    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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