我正在使用agm-direction绘制使用路线。
我需要显示完整的旅行地图起点到目的地以及航路点。如果航路点大于23,则Google API显示返回错误。 请告诉我如何正确绘制地图。
Component.ts:-
routes_array = [
"30.708390,76.703096",
"30.708372225261858,76.7030747335146",
"30.708127263140252,76.70344730933701",
"30.70803462555741,76.70358717441559",
"30.707881386270177,76.70371748541488",
"30.707725575199227,76.70383928049104",
"30.70758387610322,76.70398586890322",
"30.707436869664527,76.70412355486599",
"30.70731136863878,76.70424766838549",
"30.707386199539844,76.70444440432814",
"30.70744726771558,76.7046474777252",
"30.7074794276252,76.70479886233807",
"30.70759153259385,76.70497069217667",
"30.707684854279915,76.70515885650899"
]
lat : Number;
lng : Number;
origin : any;
destination : any;
waypoints : any = [];
ngOnInit() {
let firstLatLng = routes_array[0];
let firstlatLngArray = firstLatLng.split(',');
this.lat = +firstlatLngArray[0];
this.lng = +firstlatLngArray[1];
let lastLatLng = routes_array[(routes_array).length-1];
let lastlatLngArray = lastLatLng.split(',');
this.origin = null;
this.destination = null;
this.origin = { lat: this.lat, lng: this.lng };
if(+lastlatLngArray[0] != this.lat && +lastlatLngArray[1] != this.lng) {
this.destination = { lat: +lastlatLngArray[0], lng: +lastlatLngArray[1] };
}
this.waypoints = [];
}
Component.html:-
<agm-map [latitude]="lat" [longitude]="lng">
<agm-direction [origin]="origin" [destination]="destination" [waypoints]="waypoints"></agm-direction>
</agm-map>