【问题标题】:How do I find all the restaurants in a city without mentioning radius如何在不提及半径的情况下找到城市中的所有餐厅
【发布时间】:2021-10-11 10:17:31
【问题描述】:

我正在寻找 10 个城市的所有餐厅。有的面积小,有的面积大。我无法指定半径。例如,考虑位置名称 Chandigarh。我拿起了昌迪加尔中心的纬度经度'30.740889611128623, 76.77223250477658'。现在我想找到昌迪加尔的所有餐馆。如果指定半径,它将对城市无效。我想根据位置而不是城市来查找餐厅。因此我无法动态化我的代码。我如何实现它?下面给出错误ApiError: INVALID_REQUEST

gmaps = googlemaps.Client(key = API_KEY)
places_result  = gmaps.places_nearby(location='30.740889611128623, 76.77223250477658', name='Chandigarh', open_now =False , type = 'restaurant')

【问题讨论】:

    标签: python google-maps google-cloud-platform google-places-api


    【解决方案1】:

    根据 Places API documentation

    INVALID_REQUEST 表示 API 请求格式错误,一般是由于 到缺少的必需查询参数(位置或半径)。

    确实,您在代码中指定了位置参数,但没有提供半径参数。只有当您 在您的请求中指定 rankby=distance。

    半径 — 定义返回位置结果的距离(以米为单位)。最大允许半径为 50 000 米。请注意,如果指定了 rankby=distance(在下面的可选参数中描述),则不得包含半径。

    请参阅附近搜索中的documentation

    【讨论】:

    • places_result = places_result = gmaps.places_nearby(location='30.740889611128623, 76.77223250477658',rankby='distance', name='Chandigarh', open_now =False , type = 'restaurant')。它说“places_nearby() 有一个意外的关键字参数 'rankby'”
    • syntax 似乎有点错误。这个link 可能对你有帮助,如果没有帮助,请告诉我。
    猜你喜欢
    • 2013-08-21
    • 1970-01-01
    • 2010-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多