Thanks for reply me mvrc. I don’t have error but I can’t see anything in my screen, all is white (using google chrome and my smartphone Android). My code is like this:
home.html
<ion-header>
<ion-navbar>
<ion-title>
Map
</ion-title>
<ion-buttons end>
<button (click)="addMarker()"><ion-icon name="add"></ion-icon>Add Marker</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content>
<div #map id="map"></div>
</ion-content>
home.ts
import {Component, ViewChild, ElementRef} from ‘@angular/core’;
import {NavController} from ‘ionic-angular’;
declare var google;
@Component({
templateUrl: ‘build/pages/home/home.html’
})
export class HomePage {
@ViewChild(‘map’) mapElement: ElementRef;
map: any;
constructor(public navCtrl: NavController) {
}
ionViewLoaded(){
this.loadMap();
}
loadMap(){
let latLng = new google.maps.LatLng(-34.9290, 138.6010);
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
}
}
home.scss
.scroll {
height: 100%;
}
#map {
width: 100%;
height: 100%;
}
and I add this line in my index.html
<script src="http://maps.google.com/maps/api/js"></script>
Do you know how to solve it?
Thanks in advance!