I am trying to panTo an area on a map by using ionic geolocation plugin and passing the argument
location but shows uncaught error.
code for this is
ngOnInit(){
this.getCurrentLocation().subscribe(location => {
this.map.panTo(location);
});
}
getCurrentLocation(){
let loading = this.loadingCtrl.create({
content: 'Locating...'
});
loading.present();
let options = {timeout:10000, enableHighAccuracy: true};
let locationObs = Observable.create(observable => {
this.geolocation.getCurrentPosition(options)
.then(resp => {
let lat = resp.coords.latitude;
let lng = resp.coords.longitude;
let location=new google.maps.LatLng(lat,lng);
observable.next(location);
loading.dismiss();
},
(err)=>{
console.log('Error getting location'+ err);
loading.dismiss();
})
})
return locationObs;
}