提问者:小点点

Google Places API中附近搜索和文本搜索的区别


在Google Places API中,附近搜索和文本搜索有什么区别?

例如,使用https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&types=cafe&key=your_api_key搜索半径1公里内的咖啡馆仅返回1个结果

使用https://maps.googleapis.com/maps/api/place/textsearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&query=cafe&key=your_api_key对半径1公里内的咖啡馆进行文本搜索会返回20个结果。

将types更改为附近搜索中的type还会返回20个结果,这些结果也与使用上面的文本搜索找到的结果不同。ie https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&type=cafe&key=your_api_key

当你在谷歌地图android应用上使用上面给出的位置进行咖啡馆搜索时,你得到的结果和你使用上面的文本搜索得到的结果是一样的。

为了方便起见,下面是上面的可点击链接

https://maps.googleapis.com/maps/api/place/textsearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&query=cafe&key=

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&type=cafe&key=

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-41.319282,174.818717&radius=1000&sensor=true&types=cafe&key=


共1个答案

匿名用户

简单地说,附近的地方可以让你搜索得更模糊,但只返回特定的结果。在文本搜索中,如果你搜索“餐馆”,它将搜索带有文本“餐馆”的地点,机构或名称。任何与餐馆有关的东西。同时,在附近搜索,如果你搜索“restaurants”,它将返回有或没有文本“restaurants”的restaurants restaurants,但只返回“restaurants”的restaurants。