1
我正在开发一个应用程序,使用Ionic v2,Google Maps API v3和Cordova Geolocation来跟踪用户的位置。Ionic 2和Cordova Geolocation之间的集成
问题: 当我在GPS关闭的Android设备上运行应用程序时,我总是收到“代码3:超时过期”错误。
我的问题是:
- 如若科尔多瓦地理位置使用电话网络(或WiFi)来获得用户位置时,GPS离线?
- 如果没有,还有另一种方法可以使用网络或Wifi找到用户位置?
我的代码:
getCurrentPosition (callback: (result: any) => any) {
Geolocation.getCurrentPosition({timeout: 5000}).then((resp) => {
console.log('Getting location:');
console.log('Lat ' + resp.coords.latitude);
console.log('Lng ' + resp.coords.longitude);
callback(resp.coords); // send the results to the
}).catch((error) => {
alert('Error getting location'+JSON.stringify(error));
alert(' Code: '+ error.code + ' Message: ' +error.message);
});
}
最佳,