【问题标题】:ionic2: geolocation in browser fails with error: EXCEPTION: Uncaught (in promise): falseionic2:浏览器中的地理定位失败并出现错误:异常:未捕获(承诺中):错误
【发布时间】:2025-12-22 21:05:06
【问题描述】:

我正在使用带有 ionic2 的地理定位插件。当应用程序在浏览器中加载时,它会请求许可。但是在调用 getcurrentposition 时它并没有得到位置。我用的是火狐浏览器。

控制台日志显示错误:

例外:未捕获(承诺):错误

我需要根据 getcurrentlocation 调用的成功或失败将位置(如果可用)或 null 传递给另一个函数。

这里是sn-p的代码:

 public test(){
 Geolocation.getCurrentPosition().then((resp) => {

 console.log (resp.coords.latitude);
 console.log (resp.coords.longitude);

  this.callclockin(resp.coords.latitude, resp.coords.longitude);    
 }).catch((error) => {
  this.callclockin("", "");   
 });
 }

【问题讨论】:

    标签: ionic-framework firefox-addon ionic2


    【解决方案1】:

    插件Geolocation 用于移动设备

    如果要将catch 扔到移动设备中,请查看我在此link 中的其他答案

    【讨论】:

      最近更新 更多