Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48979

Can't display marker from http.get

$
0
0
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

Read full topic


Viewing all articles
Browse latest Browse all 48979

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>