【问题标题】:How can i add marker on google map如何在谷歌地图上添加标记
【发布时间】:2021-11-25 15:46:31
【问题描述】:

我想让它在谷歌地图上标出想要的地方,我该怎么做?

<google-map id="map-container" width="100%" height="100%" class="maps"></google-map>

【问题讨论】:

标签: html css angular typescript


【解决方案1】:

你可以像这样在angular中添加它:

<google-map>
  <map-marker
    *ngFor="let marker of markers"
    [position]="marker.position"
    [label]="marker.label"
    [title]="marker.title"
    [options]="marker.options"
  >
  </map-marker>
</google-map>

// Add to list like this way
this.markers.push({
  position: {
    lat: latitudeValue,
    lng: longitudeValue,
  },
  label: {
    color: 'red',
    text: 'Marker label ' + (this.markers.length + 1),
  },
  title: 'Marker title ' + (this.markers.length + 1),
  options: { animation: google.maps.Animation.BOUNCE },
});

【讨论】:

  • 标记列表应该是怎样的?
  • @VolkanUstekidag 请检查更新的答案。
猜你喜欢
  • 2016-03-16
  • 2017-12-25
  • 1970-01-01
  • 2021-09-12
  • 1970-01-01
  • 2015-08-18
  • 2021-07-22
  • 1970-01-01
相关资源
最近更新 更多