Google Map API 仅返回一个结果?
我正在使用谷歌地图 API 来开发 iOS 应用程序。我需要在地图上找到最近的加油站。当我调用 http 请求时: http:// /maps.googleapis.com/maps/api/geocode/json?address=%gas%20station&sensor=true,它返回一个结果。但这是唯一的一个。应该会有很多结果。无论我提交什么关键字,它都只返回一个结果。有谁知道如何处理这个问题?
I am using the google maps api to develop an iOS app. I need to find the nearest gas station on the map. When I call an http request: http://maps.googleapis.com/maps/api/geocode/json?address=%gas%20station&sensor=true, it returns one result. But it is the only one. There should be many results. No matter what keywords I submit, it only returns one result. Does anyone know how to deal with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在浏览器中打开该 URL 并得到以下响应:
{
“结果” : [],
“状态”:“ZERO_RESULTS”
根据
Google 地图文档此处,
“ZERO_RESULTS”表示地理编码成功但没有返回任何结果。如果向地理编码传递了不存在的地址或远程位置的经纬度,则可能会发生这种情况。
加油站是一个模糊的地址。尝试输入包含区域、城市或街道名称的有效地址。你会得到结果。例如 http://maps. googleapis.com/maps/api/geocode/json?address=250%20King%20St%20SF&sensor=true
您需要使用 Places API 用于搜索场所(餐厅、加油站等)等地点
I opened the URL in a browser and got this response :
{
"results" : [],
"status" : "ZERO_RESULTS"
}
According to Google Maps documentation here
"ZERO_RESULTS" indicates that the geocode was successful but returned no results. This may occur if the geocode was passed a non-existent address or a latlng in a remote location.
Gas station is a vague address. Try entering a valid address with a name of the area or city or the street. And you will get results. e.g. http://maps.googleapis.com/maps/api/geocode/json?address=250%20King%20St%20SF&sensor=true
You need to use the Places API to search for places like establishments(restaurants, gas stations,etc)
我不知道为什么,但是当我将结果打印到控制台时,它总是只显示一个结果。但在带有断点的调试模式下,有 5 个结果。
请使用调试模式检查一下。
I don't know why, but when I printed the result to the console, it always was showing only one result. But in a debug mode with a breakpoint there were 5 results.
Please check it out using a debug mode.