Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Uncaught (in promise): TypeError: Cannot read property 'panTo' of undefined

$
0
0

@chauhan911 wrote:

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;

}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>