I try to learn IONIC 5. I use native geolocation to return latitude and longitude. From this function i need to retrive lat and long and then make available to sent to the server trough a form.
geolocate()
{
this.geolocation.getCurrentPosition().then((resp) => {
let position = {
latitude: resp.coords.latitude,
longitude: resp.coords.longitude
}
return position;
}).catch((error) => {
console.log('Error getting location', error);
});
}
using this other function
login(form: NgForm) {
this.geolocate();
this.authService.login(form.value.email, form.value.password, this.latitude, this.longitude).subscribe(
data => {
this.alertService.presentToast("Logged In");
},
error => {
console.log(error);
},
() => {
this.dismissLogin();
this.navCtrl.navigateRoot('');
}
);
}