I’m using Ionic 3. I tried running my app in the browser and the markers can be seen. When I run it in my android device, only the current location was marker-ed. Any answers why it wasn’t found in my android device?
displayGoogleMap() {
//get current location
this.geolocation.getCurrentPosition().then((resp) => {
let latLng = new google.maps.LatLng(resp.coords.latitude, resp.coords.longitude);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
this.map = new google.maps.Map(this.mapContainer.nativeElement, mapOptions);
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: latLng
});
this.addInfoWindow(marker, 'Current Location');
}).catch((error) => {
console.log('Error getting location', error);
});
my displayGoogleMap() works but when I’ll add multiple markes, it doesn’t appear already.
addMarkersToMap(bank) {
console.log('bank: '+bank['id']+'lat: '+bank['address']['latitude']+' longi: '+bank['address']['longitude']);
let position = new google.maps.LatLng(bank['address']['latitude'], bank['address']['longitude']);
let mapOptions = {
center: position,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
this.map = new google.maps.Map(this.mapContainer.nativeElement, mapOptions);
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: position
});
this.addInfoWindow(marker, bank['institution']);
}
addInfoWindow(marker, content){
let infoWindow = new google.maps.InfoWindow({
content: content
});
google.maps.event.addListener(marker, 'click', () => {
infoWindow.open(this.map, marker);
});
}
retrieveBloodBanks(){
var secret='aaaaaaaaaaaa';
// return new Promise(resolve => {
this.http.get('http://asdfghjk.aaa.aa.aa/api/institutions?secret='+secret)
.map(res => res.json())
.subscribe(data => {
this.bankList = data;
console.log( 'rtvr bank: '+this.bankList);
for (let bank of this.bankList['institutions']) {
console.log(bank['id']);
this.addMarkersToMap(bank);
}
});
// });
}
You’re a big help to my thesis if you could help me.
}