In my current project using ionic3 and angular 4, there are times when retrieving the user's current location can be challenging due to slow internet connection. To address this issue, I would like to implement a feature where if after 30 seconds the app fails to retrieve the user's position, an alert will prompt the user to try again.
ionViewDidLoad() {
let loader = this.loadingCtrl.create({
content : 'Checking Position...'
})
loader.present().then(()=>{
this.geolocation.getCurrentPosition({
enableHighAccuracy:true,
timeout: 3000
}).then((resp) => {
this.userlng = resp.coords.longitude;
this.userlat = resp.coords.latitude;
console.log('latitude '+this.userlat+ ' longitude '+this.userlng);
})
})
}