我在角度4中使用@ agm / core,我想在两点之间获取方向以在地图上绘制它们,但我不知道该怎么做。 官方网站上的文档很少,我得到的@ agm / core的版本是1.0.0-beta.1
HTML code:
<agm-map>
<agm-polyline>
<agm-polyline-point *ngFor="let coordinate of coordinates"
[latitude]="coordinate.latitude"
[longitude]="coordinate.longitude">
</agm-polyline-point>
</agm-polyline>
</agm-map>
组件代码:
public coordinates: [
{
latitude: number,
longitude: number,
}
];
答案 0 :(得分:3)
代码HTML模板:
<agm-map
[latitude]="lat"
[longitude]="lng"
>
<agm-marker
*ngFor="let coordinate of coordinates; let i=index"
[latitude]="coordinate.lat"
[longitude]="coordinate.lng"
></agm-marker>
<agm-polyline
[visible]="true"
[strokeWeight]="3">
<agm-polyline-point
*ngFor="let coordinate of coordinates; let i=index"
[latitude]="coordinate.lat"
[longitude]="coordinate.lng">
</agm-polyline-point>
</agm-polyline>
</agm-map>