我想使用agm在Google Maps中设置多个标记,以便在使用静态坐标时可以看到正在Google Maps上移动。
它适用于一个标记,但是我不知道如何使用多个标记。
这是HTML:
<ngx-spinner bdColor="rgba(51,51,51,0.8)"
size="medium"
color="#fff"
type="ball-scale-multiple">
</ngx-spinner>
<div class='agm-map-container-inner sebm-google-map-container-inner'>
<agm-map width="100%" [latitude]="current_position.lat" [zoom]="zoom" [longitude]="current_position.long" [styles]="styles">
<agm-marker *ngFor="let loc of loc" (markerClick)="eraseMarker(location)" [latitude]="loc.lat" [longitude]="loc.long" [iconUrl]="icon"></agm-marker>
<agm-polyline strokeColor="red" >
<agm-polyline-point *ngFor="let location of loc" [latitude]="location.lat" [longitude]="location.long"></agm-polyline-point>
</agm-polyline>
</agm-map>
</div>
这是类型脚本:
track(){
let i=0
const obs=interval(2000).pipe(takeWhile((v) => i < this.location.length)).subscribe(()=>{
const pos=this.location[i];
this.loc.push(pos);
this.current_position=pos;
i++;
}
})