0

我正在使用 AGM(角度谷歌地图)库处理角度。我不知道如何让每个标记的信息窗口内容不同。我希望每个标记都有自己的信息弹出。这是我的 component.html :

<div class ="content">
    <h2>Popular Locations around InComm</h2>
<agm-map>
    [latitude]="latitude"
    [longitude]="longitude"
    [zoom]="zoom" >

<agm-marker *ngFor="let location of locations"
[latitude]= "location.latitude"
[longitude] ="location.longitude"
[label]= "location.label"
(markerClick)="clickedMarker(infowindow)"
>

<agm-info-window #infowindow>
    <strong>InfoWindow content</strong>
  </agm-info-window>

</agm-marker>

</agm-map>
</div>

这是我的 component.ts :


previous;
clickedMarker(infowindow) {
  if (this.previous) {
      this.previous.close();
  }
  this.previous = infowindow;
}

markerDragEnd(m: location, $event: MouseEvent) {
  console.log('dragEnd', m, $event);
}

任何帮助将不胜感激,谢谢!

4

1 回答 1

2

替换<strong>InfoWindow content</strong>为您要替换的内容。例如如果你想显示标签只需添加{{location.label}}

<agm-info-window #infowindow>
    <strong>{{location.label}}</strong>
  </agm-info-window>

</agm-marker>
于 2020-05-09T01:42:19.897 回答