Can anyone suggest how to access latitude and longitude we get from HTML5 geolocation outside of getCurrentPosition function? I don't want to show it on UI but need to send it to my spring controller. but can't access it outside the function.
Here is the code am referring too:
if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    }
    function showPosition(position) {
        $scope.PostLoc = {latitude: null, longitude: null };
        var lat = position.coords.latitude;
        var longi = position.coords.longitude;
       // var result = [lat, longi]; // it's an array
       // return result;
    }
I want this lat and longi variable to be access outside showPosition function; but not successful, can anybody help, its already been few hours and am stucked. I want to send these to my controller and call google places api. 
Thank you very much. please respond.
 
     
    