问题描述
我正在研究谷歌地图方向,根据 API,我每秒只能发出 10 个请求。
下面是我的代码,
<div *ngFor="let place of outstation_routes" class="item">
<figure class="wo-vehicles-img">
<agm-map [zoom]="1">
<agm-direction [origin]="place.origin" [destination]="place.destination">
</agm-direction>
</agm-map>
</figure>
</div>
现在的问题是,谷歌抛出这个错误message: "DIRECTIONS_ROUTE: OVER_QUERY_LIMIT:
那么我该如何克服这个问题,请指导
解决方法
看看这是否有帮助,每 1 秒后将数据推送到数组。
getOutstationRoutes() {
this.service
.getOutstationRoutes()
.pipe(
mergeMap(x => from(x)),concatMap(x => of(x).pipe(delay(1000)))
)
.subscribe(res => {
this.outstation_routes.push(res);
});
}
Stackblitz Example
找到推送数据的答案from here