@perenyitamas wrote:
As you can see in the code below, first i am asking the user to turn on the location then i get the geolocation of the user. I am using a 15 sec timeout, so if i can’t get the coordinates of the user, i am using a default location.
However this 15 sec timeout is already running while the location permission request window is active. How could i only run the geolocation code when the user select yes or no on the location permission alert?async locationReq(){ this.locationAccuracy.canRequest().then((canRequest: boolean) => { if(canRequest) { this.locationAccuracy.request(this.locationAccuracy.REQUEST_PRIORITY_HIGH_ACCURACY).then( () => console.log('Request successful'), error => console.log('Error requesting location permissions', error) ); } }); return await this.plt.ready().then(() => { let loader = this.loadingCtrl.create({content: "Helyadatok lekérdezése..."}); loader.present(); var options = { timeout: 15000 }; this.geolocation.getCurrentPosition(options).then(resp => { this.lat = resp.coords.latitude; this.lang = resp.coords.longitude; loader.dismiss(); this.mapLoadingPresent(); }).catch(() => { console.log("sikertelen location"); this.lat = 47.49801; this.lang = 19.03991; loader.dismiss(); this.mapLoadingPresent(); this.presentToast(); }); }); }
Posts: 2
Participants: 1