I am using Angular Google Map from https://angular-maps.com . I wanted to show some markers using the ngFor directive for the agm-marker element. Although the DOM shows all the markers, the user interface shows only the first on the map.
Here is the 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 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
source
share