我正在使用agm(角度谷歌地图)并想使用 ngfor绘制n个圆圈,但出现错误:
Can't bind to 'ngFor' since it isn't a known property of 'agm-circle'.
这是我的html:
<agm-circle *ngFor="data in circles"
[latitude]="data.lat"
[longitude]="data.lng"
[circleDraggable]="true"
[editable]="true"
[fillColor]="'data.color'"
[radius]="data.radius"
>
</agm-circle>
这是我的ts文件有数据:
lat: number;
lng: number;
circle: any;
@ViewChild(AgmPolygon) polygon: any;
path = [
{ lat: 51.791629704426924, lng: 7.809007 },
{ lat: 51.974729774949644, lng: 0.6317138671875 },
{ lat: 51.303145259199056, lng: 0.6646728515625 },
{ lat: 51.416338106400396, lng: -0.4779052734375 }
];
constructor () {
this.lat = 51.678418;
this.lng = 7.809007;
this.circle = [
{lat: 51.79, lng: 7.8, radius: 60000, color: 'red'},
{lat: 52.79, lng: 12.8, radius: 60000, color: 'green'},
{lat: 54.79, lng: 10.8, radius: 60000, color: 'yellow'},
{lat: 51.79, lng: 8.8, radius: 60000, color: 'yellow'},
{lat: 60.79, lng: 7.8, radius: 60000, color: 'green'},
];
}
至于这些是虚拟数据,但圈子的数据将是n任何建议将不胜感激