我正在尝试使用Angular Google地图在地图上显示放置在数组中的位置。如果我从组件和HTML中删除标记的编码,它的工作正常。所以我想这个问题应该在HTML页面中
export class MapviewComponent {
zoom: number = 8;
lat: number = 37.7919038;
lng:number = -96.8651164 ;
//Markers
markers: marker[] = [{lat: 51.673858,lng: 7.815982},{lat: 51.373858,lng: 7.215982}] }
HTML编码
<agm-map
[latitude]="lat"
[longitude]="lng"
[zoom]="zoom"
[disableDefaultUI] = false
[zoomControl] = "false"
(mapClicked) = "mapClicked($event)">
<agm-marker
*ngFor = "let m of markers; let i = index"
(markerClick) = "clickedMarker(m, i)"
[latitude]="m.lat"
[longitude]="m.lng"
[label]="m.label"
[markerDraggable]="m.draggable"
(dragEnd)="markerDragEnd(m, $event)">
</agm-marker>
</agm-map>