You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Google Maps附近搜索返回INVALID_REQUEST错误,请求为何失效?

Google Places Nearby Search 返回INVALID_REQUEST错误的原因及解决办法

你的请求返回INVALID_REQUEST是因为缺少API要求的必填参数。Google Places Nearby Search API明确规定,发起请求时必须二选一指定以下参数:

  • radius:设置搜索范围的半径(单位为米)
  • rankby=distance:按距离排序,但使用这个参数时必须同时搭配keyword、name或type中的至少一个参数来限定搜索内容

你的请求https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=10,10&key=MY_API_KEY里既没有radius,也没有rankby=distance及配套的限定参数,因此被判定为无效请求。

修正示例

  • 添加radius参数(示例设置半径为5000米):
    https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=10,10&radius=5000&key=MY_API_KEY
    
  • 使用rankby=distance并搭配type参数(示例搜索附近的咖啡馆):
    https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=10,10&rankby=distance&type=cafe&key=MY_API_KEY
    

内容的提问来源于stack exchange,提问作者porton

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 21:20:27