title: Using navigator.geolocation.getCurrentPosition(); synchronously
body: <p>I have this function that is trying to return the latitude and longitude as a string when called. However when i call it with an alert it returns undefined. But when I alert the data.coords.latitude/longitude it gives me the correct values. Any help is greatly appreciated.</p>
  
  <pre><code>function GetLocation() {
      var jsonLocation;
      navigator.geolocation.getCurrentPosition(function (data) {
          jsonLocation = data.coords.latitude+','+data.coords.longitude;
      });
      return String(jsonLocation);
  }
  alert(GetLocation());
  </code></pre>