如何在Angular中使用API​​密钥获取用户的当前位置

时间:2019-05-10 06:03:09

标签: angular location

我有获取当前位置的函数,但是当我调用此函数时,它并没有进入它的内部,只是将我推到该函数之外,请问我在创建此函数时犯了什么错误,我在使用API这个。 功能如下:

//Get current location
getLocation() {
  debugger;
 var that = this;
  $.get("https://someAPIlink", function (response) {
    debugger;
    $.get("https://someAPIlink" + response.country, function (response) {
      debugger;
     // that.current_location = response.name;
      let key = 'Country';
      localStorage.setItem(key, response.name);

    //  alert('Location'+that.current_location); 
//  this.UpdateCurrenLocation();
    });

  }, "jsonp");

}

请高度感谢您的帮助。 预先感谢!

0 个答案:

没有答案