title: gelocation - asynchronous callback not working with error - Javascript
body: <p>myFn.getMyCurrentPosition(data, function(data){ //Async call, need to use data like a callback - this section doesnt work. How can I use the current position coords and use it in a different function like a successfull callback?</p>
  
  <pre><code>var myFn = {
      this.localVar : null, 
      mysuccess : function (position) {
          this.myLocalVar = position.coords.latitude + ','+ position.coords.longitude; 
          return this.myLocalVar; 
      }, 
      myerror : function (error) {     
          return null; 
      }, 
      getMyCurrentPosition : function() {
          if(navigator &amp;&amp; navigator.geolocation) { 
              //WORKS - mysuccess sets data asyncrhonously. 
              return navigator.geolocation.getCurrentPosition(this.mysuccess, this.myerror);          
          }
      }, 
      myInitializer : function(){
          //Initialize map, marker etc. for google maps API
          myFn.getMyCurrentPosition( function(){ //Async call, need to use data like a callback 
              //This code never runs! 
              if(this.myLocalVar){
                  //doSomethingAfterCall - using this.myLocalVar, map, etc.;
  
              }
          });
      }
  }
  </code></pre>
  
  <p>Update: TRIED THIS:  </p>
  
  <pre><code>var myFn = {
      mysuccess: function (position) {
          myFn.myInitializer(); 
      }, 
      myerror: function (error) { 
          myFn.myInitializer(); 
      }, 
  
       myInitializer : function(){
          //Initialize map, marker etc. for google maps API
      }, 
      onLoadSet : function(){
          navigator.geolocation.getCurrentPosition(this.mysuccess, this.myerror);
      }
  
  } 
  
  myFn.onLoadSet(); 
  </code></pre>
  
  <p>Get this error: Failed to execute 'getCurrentPosition' on 'Geolocation': The callback provided as parameter 1 is not a function.</p>