I searching to return the position.coords outside the scope of the function navigator.geolocation.getCurrentLocation(getLocation,err). I have tried using window vars but i'm not able, all values are always locals. Can someone point the way. Thanks
            Asked
            
        
        
            Active
            
        
            Viewed 669 times
        
    2
            
            
        - 
                    for the correct answer see http://stackoverflow.com/questions/9935059/saving-variables-outside-of-navigator-geolocation-getcurrentposition-javascrip – Anthony Hatzopoulos Nov 28 '12 at 20:29
1 Answers
-1
            
            
        I assume you mean getCurrentPosition. If you just need the coordinates, you can do this.
return coords.clone();
Update
getCurrentPosition requires a callback function. You can use it something like this:
navigator.geolocation.getCurrentPosition(function(pos) {
    alert(pos.coords.latitude+","+pos.coords.longitude);
});
 
    
    
        Michael Mior
        
- 28,107
- 9
- 89
- 113
- 
                    Assuming that getCurrentPosition(getLocation) is returning the function getLocation(position){return coords.clone();}, the result is NULL for coords=navigator.geolocation.getCurrentPosition(getLocation); Advice. – user325558 Jul 15 '11 at 23:53
- 
                    The result should be null. You need to provide a callback function to `getCurrentPosition`, it does not return the coordinates. – Michael Mior Jul 16 '11 at 00:38
