我目前正在一个项目中,我想在该项目上使用Google Places API进行多个“附近搜索”调用,并将结果存储在一个列表中,以便我可以随机选择该列表中的一个位置,以将其显示为标记一张地图。由于某些原因,我在将这些位置保存到列表时遇到了麻烦。有什么想法吗?
预先感谢您,如果这是一个令人困惑或愚蠢的问题!
您可以在此处找到API的所有可用选项:Nearby Search requests
假设response
是Google Maps附近搜索API的返回对象。
const keywords = ['my', 'multiple', 'keyword', 'searches']
let list = []
keywords.forEach(async(keyword) => {
await nearbySearchCall(keyword) // This is your nearby place search logic
let results = response.results
list.push(...results)
})
// insert code here for iterating the responses and plotting onto the map.