如何改变不同标记的信息窗口内的内容?

问题描述 投票:0回答:1

我正在使用AGM(angular google maps)库与angular一起工作。我不知道如何让每个标记的信息窗口的内容是不同的。我希望每个标记都有自己的信息弹出。这里是我的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.html:和这里是我的component.ts。


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

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

任何帮助将是apperciated,谢谢!

javascript angular google-maps angular-google-maps agm
1个回答
2
投票

替换 <strong>InfoWindow content</strong> 例如,如果你想显示标签,只需添加 {{location.label}}

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

</agm-marker>
© www.soinside.com 2019 - 2024. All rights reserved.