如何在Google地图上显示多个位置

时间:2017-07-18 08:38:17

标签: angularjs ionic-framework ionic2

我正在尝试在Google地图上显示我的应用程序中的多个位置,但我只能显示一个位置如何显示多个

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'},
        ];

  }

1 个答案:

答案 0 :(得分:1)

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