Can someone help me figure out what's causing the issue in my code? When I try to load a google map in my ionic 2 app, the marker doesn't show up the first time. It only appears when I reload the map for the second time or later.
I also need assistance on how to display the route between the user's location and the marker's location.
export class Map implements OnInit {
map:GoogleMap;
constructor(public navCtrl: NavController, public navParams: NavParams,private googleMaps: GoogleMaps) {}
ngOnInit() {
this.loadMap()}
loadMap() {
let location : LatLng = new LatLng(xxxxx,yyyyyy);
const markerOptions: MarkerOptions = {
position: location,
title: 'Dubai'
};
this.map = new GoogleMap('map', {
'backgroundColor': 'white',
'controls': {
'compass': true,
'myLocationButton': true,
'indoorPicker': true,
'zoom': true
},
'gestures': {
'scroll': true,
'tilt': true,
'rotate': true,
'zoom': true
},
'camera': {
'latLng': location,
'tilt': 30,
'zoom': 15,
'bearing': 50
},
});
this.map.addMarker(markerOptions).then(data => {data.showInfoWindow();});
this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => console.log('Map is ready!'));
}
}