首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >完成加载: Angular5 "<URL>“继续运行

完成加载: Angular5 "<URL>“继续运行
EN

Stack Overflow用户
提问于 2018-03-06 13:19:12
回答 1查看 414关注 0票数 1

我有一个角5应用程序,并支持一个api,提供了一个列表附近的快递员(出租车司机)的选定标记位置。直到今天,所有的东西都运行得很完美,好像一直在从api中请求快递者的位置。请求是从服务中的方法发出的。

以前有谁面临过这个问题吗?

组件:

代码语言:javascript
复制
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;
        });
      }
    }
  );
}

服务:

代码语言:javascript
复制
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(由服务响应)。我该拿这个怎么办?

EN

回答 1

Stack Overflow用户

发布于 2018-03-06 17:33:10

解决方案:看起来它是使用API的实验性版本的任何站点

如果将?v=3添加到js调用中,那么它将使用发布版本(3.31)而不是(3.32)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49131823

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档