`navigator.geolocation.watchPosition()`返回undefined

时间:2014-08-20 14:48:44

标签: javascript angularjs geolocation w3c-geolocation

非常简单的问题:为什么以下代码返回未定义的值?功能

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

有没有人对此有任何想法?
感谢高级!!!

0 个答案:

没有答案