【问题标题】:Google API for Restaurants Places用于餐厅的 Google API
【发布时间】:2013-04-24 20:57:09
【问题描述】:

我在理解 Google Places API 时遇到问题。我正在构建一个具有附近功能的 iPhone 应用程序,该功能允许用户找到位于用户 GPS 周围的餐馆。我怎样才能为此获得 Google API?我必须定制一个这是如何工作的吗?如果我还想为兴趣点创建 API,我该怎么做?

【问题讨论】:

    标签: google-places-api


    【解决方案1】:

    有一个用于搜索附近位置的 Google Places API。文档在这里:https://developers.google.com/places/documentation/search#PlaceSearchRequests

    但我猜你已经找到了。如果您提出更具体的问题,我们可以提供更多帮助。

    【讨论】:

    • 感谢您的帮助。我很难理解 API。我想我现在已经掌握了一些方法。我正在使用 seattleclouds.com 构建一个应用程序。如何以 HTML 格式显示使用 google API 返回的结果?
    • 你需要告诉我你使用的是什么编程语言。
    【解决方案2】:

    您可以使用 Google place API,如果您只想在您的案例中显示特定类型的地点,例如餐厅,您可以使用如下代码所示的请求对象

     var request = {
        location: pyrmont,
        type: ['restaurant']
      };
    
     infowindow = new google.maps.InfoWindow();
      places = new google.maps.places.PlacesService(map);
    places.nearbySearch(request, callback);
    

    有关 google place API 中类型过滤的更多详细信息,您可以查看Link on Google Developers。 但是附近的搜索只带一个类型参数,而且只有餐馆。如果您正在寻找公共餐饮场所,则不是食物,不是咖啡馆,只有 Google API 提供的餐厅。

    【讨论】:

      【解决方案3】:

      首先,Google Paces API 应该处于活动状态。

      function displayRestaurantAround() {
        return new Promise((resolve, reject) => {
          this.service.nearbySearch({
            location: currentUserPosition,
            radius: 5000,
            types: ['restaurant']
          }, (res) => {
            resolve(res);
          });
        });
      }
      

      【讨论】:

        猜你喜欢
        • 2013-04-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多