我有一个角5应用程序,并支持一个api,提供了一个列表附近的快递员(出租车司机)的选定标记位置。直到今天,所有的东西都运行得很完美,好像一直在从api中请求快递者的位置。请求是从服务中的方法发出的。
以前有谁面临过这个问题吗?
组件:
ngOnInit() {
this.loadMap();
this.startMap();
this.loadCustomerAddresses();
}
startMap(){
google.maps.event.addListener(this.map, 'idle', () => {
if(this.sourceConfirmed == false){
this.locateSource();
}else if(this.destinationConfirmed == false){
this.locateDestination();
}else if(this.addingNextDestination == true){
this.destComponent.locateNextDestination();
}else{
return false;
}
})
locateSource(){
this.markerSource = new google.maps.Marker({
position: this.map.getCenter(),
map: this.map,
draggable: false
});
this.markerSource.setVisible(false);
this.mapCenter = this.map.getCenter();
this.markerSource.setPosition(this.mapCenter);
this.sourceLat = this.markerSource.getPosition().lat();
this.sourceLng = this.markerSource.getPosition().lng();
this._orderService.getPlaceName(this.sourceLat, this.sourceLng).subscribe(
name => {
this.sourceAddress = name;
}
);
this._orderService.loadCouriersNearby(this.mapCenter.lat(), this.mapCenter.lng()).subscribe(
result => {
if(result.status == 'success'){
let couriers = result.couriers;
this._zone.run(() => {
this.couriersCount = couriers.length;
});
for (let courier of couriers) {
let latLng = {lat: Number(courier.location.latitude), lng: Number(courier.location.longitude)};
let courierMarker = new google.maps.Marker({
position: latLng,
})
courierMarker.setMap(this.map)
this.couriersMarkers.push(courierMarker);
}
}else{
this._zone.run(() => {
this.couriersCount = 0;
});
}
}
);
}服务:
loadCouriersNearby(lat, lng){
var url = 'http://my.domain.path';
var headers = new HttpHeaders().set('x-mobile-token', this._cookieService.get('token'));
var params = new HttpParams()
.set('latitude', lat)
.set('longitude', lng)
return this.http.get(url, {headers: headers, params: params}).map(response=>response.data);
}现在,它正在向API发送大约3次请求以获取点数,并且它们确实发送了一组快递员列表,但是大量的请求不允许在地图上显示信使的mraker(由服务响应)。我该拿这个怎么办?
发布于 2018-03-06 17:33:10
解决方案:看起来它是使用API的实验性版本的任何站点
如果将?v=3添加到js调用中,那么它将使用发布版本(3.31)而不是(3.32)
https://stackoverflow.com/questions/49131823
复制相似问题