Showing only one marker when there should be multiple in Angular Google Map

Viewed 1761

I am using Angular Google Map from https://angular-maps.com . I wanted to show multiple markers using ngFor directive on agm-marker element. Though DOM shows all of the markers are present, UI shows only the first one on the map.

Here is HTML part:

<agm-map [latitude]="lat" [longitude]="long" [zoom] = 16>
<agm-marker *ngFor="let m of latlongs; let i = index"
[latitude]="m.lat"
[longitude]="m.long"
[markerDraggable]="m.draggable"></agm-marker>

</agm-map> 

Typescript code is here:

 this.service.getData().subscribe(data => {
  let json: any[] = []; 
  json["data"] = data.json().map(it => {
    it["category"] = "location";
    it["gallery"] = ["../assets/img/area.png"];
    return it;
  });

  for(let i = 0; i < json["data"].length; i++){
    this.mapInfos.push({lat: +json["data"][i].lat, long: +json["data"][i].long});
  }

  this.latlongs = this.mapInfos;

});

I am using angular 4 for my project

2 Answers
Related