Geolocation nativescript地理位置“;getCurrentLocation";函数在nativescript 2.5.0(IOS)中给出错误
我正在开发nativescript-Angular2应用程序。我正在尝试使用nativescript地理位置插件获取用户的位置。但是当我调用“getCurrentLocation”时,它给出了一个错误,它说“新位置比请求的最大年龄早!” 这是我的环境信息 nativescript 2.5.0Geolocation nativescript地理位置“;getCurrentLocation";函数在nativescript 2.5.0(IOS)中给出错误,geolocation,angular2-nativescript,nativescript-plugin,Geolocation,Angular2 Nativescript,Nativescript Plugin,我正在开发nativescript-Angular2应用程序。我正在尝试使用nativescript地理位置插件获取用户的位置。但是当我调用“getCurrentLocation”时,它给出了一个错误,它说“新位置比请求的最大年龄早!” 这是我的环境信息 nativescript 2.5.0 tns核心模块2.4.4 tns安卓2.5.0 tns ios 2.5.0 nativescript地理位置0.0.19 这是我的代码示例 ngOnInit() { if (!isEnabled()) {
tns核心模块2.4.4
tns安卓2.5.0
tns ios 2.5.0 nativescript地理位置0.0.19 这是我的代码示例
ngOnInit() {
if (!isEnabled()) {
enableLocationRequest();
}
}
buttonTap() {
var location=getCurrentLocation({desiredAccuracy:3,updateDistance:10,maximumAge: 20000, timeout: 20000 }).
then(function (loc) {
if (loc) {
console.log("User location is: " + loc);
}
}, function (e) {
console.log("Error: " + e.message);
});
}
请帮助。您需要更改maximumAge:20000或将其完全删除。谢谢@RandyJohnson,您的解决方案成功了!!