我尝试学习 IONIC 5。我使用本地地理定位来返回纬度和经度。从这个函数中,我需要检索经纬度,然后通过表格发送到服务器。
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);
});
}
使用这个其他功能
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('');
}
);
}