Ionic DevApp: Google maps not showing

389 Views Asked by At

I have used JavaScript SDK to display map.

It's working on the browser but when I open it on dev app, the page shows the blank page.

 ionViewDidLoad(){
    this.loadMap();
  }

  loadMap(){

    this.geolocation.getCurrentPosition().then((position) => {

      let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);

      let mapOptions = {
        center: latLng,
        zoom: 15,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }

      this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);

    }, (err) => {
      console.log(err);
    });

  } 
1

There are 1 best solutions below

0
On

Try to add locationOption

let locationOptions = { timeout: 30000, enableHighAccuracy: true };

and pass to getCurrentPosition like this this.geolocation.getCurrentPosition(locationOptions).then((p‌​osition) => {