title: Get user location from navigator in controller
body: <p>I am using navigator.geolocation.getcurrentposition to get current user's location (lat/long). Here's my function:</p>
  
  <pre><code>function userLocation(){
  
      var response = [];
      if (navigator.geolocation) {
  
          navigator.geolocation.getCurrentPosition(function(p){
              // on success
              response['latitude'] = p.coords.latitude;
              response['longitude'] = p.coords.longitude;
  
              console.log(response);
  
          }, function(e){
              // on error
              console.log(e);
          });
  
      } else {
          console.log("Geolocation is not supported by this browser.");
      }
  
      return response;
  
  }
  </code></pre>
  
  <p>It always returns empty array and i understand that the getCurrentPosition function makes asynchronous call so it is not possible to return the response.</p>
  
  <p>I tried using google geocode api to get the location but that is based on user's IP address and not that accurate.</p>
  
  <p>I want a function to return these lat/long. Is there any way i can get the response from getCurrentPosition in my controller function?</p>