made looping markers

This commit is contained in:
piratefinn 2017-09-27 14:34:46 +01:00
parent 1eb79aa047
commit b59351addf
2 changed files with 29 additions and 1 deletions

View file

@ -22,7 +22,16 @@
[zoom]="zoom"
[scaleControl]="true"
(idle)="viewBoundsChanged($event)">
<agm-marker [latitude]="lat" [longitude]="lng"></agm-marker>
<agm-marker
*ngFor="let m of markers"
[latitude]="m.lat"
[longitude]="m.lng"
[label]="m.label">
<agm-info-window>
<strong>{{m.label}}</strong>
</agm-info-window>
</agm-marker>
</agm-map>
</div>
</div>

View file

@ -15,6 +15,25 @@ export class MapComponent implements OnInit {
dataReceived: string = 'yes';
markers = [
{
lat: 54.0466,
lng: -2.8007,
label: 'A',
},
{
lat: 54.0453,
lng: -2.83,
label: 'B'
},
{
lat: 54.0563,
lng: -2.8279,
label: 'C'
}
]
map: any;
constructor(