【问题标题】:How to change content inside of info window for different markers?如何为不同的标记更改信息窗口内的内容?
【发布时间】:2020-05-09 09:42:19
【问题描述】:

我正在使用 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);
}

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

【问题讨论】:

    标签: javascript angular google-maps angular-google-maps agm


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2012-08-30
      • 2023-03-21
      • 1970-01-01
      • 2015-10-08
      • 1970-01-01
      • 1970-01-01
      • 2012-08-28
      • 1970-01-01
      • 2015-06-07
      相关资源
      最近更新 更多