google-api - 如何在 Google Places Autocomplete API 中获取位置
问题描述
因此,我使用 Google Places API 来搜索地点并从地点获取数据。
我的目标是通过名称获取位置(几何),独立于我的位置,在世界各地提供自动完成建议。这些是我测试的选项:
选项1
我已经在使用“findplacefromtext”:
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input={name of place}&inputtype=textquery&fields={fields}&language=en&key={key}"
https://developers.google.com/places/web-service/search#FindPlaceRequests
它有效,但我只得到一个结果。我想在该请求中获得自动完成建议。是否可以在此请求中返回 1 个以上的结果?
选项 2
因此,在我的第二种方法中,我尝试使用 AutoComplete 请求“autocomplete/json”:
https://maps.googleapis.com/maps/api/place/autocomplete/json?key={key}&input={text}&language=en
https://developers.google.com/places/web-service/autocomplete
这正是我正在寻找的,但它缺少位置和地点信息。它包含“place_id”,带有“place_id”我可以发出第二个请求,返回我需要的所有地点数据,但总共有 2 个请求,而不是 1 个。如果我有 15 个结果,我将拥有使用 15 个请求(Place Detail Request)
https://developers.google.com/places/web-service/details
是否可以在自动完成请求中返回地点信息,而无需提出地点详细信息请求?
解决方案
地方自动填充目前不返回或支持比此处指示的更详细的信息。如果您有兴趣拥有此功能,可以在 Google 的Public Issue Tracker中提交功能请求,供 Google 产品团队评估。
推荐阅读
- python - mkproject -t django 创建空目录而不是 django 项目
- jquery - Spring - 如何防止响应转换为换行符?
- javascript - JavaScript数组对象到一列csv字符串
- bash - 为什么我的带有管道的 xargs 命令仅适用于单个文件,而不适用于多个文件?
- arrays - 如何查找从文件中读取的二维数组的元素数?
- android - 如何用 doAsync 替换 AsyncTask
- php - 使用 PHP 数组输出 MySQL 查询 - foreach 循环错误“非法偏移”和“无效参数”
- sqlite - 如何在 Xamarin XAML 中对 Sqlite DB 进行原始查询
- selenium - 当他单击硒中的“返回顶部”按钮时如何验证用户已滚动到顶部
- python - 了解 Python 中的对象类型