ionic2:浏览器中的地理位置失败,错误:EXCEPTION:Uncaught(in promise):false [英] ionic2: geolocation in browser fails with error: EXCEPTION: Uncaught (in promise): false
问题描述
我正在使用ionic2的geolocation插件。当应用程序在浏览器中加载时,它会请求权限。但是当调用getcurrentposition时它不会得到位置。我使用FireFox浏览器。
I am working with geolocation plugin with ionic2. When the app loads in the browser, it asks for permission. But it does not get the position when getcurrentposition is called. I use FireFox browser.
控制台日志显示错误:
EXCEPTION :未捕获(承诺):false
EXCEPTION: Uncaught (in promise): false
我需要将位置(如果可用)或null转移到另一个函数,基于成功或失败getcurrentlocation调用。
I need to pass the location if available or null to another function based on success or failure of the getcurrentlocation call.
以下是代码段:
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("", "");
});
}
推荐答案
插件 Geolocation
适用于设备移动
并且用于在设备中抛出 catch
移动设备在这个中查看我的其他答案链接
And for throw the catch
in a device mobile look at my other answer in this link
这篇关于ionic2:浏览器中的地理位置失败,错误:EXCEPTION:Uncaught(in promise):false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!