此问题是对一些过时问题的更新:
因为我需要一种方法来到达所有餐馆、商店和教堂,我认为 Google Places API 似乎可以满足我的要求,但我在过滤时遇到一些麻烦:我想在一个请求中搜索多个地点类型。
let url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?"
url += "location=" + 79.999 + "," + 8.999
url += "radius=" + 2000
url += "type=" + mytype// ??
url += "key=" + mykey
这就是我的网址应该的样子。但我在设置多种类型时遇到了麻烦,例如:
将 mytype
设置为“restaurant”可能效果很好。
将 mytype
设置为“餐厅、商店、教堂”不起作用。
将 mytype
设置为“[restaurant,store,church]”也不起作用。
我知道 Google 很久以前就禁用了搜索多种地点类型的功能。但是使用 javascript API 对于多种类型绝对可以正常工作,因此 URL 请求可能也应该以这种方式工作。
最佳答案
用 "|"
分隔类型就可以了。
let mytype = "restaurant|food|store"
let url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?"
url += "location=" + 79.999 + "," + 8.999
url += "radius=" + 2000
url += "type=" + mytype// ??
url += "key=" + mykey
Volià,希望我能帮忙。
关于javascript - Google 放置 : Use multiple types,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48793047/