map: any;
@ViewChild('map', {read: ElementRef, static: false}) mapRef: ElementRef;
data: any;
infoWindows: any = [];
markers: any = {};
constructor(private http: HttpClient) {}
get_location(){
this.http.get('http://gsmgpsppm.000webhostapp.com/fetch_data.php')
.subscribe(data =>{
console.log("received: " + JSON.stringify(data[0][0]));
this.markers = JSON.stringify(data[0][0]);
});
}
ionViewDidEnter() {
this.showMap();
}
addMarkersToMap() {
this.get_location();
let position = new google.maps.LatLng( this.markers["latitude"] , this.markers["longitude"] );
let mapMarker = new google.maps.Marker({
position: position,
latitude: this.markers["latitude"],
longitude: this.markers["longitude"]
});
Given the above code, in function LatLng I can’t display markers data, received from an http.get as:
Is there anything wrong with the syntax??
1 post - 1 participant