无法获得有关Google Places API的其他详细信息,例如'opening_hours'

问题描述 投票:-1回答:1

我似乎无法通过使用Google Places API获得开放时间。

我使用Google地图查找具有营业时间和评分的商家。我选择了麦当劳。

enter image description here

然后我用google's tool搜索地址的place_id。

哪个让我得到place_id:

ChIJRRNEbiK0xokRxwlEbC1WEqk

enter image description here

然后我尝试使用place_id搜索位置详细信息

https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJRRNEbiK0xokRxwlEbC1WEqk&fields=name,rating,opening_hours&key=MY_KEY

但是我只得到名称,它被设置为地址。

enter image description here

[[edit] @geocodezip说,在地址开头添加“麦当劳”会返回不同的place_id。

我做错什么了吗?

google-maps google-places-api google-places
1个回答
1
投票
如果在工具中输入“麦当劳(McDonald's),美国宾夕法尼亚州费城,科特曼大街2801号,则得到的地点ID是:“ ChIJLZZdbiK0xokRqpqP6w3DRiM”]

如果我在your query (with a valid key)中使用该ID,则会收到包含额外数据的响应:

{ "html_attributions" : [], "result" : { "name" : "McDonald's", "opening_hours" : { "open_now" : true, "periods" : [ { "open" : { "day" : 0, "time" : "0000" } } ], "weekday_text" : [ "Monday: Open 24 hours", "Tuesday: Open 24 hours", "Wednesday: Open 24 hours", "Thursday: Open 24 hours", "Friday: Open 24 hours", "Saturday: Open 24 hours", "Sunday: Open 24 hours" ] }, "rating" : 3.1 }, "status" : "OK" }

proof of concept fiddle (uses the javascript API places library)

screenshot of fiddle
© www.soinside.com 2019 - 2024. All rights reserved.