Nouf
Nouf

Reputation: 773

How to display the more than one location on google maps

I am trying to display the more than one location in my application on google map but I can only show one location how can I show more than one

page.html

   <agm-map [latitude]="lat"[longitude]="lng" [zoom]="15"
          [zoomControl]="false">
      <agm-marker *ngFor="let location of tracks" [latitude]="tracks.lat" [longitude]="tracks.lng" [label]="tracks.label"></agm-marker>
    </agm-map>

page.ts

    constructor(private geolocation: Geolocation) {
    this.lat=51.723858
    this.lng=7.895982

  this.tracks = [
            {lat:51.673858, lng: 7.815982,label: 'A'},
            {lat:51.373858, lng: 7.215982,label: 'B'},
        ];

  }

Upvotes: 1

Views: 249

Answers (1)

Peter
Peter

Reputation: 933

Since you're assigning each item in tracks to the variable location you should be using location.lat instead of tracks.lat.

Upvotes: 1

Related Questions