Ionic 3 Google maps - map doesn't show on android


#1

i’m trying to use geolocation and google maps with ionic 3, the app is working fine in the browser:

but for some reason, when i build the apk is not showing the map on my phone

this the geolocation .ts

import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { Geolocation, Geoposition } from '@ionic-native/geolocation';

declare var google;

@IonicPage()
@Component({
  selector: 'page-geo',
  templateUrl: 'geo.html',
})
export class GeoPage {
  map: any;

  constructor(public navCtrl: NavController, public navParams: NavParams, public geo:     Geolocation) { }

  ionViewDidLoad() {
    this.getPosition();
  }

  getPosition():any{
    this.geo.getCurrentPosition().then(resp => {

      this.loadMap(resp);

    }).catch((error) =>{
      console.log(error);
    })
  }
  loadMap(position: Geoposition){

let latitud = position.coords.latitude;
let longitud = position.coords.longitude;
console.log(latitud, longitud);

let mapEle: HTMLElement = document.getElementById('map');

let myLatLng = {lat: latitud, lng: longitud};

this.map = new google.maps.Map(mapEle, {
  center: myLatLng,
  zoom: 12
});



google.maps.event.addListenerOnce(this.map, 'idle', () => {
  let marker = new google.maps.Marker({
    position: myLatLng,
    map: this.map,
    title: 'Hello World!'
  });
  mapEle.classList.add('show-map');
    });

  }



}

i don’t know what’s wrong, thanks in advice


#2

Check if you are authorized all domain on Google Maps SDK. And debug device with chrome console :wink:


#3

same problem with me :frowning:


#4

Is this related to GDPR?


#5

General Data Protection Regulation??? no, i’m from south america(Chile), not europe


#6

it is showing the map on my phone (after some updates in the code), but only if you turn on the gps before starting the app, it doesnt work otherwise :confused:


#7

Thought maybe it was some new thing you had to approve @ google in order for it to work. So many privacy updates…


#8

Even though you’re in SA you have to conform to the GDPR if it’s available to EU cit.


#9

Hi guys,
This works for me Googlemap with geolocation