javascript - Google 放置 : Use multiple types

标签 javascript swift google-maps google-maps-api-3

此问题是对一些过时问题的更新:


因为我需要一种方法来到达所有餐馆商店教堂,我认为 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/

相关文章:

javascript - 使用 jQuery 单击时垂直滚动 100%

HTMLPanel 中的 Javascript

swift - 如何将 UICollectionViewCell 高度设置为 View (屏幕)高度的 90%?

ios - 如何在iOS中显示来自网络的pdf

javascript - Google map 捏合不适用于 Microsoft Surface

javascript - 通过缩放调整自定义图像标记的大小 - Google Maps API v3

javascript - React.js .map 不是函数,映射 Firebase 结果

angularjs - 我们可以使用 Angular.js 来完全替代 javascript 模板引擎吗?

ios - 带有渐变的 CAShapeLayer

javascript - 使用 CSS 为 Google API map 标记制作动画?