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