非常简单的问题:为什么以下代码返回未定义的值?功能
GetLocation(location) {
Lat = location.coords.latitude;
Lon = location.coords.longitude;
gCoords = "gCoords: " + Lat + "," + Lon;
gLat = Lat;
gLon = Lon;
$timeout(function() {
calculate();
});
return [gCoords, gLat, gLon];
}
var GPSInfo = navigator.geolocation.watchPosition(GetLocation);
var info1 = GPSInfo[0]
var info2 = GPSInfo[1]
var info3 = GPSInfo[2]
console.log(
"gCoords: " + info1 +
" gLat: " + info2 +
" gLon: " + info3 )
控制台记录下:gCoords: undefined gLat: undefined gLon: undefined
有没有人对此有任何想法?
感谢高级!!!