从googleapi自动完成请求中获取拉链
我将以下请求发送给Google Autococtlete API,以尝试获取包含邮政编码的街道地址。
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=917&component=country:us&key=[MyApiKey]&types=address&bounds=defaultBounds&stricktBounds=true&address_components=postal_code&fields=address_components
我似乎无法弄清楚如何在查询参数中询问邮政编码。当我通过输入中的ZIP传递完整地址时,Google返回邮政编码,但我希望它始终返回邮政编码。
我可以向Google Maps API提出另一个请求,并传递我从Autococtlete Endpt获得的位置ID,并通过以下请求获取完整的地址。
https://maps.googleapis.com/maps/api/place/details/json?fields=formatted_address&place_id=Eic1MDEgQ29sbGVnZSBBdmVudWUsIEdyZWVuc2Jvcm8sIE5DLCBVU0EiURJPCjQKMgldGdoYQBlTiBEjv0Tw4tNAARoeCxDuwe6hARoUChIJVXM4RSQZU4gRLNRdpst7vxAMEPUDKhQKEgmVWLxpQBlTiBGKDjnnY2NAzg&key=[my_Key]
但是我想进行搜索,并在一个请求中获取邮政编码。
编辑: 以下使用Google API JavaScript软件包在JavaScript中工作,但我无法在项目中使用JavaScript ...
https://maps.googleapis.com/maps/api/place/js/AutocompletionService.GetPredictions?1s501&fields=formatted_address&key=[my_key]
谢谢您的任何帮助!
I am sending the following request to the google autocomplete api in attempts to get a street address with the zip code included.
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=917&component=country:us&key=[MyApiKey]&types=address&bounds=defaultBounds&stricktBounds=true&address_components=postal_code&fields=address_components
I can't seem to figure out how to ask for the zip code in the query parameters. When I pass a full address with the zip in the input, google returns the zip code, but I would like it to always return the zip code.
I can make another request to the google maps api and pass the place id that I get from the autocomplete endpt and get the full address with the following request.
https://maps.googleapis.com/maps/api/place/details/json?fields=formatted_address&place_id=Eic1MDEgQ29sbGVnZSBBdmVudWUsIEdyZWVuc2Jvcm8sIE5DLCBVU0EiURJPCjQKMgldGdoYQBlTiBEjv0Tw4tNAARoeCxDuwe6hARoUChIJVXM4RSQZU4gRLNRdpst7vxAMEPUDKhQKEgmVWLxpQBlTiBGKDjnnY2NAzg&key=[my_Key]
But I would like to do a search and get the zip code all in one request.
Edit:
The following works in javascript with the google api javascript package, but I cannot use javascript in my project...
https://maps.googleapis.com/maps/api/place/js/AutocompletionService.GetPredictions?1s501&fields=formatted_address&key=[my_key]
Thanks for any help!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Google API Place TextSearch端点可以与字段类型ford_address一起使用以返回邮政编码。
The google api place textsearch endpoint can be used instead with field type formatted_address to return the zip code.