title: Making geolocation coordinates available to other functions
body: <p>I'm working on a basic JavaScript weather application. I'd like to pull the geolocation from the browser and make it accessible to my other functions.</p>
  
  <pre><code>function Weather( options ) {
  
      this.apiKey = options.key;
      this.endpoint = options.endpoint;
      this.coordinates = {};
  }
  
  Weather.prototype.GetLocation = function( callback ) {
      if (navigator.geolocation)
      {
          navigator.geolocation.getCurrentPosition( function(position) {
              this.coordinates.latitude = position.coords.latitude;
              this.coordinates.longitude = position.coords.longitude;
          });
      }
  };
  
  Weather.prototype.GetCurrentConditions = function() {
  
      this.GetLocation();
  
      var url = this.endpoint + "weather?lat=" + this.coordinates.latitude + "&amp;lon=" + this.coordinates.longitude;
  
      return this.getJSONP( url );
  };
  
  Weather.prototype.GetExtendedForecast = function() {
  
      this.GetLocation();
  
      var url = this.endpoint + "forecast/daily?lat=" + this.coordinates.latitude + "&amp;lon=" + this.coordinates.longitude + "&amp;cnt=7";
  
      return this.getJSONP( url );
  };
  </code></pre>
  
  <p>However, I keep getting undefined as my latitude and longitude. I read somewhere that if you want to use the coordinates that you have to save them in the callback function of getCurrentPosition which is what I did but I'm still unable to get anything other than undefined. Is there a way to make these values accessible to my other functions?</p>