View Full Version : Get coordinates from nested function

21 Feb 2012, 6:12 PM
Hi. I am new to extjs and I need some help with something I have been struggling for a few days. I am trying to return the coordinates from a function. See code snippet below. I am trying to return the latitude and assign it to the variable 'latt'.

var getLat = function(){
var myLat = 0.00;

navigator.geolocation.getCurrentPosition(function(p) {
myLat = p.coords.latitude;
//coords[1] = p.coords.latitude;

}, function(error){

alert("Failed to get GPS location");


return myLat;

var latt = getLat();

21 Feb 2012, 7:10 PM
You will need to think asynchronously. You need to act on it in that callback function.