【问题标题】:Google Places API: how to search by type and location in PythonGoogle Places API:如何在 Python 中按类型和位置进行搜索
【发布时间】:2018-06-28 10:00:36
【问题描述】:

我正在遵循我在 GitHub 的 main page 上找到的相对于 googlemaps 的示例,并且我正在编写自己的代码以检索特定区域的所有电影院。

代码是这样的:

import googlemaps

gmaps = googlemaps.Client(key='MyGoogleKey')

search_loction = gmaps.location('40.714224, -73.961452').type('movie_theater')
print (search_loction)

它返回错误:

Traceback (most recent call last):
  File "GoogleMap.py", line 5, in <module>
    search_loction = gmaps.location('40.714224, -73.961452')
AttributeError: 'Client' object has no attribute 'location'

如果我按照指南进行操作,是的,属性 [location] 是允许的

那我做错了什么?

【问题讨论】:

  • 我不知道这个库,但您不应该使用gmaps.places(...) 并将位置作为参数吗?
  • 根据我的理解,这就是图片所说的,让我尝试使用地点
  • @MrUpsidown,您的建议是正确的,请将其作为答案发布,以便我将其标记为正确的回复

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


【解决方案1】:

根据documentation,你应该使用

gmaps.places(...)location 作为参数。

类似

gmaps.places(location=(lat,lng), type="movie_theater")

希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多