Loading lib/proj4js.js +22 −3 Original line number Diff line number Diff line Loading @@ -511,6 +511,12 @@ Proj4js.Proj = Proj4js.Class({ */ localCS: false, /** * Property: queue * Buffer (FIFO) to hold callbacks waiting to be called when projection loaded. */ queue: null, /** * Constructor: initialize * Constructor for Proj4js.Proj objects Loading @@ -519,7 +525,7 @@ Proj4js.Proj = Proj4js.Class({ * srsCode - a code for map projection definition parameters. These are usually * (but not always) EPSG codes. */ initialize: function(srsCode) { initialize: function(srsCode, callback) { this.srsCodeInput = srsCode; //check to see if this is a WKT string Loading Loading @@ -573,6 +579,13 @@ Proj4js.Proj = Proj4js.Class({ this.srsAuth = ''; this.srsProjNumber = this.srsCode; } //Register callbacks prior to attempting to process definition this.queue = []; if( callback ){ this.queue.push( callback ); } this.loadProjDefinition(); }, Loading Loading @@ -623,6 +636,12 @@ Proj4js.Proj = Proj4js.Class({ defsLoaded: function() { this.parseDefs(); this.loadProjCode(this.projName); if( this.queue ) { var item; while( (item = this.queue.shift()) ) { item.call( this, this ); } } }, /** Loading test/runtests.js +3 −15 Original line number Diff line number Diff line /* Loop through the test points and create a Proj object for each */ function runTests() { for (var i=0; i < Proj4js.testPoints.length; ++i) { var test = Proj4js.testPoints[i]; var proj = new Proj4js.Proj(test.code); checkProjLoaded.call(proj, test); } var proj = new Proj4js.Proj(test.code, Proj4js.bind(showResults, this, test)); } /* a timer that waits for the readyToUse flag to be set. This gets called in * the context of the Proj4js.Proj object */ function checkProjLoaded(test) { if (!this.readyToUse) { window.setTimeout(Proj4js.bind(checkProjLoaded, this, test), 500); } else { showResults(this, test); } } /* a callback function to run the test for this test point since we are using the dynamic load capabilities in the test page */ function showResults(proj, test) { function showResults(test, proj) { //var test = proj.testPoint; var xyEPSLN = 1.0e-2; var llEPSLN = 1.0e-6; Loading Loading
lib/proj4js.js +22 −3 Original line number Diff line number Diff line Loading @@ -511,6 +511,12 @@ Proj4js.Proj = Proj4js.Class({ */ localCS: false, /** * Property: queue * Buffer (FIFO) to hold callbacks waiting to be called when projection loaded. */ queue: null, /** * Constructor: initialize * Constructor for Proj4js.Proj objects Loading @@ -519,7 +525,7 @@ Proj4js.Proj = Proj4js.Class({ * srsCode - a code for map projection definition parameters. These are usually * (but not always) EPSG codes. */ initialize: function(srsCode) { initialize: function(srsCode, callback) { this.srsCodeInput = srsCode; //check to see if this is a WKT string Loading Loading @@ -573,6 +579,13 @@ Proj4js.Proj = Proj4js.Class({ this.srsAuth = ''; this.srsProjNumber = this.srsCode; } //Register callbacks prior to attempting to process definition this.queue = []; if( callback ){ this.queue.push( callback ); } this.loadProjDefinition(); }, Loading Loading @@ -623,6 +636,12 @@ Proj4js.Proj = Proj4js.Class({ defsLoaded: function() { this.parseDefs(); this.loadProjCode(this.projName); if( this.queue ) { var item; while( (item = this.queue.shift()) ) { item.call( this, this ); } } }, /** Loading
test/runtests.js +3 −15 Original line number Diff line number Diff line /* Loop through the test points and create a Proj object for each */ function runTests() { for (var i=0; i < Proj4js.testPoints.length; ++i) { var test = Proj4js.testPoints[i]; var proj = new Proj4js.Proj(test.code); checkProjLoaded.call(proj, test); } var proj = new Proj4js.Proj(test.code, Proj4js.bind(showResults, this, test)); } /* a timer that waits for the readyToUse flag to be set. This gets called in * the context of the Proj4js.Proj object */ function checkProjLoaded(test) { if (!this.readyToUse) { window.setTimeout(Proj4js.bind(checkProjLoaded, this, test), 500); } else { showResults(this, test); } } /* a callback function to run the test for this test point since we are using the dynamic load capabilities in the test page */ function showResults(proj, test) { function showResults(test, proj) { //var test = proj.testPoint; var xyEPSLN = 1.0e-2; var llEPSLN = 1.0e-6; Loading