Я пытаюсь найти геолокацию в 3. ионном, когда я использую геолокацию "getcurrentlocation ()" не работает.Он показывает ошибку, как показано ниже, и я не знаю, как решить эту проблему. Ниже приведен код.
import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { GeolocationOptions, Geoposition } from
'@ionicnative/geolocation' ;
@IonicPage()
@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
export class HomePage {
currentPos : Geoposition;
constructor(
public navCtrl: NavController,
public navParams: NavParams,
private geolocation: Geolocation
) {
}
ionViewDidEnter(){
this.getUserPosition();
}
getUserPosition(){
this.geolocation.getCurrentPosition().then((pos : Geoposition) => {
this.currentPos = pos;
console.log(pos);
},(err : PositionError)=>{
console.log("error : " + err.message);
});
}
}