有没有办法按开放时间过滤谷歌餐厅?

时间:2018-03-25 22:35:33

标签: google-maps typescript ionic-framework google-maps-api-3 ionic3

Ionic 3 - 有没有办法通过开放时间按照open_now或评级来过滤谷歌餐馆?

getTypes(latLng) {
    let loading = this.loadingCtrl.create({
        content: 'Procurando...'
    });

loading.present();

var service = new google.maps.places.PlacesService(this.map);
let request = {
  location: latLng,
  radius: this.isKM,
  type: [this.item]
};
return new Promise((resolve, reject) => {
    service.nearbySearch(request, function (results, status) {
      if (status === google.maps.places.PlacesServiceStatus.OK) {
        resolve(results);
        loading.dismiss();
      } else {
         loading.dismiss();
         reject(status);
      }
    });
  });
}

1 个答案:

答案 0 :(得分:0)

PlacesService中的

nearbySearch()确实有openNow选项,仅搜索在发送查询时打开的地点。因此,您修改的示例代码将是:

var service = new google.maps.places.PlacesService(this.map);
let request = {
  location: latLng,
  radius: this.isKM,
  type: [this.item],
  openNow: true
};
return new Promise((resolve, reject) => {
    service.nearbySearch(request, function (results, status) {
      if (status === google.maps.places.PlacesServiceStatus.OK) {
        resolve(results);
        loading.dismiss();
      } else {
         loading.dismiss();
         reject(status);
      }
    });
  });
}

Nearby Search Documentation